diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/ui/manager/pages/social/ManageScope.kt b/app/src/main/kotlin/me/rhunk/snapenhance/ui/manager/pages/social/ManageScope.kt index 1f14a894..da9efadd 100644 --- a/app/src/main/kotlin/me/rhunk/snapenhance/ui/manager/pages/social/ManageScope.kt +++ b/app/src/main/kotlin/me/rhunk/snapenhance/ui/manager/pages/social/ManageScope.kt @@ -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 } ) diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json index 503408b0..aa858a77 100644 --- a/common/src/main/assets/lang/en_US.json +++ b/common/src/main/assets/lang/en_US.json @@ -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", diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/ui/Components.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/ui/Components.kt index 7ec8cdc6..962d9054 100644 --- a/common/src/main/kotlin/me/rhunk/snapenhance/common/ui/Components.kt +++ b/common/src/main/kotlin/me/rhunk/snapenhance/common/ui/Components.kt @@ -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) } ) } diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/bridge/BridgeClient.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/bridge/BridgeClient.kt index 7ac442d2..6a325a9a 100644 --- a/core/src/main/kotlin/me/rhunk/snapenhance/core/bridge/BridgeClient.kt +++ b/core/src/main/kotlin/me/rhunk/snapenhance/core/bridge/BridgeClient.kt @@ -259,7 +259,7 @@ class BridgeClient( fun setAllScopeNotes(notes: Map) = safeServiceCall { service.setAllScopeNotes(notes) } - fun getScriptingInterface(): IScripting = safeServiceCall { service.scriptingInterface } + fun getScriptingInterface(): IScripting? = safeServiceCall { service.scriptingInterface } fun getE2eeInterface(): E2eeInterface = safeServiceCall { service.e2eeInterface } diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/ui/FriendNotes.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/ui/FriendNotes.kt index 1c2fdeaf..ae9871ee 100644 --- a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/ui/FriendNotes.kt +++ b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/ui/FriendNotes.kt @@ -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 } ) diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/scripting/CoreScriptRuntime.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/scripting/CoreScriptRuntime.kt index dc0f5921..0a7509eb 100644 --- a/core/src/main/kotlin/me/rhunk/snapenhance/core/scripting/CoreScriptRuntime.kt +++ b/core/src/main/kotlin/me/rhunk/snapenhance/core/scripting/CoreScriptRuntime.kt @@ -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 + } } } }