Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Commit 6b93ab4

Browse files
committed
Fix LocalItem
1 parent 5952f77 commit 6b93ab4

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

app/src/main/kotlin/com/sanmer/mrepo/ui/screens/repository/view/pages/OverviewPage.kt

+9-7
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import com.sanmer.mrepo.utils.extensions.toDateTime
3737
fun OverviewPage(
3838
online: OnlineModule,
3939
item: VersionItem?,
40-
local: LocalModule,
40+
local: LocalModule?,
4141
isProviderAlive: Boolean,
4242
notifyUpdates: Boolean,
4343
setUpdatesTag: (Boolean) -> Unit,
@@ -78,13 +78,15 @@ fun OverviewPage(
7878
HorizontalDivider(thickness = 0.9.dp)
7979
}
8080

81-
LocalItem(
82-
local = local,
83-
notifyUpdates = notifyUpdates,
84-
setUpdatesTag = setUpdatesTag
85-
)
81+
if (local != null) {
82+
LocalItem(
83+
local = local,
84+
notifyUpdates = notifyUpdates,
85+
setUpdatesTag = setUpdatesTag
86+
)
8687

87-
HorizontalDivider(thickness = 0.9.dp)
88+
HorizontalDivider(thickness = 0.9.dp)
89+
}
8890
}
8991

9092
@Composable

app/src/main/kotlin/com/sanmer/mrepo/viewmodel/ModuleViewModel.kt

+5-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import com.sanmer.mrepo.database.entity.Repo
1515
import com.sanmer.mrepo.database.entity.toRepo
1616
import com.sanmer.mrepo.model.json.UpdateJson
1717
import com.sanmer.mrepo.model.local.LocalModule
18-
import com.sanmer.mrepo.model.local.example
1918
import com.sanmer.mrepo.model.online.OnlineModule
2019
import com.sanmer.mrepo.model.online.TrackJson
2120
import com.sanmer.mrepo.model.online.VersionItem
@@ -51,15 +50,15 @@ class ModuleViewModel @Inject constructor(
5150
&& online.track.source.isBlank()
5251
&& online.track.support.isBlank()
5352

54-
var local by mutableStateOf(LocalModule.example())
53+
var local: LocalModule? by mutableStateOf(null)
5554
private set
5655

57-
private val installed get() = local.id == online.id
58-
&& local.author == online.author
56+
private val installed get() = local?.let { it.author == online.author } ?: false
5957
var notifyUpdates by mutableStateOf(false)
6058
private set
6159

62-
val localVersionCode get() = if (notifyUpdates) local.versionCode else Int.MAX_VALUE
60+
val localVersionCode get() =
61+
if (notifyUpdates && installed) local!!.versionCode else Int.MAX_VALUE
6362
val updatableSize by derivedStateOf {
6463
versions.count { it.second.versionCode > localVersionCode }
6564
}
@@ -96,7 +95,7 @@ class ModuleViewModel @Inject constructor(
9695
}
9796

9897
if (installed) {
99-
UpdateJson.loadToVersionItem(local.updateJson)?.let {
98+
UpdateJson.loadToVersionItem(local!!.updateJson)?.let {
10099
versions.add(0, "Update Json".toRepo() to it)
101100
}
102101
}

0 commit comments

Comments
 (0)