fix: Multiple crashes
This commit is contained in:
@@ -162,7 +162,7 @@ class ManageScope: Routes.Route() {
|
||||
EditNoteTextField(
|
||||
modifier = Modifier.padding(8.dp),
|
||||
primaryColor = Color.White,
|
||||
translation = context.translation,
|
||||
placeholder = context.translation["manager.sections.manage_scope.notes_placeholder"],
|
||||
content = scopeNotes,
|
||||
setContent = { scopeNotes = it }
|
||||
)
|
||||
|
||||
@@ -354,6 +354,9 @@
|
||||
},
|
||||
|
||||
"features": {
|
||||
"friend_notes": {
|
||||
"placeholder": "Click to add a note"
|
||||
},
|
||||
"notices": {
|
||||
"unstable": "\u26A0 Unstable",
|
||||
"ban_risk": "\u26A0 This feature may cause bans",
|
||||
|
||||
@@ -26,7 +26,7 @@ import me.rhunk.snapenhance.common.bridge.wrapper.LocaleWrapper
|
||||
fun EditNoteTextField(
|
||||
modifier: Modifier = Modifier,
|
||||
primaryColor: Color,
|
||||
translation: LocaleWrapper,
|
||||
placeholder: String,
|
||||
content: String?,
|
||||
setContent: (String) -> Unit
|
||||
) {
|
||||
@@ -49,7 +49,7 @@ fun EditNoteTextField(
|
||||
},
|
||||
shape = MaterialTheme.shapes.medium,
|
||||
textStyle = LocalTextStyle.current.copy(fontSize = 12.sp, color = primaryColor),
|
||||
placeholder = { Text(text = translation["manager.sections.manage_scope.notes_placeholder"], fontSize = 12.sp) }
|
||||
placeholder = { Text(text = placeholder, fontSize = 12.sp) }
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -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