mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-02 23:44:29 +02:00
fix(core): remote sync
This commit is contained in:
parent
546aa00c74
commit
54d3010970
@ -131,6 +131,7 @@ class SnapEnhance {
|
|||||||
reloadConfig()
|
reloadConfig()
|
||||||
actionManager.init()
|
actionManager.init()
|
||||||
initConfigListener()
|
initConfigListener()
|
||||||
|
initWidgetListener()
|
||||||
initNative()
|
initNative()
|
||||||
scope.launch(Dispatchers.IO) {
|
scope.launch(Dispatchers.IO) {
|
||||||
translation.userLocale = getConfigLocale()
|
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() {
|
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(
|
val responseUnaryCallEvent = UnaryCallEvent(
|
||||||
uri = uri,
|
uri = uri,
|
||||||
buffer = array
|
buffer = array
|
||||||
)
|
).also { it.context = context}
|
||||||
|
|
||||||
event.callbacks.forEach { callback ->
|
event.callbacks.forEach { callback ->
|
||||||
callback(responseUnaryCallEvent)
|
callback(responseUnaryCallEvent)
|
||||||
@ -215,7 +215,7 @@ class EventDispatcher(
|
|||||||
return@ephemeralHookObjectMethod
|
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