mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-09 23:15:38 -05:00
config refacotr: separate settings.json, session.json, appusage.json
This commit is contained in:
@@ -55,7 +55,7 @@ Singleton {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
root.userPreference = Prefs.networkPreference
|
||||
root.userPreference = SettingsData.networkPreference
|
||||
|
||||
if (root.networkStatus === "wifi" && root.wifiEnabled) {
|
||||
updateCurrentWifiInfo()
|
||||
@@ -402,7 +402,7 @@ Singleton {
|
||||
root.userPreference = preference
|
||||
root.changingPreference = true
|
||||
root.targetPreference = preference
|
||||
Prefs.setNetworkPreference(preference)
|
||||
SettingsData.setNetworkPreference(preference)
|
||||
|
||||
if (preference === "wifi") {
|
||||
// Set WiFi to low route metric (high priority), ethernet to high route metric (low priority)
|
||||
|
||||
@@ -57,7 +57,7 @@ Singleton {
|
||||
onNotification: notif => {
|
||||
notif.tracked = true;
|
||||
|
||||
const shouldShowPopup = !root.popupsDisabled && !Prefs.doNotDisturb;
|
||||
const shouldShowPopup = !root.popupsDisabled && !SessionData.doNotDisturb;
|
||||
const wrapper = notifComponent.createObject(root, {
|
||||
popup: shouldShowPopup,
|
||||
notification: notif
|
||||
@@ -226,7 +226,7 @@ Singleton {
|
||||
function processQueue() {
|
||||
if (addGateBusy) return;
|
||||
if (popupsDisabled) return;
|
||||
if (Prefs.doNotDisturb) return;
|
||||
if (SessionData.doNotDisturb) return;
|
||||
if (notificationQueue.length === 0) return;
|
||||
|
||||
const [next, ...rest] = notificationQueue;
|
||||
@@ -420,9 +420,9 @@ Singleton {
|
||||
|
||||
|
||||
Connections {
|
||||
target: Prefs
|
||||
target: SessionData
|
||||
function onDoNotDisturbChanged() {
|
||||
if (Prefs.doNotDisturb) {
|
||||
if (SessionData.doNotDisturb) {
|
||||
// Hide all current popups when DND is enabled
|
||||
for (const notif of visibleNotifications) {
|
||||
notif.popup = false;
|
||||
|
||||
@@ -149,8 +149,8 @@ Singleton {
|
||||
var shouldBeLightMode = (root.systemColorScheme === 2)
|
||||
if (Theme.isLightMode !== shouldBeLightMode) {
|
||||
Theme.isLightMode = shouldBeLightMode
|
||||
if (typeof Prefs !== "undefined") {
|
||||
Prefs.setLightMode(shouldBeLightMode)
|
||||
if (typeof SessionData !== "undefined") {
|
||||
SessionData.setLightMode(shouldBeLightMode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,13 +92,13 @@ Singleton {
|
||||
}
|
||||
|
||||
function getWeatherUrl() {
|
||||
if (Prefs.useAutoLocation) {
|
||||
if (SettingsData.useAutoLocation) {
|
||||
const url = "wttr.in/?format=j1"
|
||||
console.log("Using auto location, URL:", url)
|
||||
return url
|
||||
}
|
||||
|
||||
const location = Prefs.weatherCoordinates || "40.7128,-74.0060"
|
||||
const location = SettingsData.weatherCoordinates || "40.7128,-74.0060"
|
||||
const url = `wttr.in/${encodeURIComponent(location)}?format=j1`
|
||||
console.log("Using manual location:", location, "URL:", url)
|
||||
return url
|
||||
@@ -107,7 +107,7 @@ Singleton {
|
||||
function addRef() {
|
||||
refCount++;
|
||||
|
||||
if (refCount === 1 && !weather.available && Prefs.weatherEnabled) {
|
||||
if (refCount === 1 && !weather.available && SettingsData.weatherEnabled) {
|
||||
// Start fetching when first consumer appears and weather is enabled
|
||||
fetchWeather();
|
||||
}
|
||||
@@ -120,7 +120,7 @@ Singleton {
|
||||
|
||||
function fetchWeather() {
|
||||
// Only fetch if someone is consuming the data and weather is enabled
|
||||
if (root.refCount === 0 || !Prefs.weatherEnabled) {
|
||||
if (root.refCount === 0 || !SettingsData.weatherEnabled) {
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -246,7 +246,7 @@ Singleton {
|
||||
Timer {
|
||||
id: updateTimer
|
||||
interval: root.updateInterval
|
||||
running: root.refCount > 0 && !IdleService.isIdle && Prefs.weatherEnabled
|
||||
running: root.refCount > 0 && !IdleService.isIdle && SettingsData.weatherEnabled
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: {
|
||||
@@ -261,7 +261,7 @@ Singleton {
|
||||
console.log("WeatherService: System idle, pausing weather updates")
|
||||
} else {
|
||||
console.log("WeatherService: System active, resuming weather updates")
|
||||
if (root.refCount > 0 && !root.weather.available && Prefs.weatherEnabled) {
|
||||
if (root.refCount > 0 && !root.weather.available && SettingsData.weatherEnabled) {
|
||||
// Trigger immediate update when coming back from idle if no data and weather enabled
|
||||
root.fetchWeather()
|
||||
}
|
||||
@@ -291,7 +291,7 @@ Singleton {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
Prefs.weatherCoordinatesChanged.connect(() => {
|
||||
SettingsData.weatherCoordinatesChanged.connect(() => {
|
||||
console.log("Weather location changed, force refreshing weather")
|
||||
root.weather = {
|
||||
available: false,
|
||||
@@ -311,13 +311,13 @@ Singleton {
|
||||
root.forceRefresh()
|
||||
})
|
||||
|
||||
Prefs.weatherLocationChanged.connect(() => {
|
||||
SettingsData.weatherLocationChanged.connect(() => {
|
||||
console.log("Weather location display name changed")
|
||||
const currentWeather = Object.assign({}, root.weather)
|
||||
root.weather = currentWeather
|
||||
})
|
||||
|
||||
Prefs.useAutoLocationChanged.connect(() => {
|
||||
SettingsData.useAutoLocationChanged.connect(() => {
|
||||
console.log("Auto location setting changed, force refreshing weather")
|
||||
root.weather = {
|
||||
available: false,
|
||||
@@ -337,12 +337,12 @@ Singleton {
|
||||
root.forceRefresh()
|
||||
})
|
||||
|
||||
Prefs.weatherEnabledChanged.connect(() => {
|
||||
console.log("Weather enabled setting changed:", Prefs.weatherEnabled)
|
||||
if (Prefs.weatherEnabled && root.refCount > 0 && !root.weather.available) {
|
||||
SettingsData.weatherEnabledChanged.connect(() => {
|
||||
console.log("Weather enabled setting changed:", SettingsData.weatherEnabled)
|
||||
if (SettingsData.weatherEnabled && root.refCount > 0 && !root.weather.available) {
|
||||
// Start fetching when weather is re-enabled
|
||||
root.forceRefresh()
|
||||
} else if (!Prefs.weatherEnabled) {
|
||||
} else if (!SettingsData.weatherEnabled) {
|
||||
// Stop all timers when weather is disabled
|
||||
updateTimer.stop()
|
||||
retryTimer.stop()
|
||||
|
||||
Reference in New Issue
Block a user