fix: Multiple crashes
This commit is contained in:
@@ -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 }
|
||||
|
||||
|
||||
@@ -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 }
|
||||
)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user