Skip to content

Commit 3314b78

Browse files
Added plugin installation check and default settings initialization
1 parent 0293853 commit 3314b78

3 files changed

Lines changed: 40 additions & 0 deletions

File tree

components/home/HomeRows.bs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "pkg:/source/api/MoonfinPlugin.bs"
12
import "pkg:/source/constants/HomeRowItemSizes.bs"
23
import "pkg:/source/enums/KeyCode.bs"
34
import "pkg:/source/enums/TaskControl.bs"
@@ -204,6 +205,15 @@ function isKtEnabled() as boolean
204205
return normalizeBooleanValue(get_user_setting("plugin.kefintweaks.enabled"), false)
205206
end function
206207

208+
function isPluginFeatureOptedOut(settingName as string) as boolean
209+
settingValue = get_user_setting(settingName)
210+
if not isValid(settingValue)
211+
return false
212+
end if
213+
214+
return not normalizeBooleanValue(settingValue, false)
215+
end function
216+
207217
function loadCachedHssProbeState() as boolean
208218
m.hssSections = []
209219
m.hssSuppressedBuiltins = {}
@@ -724,6 +734,14 @@ function shouldLoadHss() as boolean
724734
end if
725735
end if
726736

737+
if isPluginFeatureOptedOut("plugin.enabled") or isPluginFeatureOptedOut("plugin.hss.enabled")
738+
return false
739+
end if
740+
741+
if moonfinPlugin.IsPluginInstalled()
742+
return true
743+
end if
744+
727745
if not isHssEnabled()
728746
return false
729747
end if
@@ -746,6 +764,14 @@ function shouldLoadKt() as boolean
746764
end if
747765
end if
748766

767+
if isPluginFeatureOptedOut("plugin.enabled") or isPluginFeatureOptedOut("plugin.kefintweaks.enabled")
768+
return false
769+
end if
770+
771+
if moonfinPlugin.IsPluginInstalled()
772+
return true
773+
end if
774+
749775
if not isKtEnabled()
750776
return false
751777
end if

source/api/MoonfinPlugin.bs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ namespace moonfinPlugin
165165
return moonfinPlugin.ParseBoolSetting(chainLookupReturn(m.global.session, "user.settings.`plugin.enabled`", false), false)
166166
end function
167167

168+
function IsPluginInstalled() as boolean
169+
pluginInfo = m.global.session.pluginInfo
170+
if not isValid(pluginInfo) then return false
171+
return pluginInfo.installed = true
172+
end function
173+
168174
function IsRatingsEnabled() as boolean
169175
if not moonfinPlugin.IsEnabled() then return false
170176
return moonfinPlugin.ParseBoolSetting(chainLookupReturn(m.global.session, "user.settings.`plugin.mdblist.enabled`", true), true)

source/utils/session.bs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,14 @@ namespace session
240240
defaultSettings: result.defaultSettings ?? invalid
241241
}
242242

243+
if not isValid(get_user_setting("plugin.enabled"))
244+
set_user_setting("plugin.enabled", "true")
245+
end if
246+
247+
if toBoolean(pluginInfo.jellyseerrEnabled) = true and not isValid(get_user_setting("jellyseerr.enabled"))
248+
set_user_setting("jellyseerr.enabled", "true")
249+
end if
250+
243251
end if
244252

245253
tmpSession = m.global.session

0 commit comments

Comments
 (0)