File tree Expand file tree Collapse file tree 4 files changed +28
-5
lines changed
app/src/main/java/org/fossasia/openevent/general Expand file tree Collapse file tree 4 files changed +28
-5
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import org.fossasia.openevent.general.order.OrderService
24
24
import org.fossasia.openevent.general.ticket.Ticket
25
25
import org.fossasia.openevent.general.ticket.TicketService
26
26
import org.fossasia.openevent.general.utils.HttpErrors
27
+ import retrofit2.HttpException
27
28
import timber.log.Timber
28
29
29
30
const val ORDER_STATUS_PENDING = " pending"
@@ -175,8 +176,9 @@ class AttendeeViewModel(
175
176
}, {
176
177
mutableProgress.value = false
177
178
if (createAttendeeIterations + 1 == totalAttendee)
178
- if (it.message.equals(HttpErrors .CONFLICT )) {
179
- mutableTicketSoldOut.value = true
179
+ if (it is HttpException ) {
180
+ if (it.code() == HttpErrors .CONFLICT )
181
+ mutableTicketSoldOut.value = true
180
182
} else {
181
183
mutableMessage.value = resource.getString(R .string.create_attendee_fail_message)
182
184
Timber .d(it, " Failed" )
Original file line number Diff line number Diff line change @@ -22,7 +22,9 @@ import org.fossasia.openevent.general.data.Resource
22
22
import org.fossasia.openevent.general.event.paging.EventsDataSourceFactory
23
23
import org.fossasia.openevent.general.notification.NotificationService
24
24
import org.fossasia.openevent.general.search.location.SAVED_LOCATION
25
+ import org.fossasia.openevent.general.utils.HttpErrors
25
26
import org.fossasia.openevent.general.utils.extensions.withDefaultSchedulers
27
+ import retrofit2.HttpException
26
28
import timber.log.Timber
27
29
28
30
const val NEW_NOTIFICATIONS = " newNotifications"
@@ -134,10 +136,28 @@ class EventsViewModel(
134
136
}
135
137
}
136
138
}, {
139
+ if (it is HttpException ) {
140
+ if (authHolder.isLoggedIn() && it.code() == HttpErrors .UNAUTHORIZED ) {
141
+ logoutAndRefresh()
142
+ }
143
+ }
137
144
Timber .e(it, " Error fetching notifications" )
138
145
})
139
146
}
140
147
148
+ private fun logoutAndRefresh () {
149
+ compositeDisposable + = authService.logout()
150
+ .withDefaultSchedulers()
151
+ .subscribe({
152
+ loadLocationEvents()
153
+ syncNotifications()
154
+ }, {
155
+ mutableProgress.value = false
156
+ Timber .e(it, " Error while logout" )
157
+ mutableMessage.value = resource.getString(R .string.error)
158
+ })
159
+ }
160
+
141
161
fun checkAndReset (token : String , newPassword : String ) {
142
162
val resetRequest = RequestPasswordReset (PasswordReset (token, newPassword))
143
163
if (authHolder.isLoggedIn()) {
Original file line number Diff line number Diff line change @@ -24,8 +24,8 @@ object AppLinkUtils {
24
24
}
25
25
26
26
fun handleIntent (intent : Intent ? , navController : NavController ) {
27
- val uri = intent?.data.toString()
28
- val data = getData(uri) ? : return
27
+ val uri = intent?.data ? : return
28
+ val data = getData(uri.toString() ) ? : return
29
29
val bundle = Bundle ()
30
30
bundle.putString(data.argumentKey, data.argumentValue)
31
31
navController.navigate(data.destinationId, bundle)
Original file line number Diff line number Diff line change 1
1
package org.fossasia.openevent.general.utils
2
2
3
3
object HttpErrors {
4
- const val CONFLICT = " HTTP 409 CONFLICT"
4
+ const val CONFLICT = 409
5
+ const val UNAUTHORIZED = 401
5
6
}
You can’t perform that action at this time.
0 commit comments