Skip to content

Commit 2702c3d

Browse files
committed
fix(Plugins): make missing manifest properties optional
1 parent dec0de1 commit 2702c3d

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

app/src/main/kotlin/com/aliucord/manager/ui/screens/plugins/PluginsModel.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class PluginsModel(
164164
@Serializable
165165
data class SafeModeSettings(
166166
@SerialName("AC_aliucord_safe_mode_enabled")
167-
val safeMode: Boolean,
167+
val safeMode: Boolean = false,
168168
)
169169

170170
pluginsSafeMode.value = readAliucordSettings<SafeModeSettings>()?.safeMode ?: false
@@ -204,6 +204,7 @@ class PluginsModel(
204204
plugins.value = pluginItems.toUnsafeImmutable()
205205
}
206206

207+
// TODO: don't cause entire page to fail if one plugin is corrupted
207208
private fun loadPluginManifest(pluginFile: File): PluginManifest {
208209
return ZipReader(pluginFile).use {
209210
val manifest = it.openEntry("manifest.json")

app/src/main/kotlin/com/aliucord/manager/ui/screens/plugins/components/PluginCard.kt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,17 @@ fun PluginCard(
110110
Row(
111111
horizontalArrangement = Arrangement.spacedBy(10.dp)
112112
) {
113-
IconButton(
114-
onClick = { uriHandler.openUri(plugin.manifest.repositoryUrl) },
115-
modifier = Modifier.size(25.dp),
116-
) {
117-
Icon(
118-
modifier = Modifier.fillMaxSize(),
119-
painter = painterResource(R.drawable.ic_account_github_white_24dp),
120-
contentDescription = stringResource(R.string.github)
121-
)
113+
plugin.manifest.repositoryUrl?.let { repositoryUrl ->
114+
IconButton(
115+
onClick = { uriHandler.openUri(repositoryUrl) },
116+
modifier = Modifier.size(25.dp),
117+
) {
118+
Icon(
119+
modifier = Modifier.fillMaxSize(),
120+
painter = painterResource(R.drawable.ic_account_github_white_24dp),
121+
contentDescription = stringResource(R.string.github)
122+
)
123+
}
122124
}
123125

124126
if (plugin.manifest.changelog != null) {

app/src/main/kotlin/com/aliucord/manager/ui/screens/plugins/model/PluginManifest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ data class PluginManifest(
1313
val authors: ImmutableList<Author>,
1414
val description: String,
1515
val version: String,
16-
val updateUrl: String,
16+
val updateUrl: String?,
1717
val changelog: String?,
1818
val changelogMedia: String?,
1919
) {
20-
val repositoryUrl: String
21-
get() = updateUrl.replaceFirst(
20+
val repositoryUrl: String?
21+
get() = updateUrl?.replaceFirst(
2222
"https://(raw\\.githubusercontent\\.com|cdn\\.jsdelivr\\.net/gh)/([^/]+)/([^/@]+).*".toRegex(),
2323
"https://github.com/$2/$3"
2424
)

0 commit comments

Comments
 (0)