mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-31 22:10:18 +02:00
fix(core): sync remote in background
This commit is contained in:
parent
eb3ea2675b
commit
5563418d79
@ -114,7 +114,9 @@ class SnapEnhance {
|
|||||||
appContext.isMainActivityPaused = false
|
appContext.isMainActivityPaused = false
|
||||||
}) {
|
}) {
|
||||||
appContext.reloadConfig()
|
appContext.reloadConfig()
|
||||||
syncRemote()
|
appContext.executeAsync {
|
||||||
|
syncRemote()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,6 +136,11 @@ class SnapEnhance {
|
|||||||
initWidgetListener()
|
initWidgetListener()
|
||||||
initNative()
|
initNative()
|
||||||
scope.launch(Dispatchers.IO) {
|
scope.launch(Dispatchers.IO) {
|
||||||
|
runCatching {
|
||||||
|
syncRemote()
|
||||||
|
}.onFailure {
|
||||||
|
log.error("Failed to sync remote", it)
|
||||||
|
}
|
||||||
translation.userLocale = getConfigLocale()
|
translation.userLocale = getConfigLocale()
|
||||||
translation.loadFromCallback { locale ->
|
translation.loadFromCallback { locale ->
|
||||||
bridgeClient.fetchLocales(locale)
|
bridgeClient.fetchLocales(locale)
|
||||||
@ -257,37 +264,35 @@ class SnapEnhance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun syncRemote() {
|
private fun syncRemote() {
|
||||||
appContext.executeAsync {
|
appContext.bridgeClient.sync(object : SyncCallback.Stub() {
|
||||||
bridgeClient.sync(object : SyncCallback.Stub() {
|
override fun syncFriend(uuid: String): String? {
|
||||||
override fun syncFriend(uuid: String): String? {
|
return appContext.database.getFriendInfo(uuid)?.let {
|
||||||
return database.getFriendInfo(uuid)?.let {
|
MessagingFriendInfo(
|
||||||
MessagingFriendInfo(
|
userId = it.userId!!,
|
||||||
userId = it.userId!!,
|
displayName = it.displayName,
|
||||||
displayName = it.displayName,
|
mutableUsername = it.mutableUsername!!,
|
||||||
mutableUsername = it.mutableUsername!!,
|
bitmojiId = it.bitmojiAvatarId,
|
||||||
bitmojiId = it.bitmojiAvatarId,
|
selfieId = it.bitmojiSelfieId,
|
||||||
selfieId = it.bitmojiSelfieId,
|
streaks = if (it.streakLength > 0) {
|
||||||
streaks = if (it.streakLength > 0) {
|
FriendStreaks(
|
||||||
FriendStreaks(
|
expirationTimestamp = it.streakExpirationTimestamp,
|
||||||
expirationTimestamp = it.streakExpirationTimestamp,
|
length = it.streakLength
|
||||||
length = it.streakLength
|
)
|
||||||
)
|
} else null
|
||||||
} else null
|
).toSerialized()
|
||||||
).toSerialized()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun syncGroup(uuid: String): String? {
|
override fun syncGroup(uuid: String): String? {
|
||||||
return database.getFeedEntryByConversationId(uuid)?.let {
|
return appContext.database.getFeedEntryByConversationId(uuid)?.let {
|
||||||
MessagingGroupInfo(
|
MessagingGroupInfo(
|
||||||
it.key!!,
|
it.key!!,
|
||||||
it.feedDisplayName!!,
|
it.feedDisplayName!!,
|
||||||
it.participantsSize
|
it.participantsSize
|
||||||
).toSerialized()
|
).toSerialized()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun jetpackComposeResourceHook() {
|
private fun jetpackComposeResourceHook() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user