From 30733f65021874dc14bf735411159f8b584af71c Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Wed, 31 Dec 2025 18:17:47 +0100 Subject: [PATCH] Migration: clear recently used emojis --- Commons/Migrations/Migration36.qml | 29 ++++++++++++++++++++++++ Commons/Migrations/MigrationRegistry.qml | 4 +++- Commons/Settings.qml | 2 +- 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 Commons/Migrations/Migration36.qml diff --git a/Commons/Migrations/Migration36.qml b/Commons/Migrations/Migration36.qml new file mode 100644 index 000000000..563b2c7a3 --- /dev/null +++ b/Commons/Migrations/Migration36.qml @@ -0,0 +1,29 @@ +import QtQuick +import Quickshell +import qs.Commons + +QtObject { + id: root + + // Clear legacy emoji usage cache to adopt new format + function migrate(adapter, logger, rawJson) { + logger.i("Settings", "Migrating settings to v36"); + + const usagePath = Settings.cacheDir + "emoji_usage.json"; + + if (!usagePath.endsWith("emoji_usage.json")) { + logger.w("Settings", "Skipping emoji usage cleanup due to unexpected path: " + usagePath); + return true; + } + + try { + // Ensure dir exists then remove the file + Quickshell.execDetached(["sh", "-c", `mkdir -p "${Settings.cacheDir}" && rm -f -- "${usagePath}"`]); + logger.i("Settings", "Cleared legacy emoji usage file at: " + usagePath); + } catch (e) { + logger.w("Settings", "Failed to clear emoji usage cache: " + e); + } + + return true; + } +} diff --git a/Commons/Migrations/MigrationRegistry.qml b/Commons/Migrations/MigrationRegistry.qml index 48b08220b..c2cc16c56 100644 --- a/Commons/Migrations/MigrationRegistry.qml +++ b/Commons/Migrations/MigrationRegistry.qml @@ -11,7 +11,8 @@ QtObject { 28: migration28Component, 32: migration32Component, 33: migration33Component, - 35: migration35Component + 35: migration35Component, + 36: migration36Component }) // Migration components @@ -20,4 +21,5 @@ QtObject { property Component migration32Component: Migration32 {} property Component migration33Component: Migration33 {} property Component migration35Component: Migration35 {} + property Component migration36Component: Migration36 {} } diff --git a/Commons/Settings.qml b/Commons/Settings.qml index 3dceb1f12..d02f97031 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -25,7 +25,7 @@ Singleton { - Default cache directory: ~/.cache/noctalia */ readonly property alias data: adapter // Used to access via Settings.data.xxx.yyy - readonly property int settingsVersion: 35 + readonly property int settingsVersion: 36 readonly property bool isDebug: Quickshell.env("NOCTALIA_DEBUG") === "1" readonly property string shellName: "noctalia" readonly property string configDir: Quickshell.env("NOCTALIA_CONFIG_DIR") || (Quickshell.env("XDG_CONFIG_HOME") || Quickshell.env("HOME") + "/.config") + "/" + shellName + "/"