mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Finish and test NotificationIdProvider
This commit is contained in:
committed by
Benoit Marty
parent
42889973af
commit
d650a28904
+3
-5
@@ -16,12 +16,10 @@
|
||||
|
||||
package io.element.android.libraries.push.impl.notifications
|
||||
|
||||
import io.element.android.libraries.di.AppScope
|
||||
import io.element.android.libraries.di.SingleIn
|
||||
import io.element.android.libraries.matrix.api.core.SessionId
|
||||
import javax.inject.Inject
|
||||
import kotlin.math.abs
|
||||
|
||||
@SingleIn(AppScope::class)
|
||||
class NotificationIdProvider @Inject constructor() {
|
||||
fun getSummaryNotificationId(sessionId: SessionId): Int {
|
||||
return getOffset(sessionId) + SUMMARY_NOTIFICATION_ID
|
||||
@@ -40,8 +38,8 @@ class NotificationIdProvider @Inject constructor() {
|
||||
}
|
||||
|
||||
private fun getOffset(sessionId: SessionId): Int {
|
||||
// TODO EAx multi account: return different value for users and persist data
|
||||
return 0
|
||||
// Compute a int from a string with a low risk of collision.
|
||||
return abs(sessionId.value.hashCode() % 100_000) * 10
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
Reference in New Issue
Block a user