mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-13 16:40:01 +00:00
Automatically assign priority at first plugin load
This commit is contained in:
+8
-2
@@ -13,8 +13,14 @@ class DatabasePluginStatusProvider(
|
||||
var pluginManagement = pluginManagementRepository.findByIdOrNull(pluginId)
|
||||
|
||||
// If the plugin is unknown, persist it as enabled
|
||||
if(pluginManagement == null) {
|
||||
pluginManagement = pluginManagementRepository.save(PluginManagementEntry(pluginId = pluginId, enabled = true))
|
||||
if (pluginManagement == null) {
|
||||
|
||||
// Set priority to the max value of the current plugins + 1 (which is the lowest priority) or 1 if there are no entries
|
||||
val currentMaxPriority = pluginManagementRepository.findMaxPriority() ?: 0
|
||||
|
||||
pluginManagement = pluginManagementRepository.save(
|
||||
PluginManagementEntry(pluginId = pluginId, enabled = true, priority = currentMaxPriority + 1)
|
||||
)
|
||||
}
|
||||
|
||||
return pluginManagement.enabled != true
|
||||
|
||||
+5
-1
@@ -1,5 +1,9 @@
|
||||
package de.grimsi.gameyfin.core.plugins.management
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.data.jpa.repository.Query
|
||||
|
||||
interface PluginManagementRepository : JpaRepository<PluginManagementEntry, String>
|
||||
interface PluginManagementRepository : JpaRepository<PluginManagementEntry, String> {
|
||||
@Query("SELECT MAX(p.priority) FROM PluginManagementEntry p")
|
||||
fun findMaxPriority(): Int?
|
||||
}
|
||||
-5
@@ -87,11 +87,6 @@ class PluginManagementService(
|
||||
}
|
||||
}
|
||||
|
||||
fun hasLogo(pluginId: String): Boolean {
|
||||
val plugin = pluginManager.getPlugin(pluginId).plugin as GameyfinPlugin
|
||||
return plugin.hasLogo()
|
||||
}
|
||||
|
||||
fun getLogo(pluginId: String): InputStream? {
|
||||
val plugin = pluginManager.getPlugin(pluginId).plugin as GameyfinPlugin
|
||||
return plugin.getLogo()
|
||||
|
||||
Reference in New Issue
Block a user