mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-02 07:34:25 +02:00
fix(core): remote sync
This commit is contained in:
parent
546aa00c74
commit
54d3010970
@ -131,6 +131,7 @@ class SnapEnhance {
|
||||
reloadConfig()
|
||||
actionManager.init()
|
||||
initConfigListener()
|
||||
initWidgetListener()
|
||||
initNative()
|
||||
scope.launch(Dispatchers.IO) {
|
||||
translation.userLocale = getConfigLocale()
|
||||
@ -224,7 +225,35 @@ class SnapEnhance {
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private fun initWidgetListener() {
|
||||
appContext.event.subscribe(SnapWidgetBroadcastReceiveEvent::class) { event ->
|
||||
if (event.action != ReceiversConfig.BRIDGE_SYNC_ACTION) return@subscribe
|
||||
event.canceled = true
|
||||
val feedEntries = appContext.database.getFeedEntries(Int.MAX_VALUE)
|
||||
|
||||
val groups = feedEntries.filter { it.friendUserId == null }.map {
|
||||
MessagingGroupInfo(
|
||||
it.key!!,
|
||||
it.feedDisplayName!!,
|
||||
it.participantsSize
|
||||
)
|
||||
}
|
||||
|
||||
val friends = feedEntries.filter { it.friendUserId != null }.map {
|
||||
MessagingFriendInfo(
|
||||
it.friendUserId!!,
|
||||
it.friendDisplayName,
|
||||
it.friendDisplayUsername!!.split("|")[1],
|
||||
it.bitmojiAvatarId,
|
||||
it.bitmojiSelfieId,
|
||||
streaks = null
|
||||
)
|
||||
}
|
||||
|
||||
appContext.bridgeClient.passGroupsAndFriends(groups, friends)
|
||||
}
|
||||
}
|
||||
|
||||
private fun syncRemote() {
|
||||
@ -258,33 +287,6 @@ class SnapEnhance {
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
event.subscribe(SnapWidgetBroadcastReceiveEvent::class) { event ->
|
||||
if (event.action != ReceiversConfig.BRIDGE_SYNC_ACTION) return@subscribe
|
||||
event.canceled = true
|
||||
val feedEntries = appContext.database.getFeedEntries(Int.MAX_VALUE)
|
||||
|
||||
val groups = feedEntries.filter { it.friendUserId == null }.map {
|
||||
MessagingGroupInfo(
|
||||
it.key!!,
|
||||
it.feedDisplayName!!,
|
||||
it.participantsSize
|
||||
)
|
||||
}
|
||||
|
||||
val friends = feedEntries.filter { it.friendUserId != null }.map {
|
||||
MessagingFriendInfo(
|
||||
it.friendUserId!!,
|
||||
it.friendDisplayName,
|
||||
it.friendDisplayUsername!!.split("|")[1],
|
||||
it.bitmojiAvatarId,
|
||||
it.bitmojiSelfieId,
|
||||
streaks = null
|
||||
)
|
||||
}
|
||||
|
||||
bridgeClient.passGroupsAndFriends(groups, friends)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ class EventDispatcher(
|
||||
val responseUnaryCallEvent = UnaryCallEvent(
|
||||
uri = uri,
|
||||
buffer = array
|
||||
)
|
||||
).also { it.context = context}
|
||||
|
||||
event.callbacks.forEach { callback ->
|
||||
callback(responseUnaryCallEvent)
|
||||
@ -215,7 +215,7 @@ class EventDispatcher(
|
||||
return@ephemeralHookObjectMethod
|
||||
}
|
||||
|
||||
methodParam.setArg(0, ByteBuffer.wrap(event.buffer))
|
||||
methodParam.setArg(0, ByteBuffer.wrap(responseUnaryCallEvent.buffer))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user