fix: Multiple crashes

This commit is contained in:
ΞTΞRNAL
2025-10-09 14:03:57 +05:30
parent a25b66a385
commit d832ffcac4
6 changed files with 28 additions and 23 deletions

View File

@@ -259,7 +259,7 @@ class BridgeClient(
fun setAllScopeNotes(notes: Map<String, String>) = safeServiceCall { service.setAllScopeNotes(notes) }
fun getScriptingInterface(): IScripting = safeServiceCall { service.scriptingInterface }
fun getScriptingInterface(): IScripting? = safeServiceCall<IScripting?> { service.scriptingInterface }
fun getE2eeInterface(): E2eeInterface = safeServiceCall { service.e2eeInterface }

View File

@@ -63,7 +63,7 @@ class FriendNotes: Feature("Friend Notes") {
EditNoteTextField(
modifier = Modifier.padding(top = 8.dp),
primaryColor = primaryColor,
translation = context.translation,
placeholder = context.translation["features.friend_notes.placeholder"],
content = scopeNotes,
setContent = { scopeNotes = it }
)

View File

@@ -31,30 +31,32 @@ class CoreScriptRuntime(
}
modContext.bridgeClient.addOnConnectedCallback(initNow = true) {
scripting = modContext.bridgeClient.getScriptingInterface()
modContext.bridgeClient.getScriptingInterface()?.let { scriptingInterface ->
scripting = scriptingInterface
if (!isBridgeReloaded) {
scripting.enabledScripts.forEach { path ->
runCatching {
load(path, scripting.getScriptContent(path))
}.onFailure {
logger.error("Failed to load script $path", it)
if (!isBridgeReloaded) {
scriptingInterface.enabledScripts.forEach { path ->
runCatching {
load(path, scriptingInterface.getScriptContent(path))
}.onFailure {
logger.error("Failed to load script $path", it)
}
}
}
}
scripting.registerAutoReloadListener(object : AutoReloadListener.Stub() {
override fun restartApp() {
modContext.softRestartApp()
scriptingInterface.registerAutoReloadListener(object : AutoReloadListener.Stub() {
override fun restartApp() {
modContext.softRestartApp()
}
})
eachModule {
onBridgeConnected(reloaded = isBridgeReloaded)
}
})
eachModule {
onBridgeConnected(reloaded = isBridgeReloaded)
}
if (!isBridgeReloaded) {
isBridgeReloaded = true
if (!isBridgeReloaded) {
isBridgeReloaded = true
}
}
}
}