Group plugins by package

This commit is contained in:
MM20
2023-11-25 16:29:20 +01:00
parent 6c311fc947
commit 25cd9b707e
17 changed files with 728 additions and 101 deletions
@@ -36,6 +36,9 @@ interface PluginDao {
@Update
suspend fun update(plugin: PluginEntity)
@Update
suspend fun updateMany(plugins: List<PluginEntity>)
@Query("DELETE FROM Plugins")
suspend fun deleteMany()
}
@@ -360,6 +360,7 @@ internal class PluginFileDeserializer(
val authority = obj.getString("authority")
val id = obj.getString("id")
val plugin = pluginRepository.get(authority).firstOrNull() ?: return null
if (!plugin.enabled) return null
val provider = PluginFileProvider(context, plugin)
return provider.getFile(id)
} catch (e: Exception) {
@@ -52,6 +52,14 @@ internal class PluginRepositoryImpl(
}
}
override fun updateMany(plugins: List<Plugin>): Job {
return scope.launch {
dao.updateMany(
plugins.map { PluginEntity(it) }
)
}
}
override fun deleteMany(): Job {
return scope.launch {
dao.deleteMany()