Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.fossasia.openevent.general.order.OrderService
import org.fossasia.openevent.general.ticket.Ticket
import org.fossasia.openevent.general.ticket.TicketService
import org.fossasia.openevent.general.utils.HttpErrors
import retrofit2.HttpException
import timber.log.Timber

const val ORDER_STATUS_PENDING = "pending"
Expand Down Expand Up @@ -175,8 +176,9 @@ class AttendeeViewModel(
}, {
mutableProgress.value = false
if (createAttendeeIterations + 1 == totalAttendee)
if (it.message.equals(HttpErrors.CONFLICT)) {
mutableTicketSoldOut.value = true
if (it is HttpException) {
if (it.code() == HttpErrors.CONFLICT)
mutableTicketSoldOut.value = true
} else {
mutableMessage.value = resource.getString(R.string.create_attendee_fail_message)
Timber.d(it, "Failed")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import org.fossasia.openevent.general.data.Resource
import org.fossasia.openevent.general.event.paging.EventsDataSourceFactory
import org.fossasia.openevent.general.notification.NotificationService
import org.fossasia.openevent.general.search.location.SAVED_LOCATION
import org.fossasia.openevent.general.utils.HttpErrors
import org.fossasia.openevent.general.utils.extensions.withDefaultSchedulers
import retrofit2.HttpException
import timber.log.Timber

const val NEW_NOTIFICATIONS = "newNotifications"
Expand Down Expand Up @@ -134,10 +136,28 @@ class EventsViewModel(
}
}
}, {
if (it is HttpException) {
if (authHolder.isLoggedIn() && it.code() == HttpErrors.UNAUTHORIZED) {
logoutAndRefresh()
}
}
Timber.e(it, "Error fetching notifications")
})
}

private fun logoutAndRefresh() {
compositeDisposable += authService.logout()
.withDefaultSchedulers()
.subscribe({
loadLocationEvents()
syncNotifications()
}, {
mutableProgress.value = false
Timber.e(it, "Error while logout")
mutableMessage.value = resource.getString(R.string.error)
})
}

fun checkAndReset(token: String, newPassword: String) {
val resetRequest = RequestPasswordReset(PasswordReset(token, newPassword))
if (authHolder.isLoggedIn()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ object AppLinkUtils {
}

fun handleIntent(intent: Intent?, navController: NavController) {
val uri = intent?.data.toString()
val data = getData(uri) ?: return
val uri = intent?.data ?: return
val data = getData(uri.toString()) ?: return
val bundle = Bundle()
bundle.putString(data.argumentKey, data.argumentValue)
navController.navigate(data.destinationId, bundle)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.fossasia.openevent.general.utils

object HttpErrors {
const val CONFLICT = "HTTP 409 CONFLICT"
const val CONFLICT = 409
const val UNAUTHORIZED = 401
}