forked from github/szkolny
[Sync] Fix showing notifications. Implement notifications web push.
This commit is contained in:
parent
9978a11c52
commit
92e0fc2847
@ -337,6 +337,7 @@ open class Data(val app: App, val profile: Profile?, val loginStore: LoginStore)
|
||||
}
|
||||
try {
|
||||
DataNotifications(this)
|
||||
db.notificationDao().addAll(notifications)
|
||||
onSuccess()
|
||||
} catch (e: Exception) {
|
||||
error(ApiError(TAG, EXCEPTION_NOTIFY)
|
||||
|
@ -52,6 +52,7 @@ class SzkolnyApi(val app: App) {
|
||||
|
||||
fun getEvents(profiles: List<ProfileFull>): List<EventFull> {
|
||||
val teams = app.db.teamDao().allNow
|
||||
val notifications = app.db.notificationDao().getNotPostedNow()
|
||||
|
||||
val response = api.serverSync(ServerSyncRequest(
|
||||
deviceId = app.deviceId,
|
||||
@ -74,7 +75,8 @@ class SzkolnyApi(val app: App) {
|
||||
profile.loginStoreType,
|
||||
teams.filter { it.profileId == profile.id }.map { it.code }
|
||||
)
|
||||
}
|
||||
},
|
||||
notifications = notifications.map { ServerSyncRequest.Notification(it.profileName ?: "", it.type, it.text) }
|
||||
)).execute().body()
|
||||
|
||||
val events = mutableListOf<EventFull>()
|
||||
|
@ -10,7 +10,9 @@ data class ServerSyncRequest(
|
||||
val device: Device? = null,
|
||||
|
||||
val userCodes: List<String>,
|
||||
val users: List<User>? = null
|
||||
val users: List<User>? = null,
|
||||
|
||||
val notifications: List<Notification>? = null
|
||||
) {
|
||||
data class Device(
|
||||
val osType: String,
|
||||
@ -30,4 +32,10 @@ data class ServerSyncRequest(
|
||||
val loginType: Int,
|
||||
val teamCodes: List<String>
|
||||
)
|
||||
|
||||
data class Notification(
|
||||
val profileName: String,
|
||||
val type: Int,
|
||||
val text: String
|
||||
)
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class NotifyTask : IApiTask(-1) {
|
||||
|
||||
fun run(app: App, taskCallback: EdziennikCallback) {
|
||||
val list = app.db.notificationDao().getNotPostedNow()
|
||||
val notificationList = list.subList(0, min(15, list.size))
|
||||
val notificationList = list.subList(0, min(10, list.size))
|
||||
|
||||
var unreadCount = list.size
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user