mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
More fixes to auto extension installer
brainrot Longer commit message: this is starting to look like spaghet and its causing me brainrot
This commit is contained in:
parent
f8cfe1bc31
commit
928f7553bf
1 changed files with 7 additions and 2 deletions
|
@ -49,7 +49,7 @@ class ExtensionInstallService(
|
||||||
|
|
||||||
private val preferences: PreferencesHelper = Injekt.get()
|
private val preferences: PreferencesHelper = Injekt.get()
|
||||||
|
|
||||||
private var activeInstalls = listOf<String>()
|
private var activeInstalls = mutableListOf<String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method needs to be implemented, but it's not used/needed.
|
* This method needs to be implemented, but it's not used/needed.
|
||||||
|
@ -88,7 +88,7 @@ class ExtensionInstallService(
|
||||||
}
|
}
|
||||||
?: return START_NOT_STICKY
|
?: return START_NOT_STICKY
|
||||||
|
|
||||||
activeInstalls = list.map { it.pkgName }
|
activeInstalls = list.map { it.pkgName }.toMutableList()
|
||||||
serviceScope.launch {
|
serviceScope.launch {
|
||||||
list.forEach { extensionManager.setPending(it.pkgName) }
|
list.forEach { extensionManager.setPending(it.pkgName) }
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,7 @@ class ExtensionInstallService(
|
||||||
extensionManager.installExtension(extension, serviceScope)
|
extensionManager.installExtension(extension, serviceScope)
|
||||||
.collect {
|
.collect {
|
||||||
if (it.first.isCompleted()) {
|
if (it.first.isCompleted()) {
|
||||||
|
activeInstalls.remove(extension.pkgName)
|
||||||
installedExtensions.add(extension)
|
installedExtensions.add(extension)
|
||||||
installed++
|
installed++
|
||||||
val prefCount =
|
val prefCount =
|
||||||
|
@ -108,6 +109,9 @@ class ExtensionInstallService(
|
||||||
preferences.extensionUpdatesCount().set(max(prefCount - 1, 0))
|
preferences.extensionUpdatesCount().set(max(prefCount - 1, 0))
|
||||||
}
|
}
|
||||||
notifier.showProgressNotification(installed, list.size)
|
notifier.showProgressNotification(installed, list.size)
|
||||||
|
if (activeInstalls.isEmpty()) {
|
||||||
|
job?.cancel()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,6 +155,7 @@ class ExtensionInstallService(
|
||||||
job?.cancel()
|
job?.cancel()
|
||||||
serviceScope.cancel()
|
serviceScope.cancel()
|
||||||
activeInstalls.forEach { extensionManager.cleanUpInstallation(it) }
|
activeInstalls.forEach { extensionManager.cleanUpInstallation(it) }
|
||||||
|
activeInstalls.clear()
|
||||||
extensionManager.downloadRelay.tryEmit("Finished" to (InstallStep.Installed to null))
|
extensionManager.downloadRelay.tryEmit("Finished" to (InstallStep.Installed to null))
|
||||||
if (instance == this) {
|
if (instance == this) {
|
||||||
instance = null
|
instance = null
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue