summaryrefslogtreecommitdiff
path: root/src/services/math.ts
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-02-22 20:35:20 +1100
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-02-22 20:35:20 +1100
commit2d979684453659318daf794febafb0887a12fb50 (patch)
tree2fd8131c34bc59e50d001938fe29021732e520c8 /src/services/math.ts
parentnotifpopups: close all popups when notifs open (diff)
downloadcaelestia-shell-2d979684453659318daf794febafb0887a12fb50.tar.gz
caelestia-shell-2d979684453659318daf794febafb0887a12fb50.tar.bz2
caelestia-shell-2d979684453659318daf794febafb0887a12fb50.zip
config: dynamic service confs
Diffstat (limited to 'src/services/math.ts')
-rw-r--r--src/services/math.ts7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/services/math.ts b/src/services/math.ts
index 5c7dfce..f5807ef 100644
--- a/src/services/math.ts
+++ b/src/services/math.ts
@@ -17,7 +17,6 @@ export default class Math extends GObject.Object {
return this.instance;
}
- readonly #maxHistory = config.maxHistory;
readonly #path = `${STATE}/math-history.json`;
readonly #history: HistoryItem[] = [];
@@ -42,7 +41,7 @@ export default class Math extends GObject.Object {
// Try select first to prevent duplicates, if it fails, add it
if (!this.select(this.#lastExpression)) {
this.#history.unshift(this.#lastExpression);
- if (this.#history.length > this.#maxHistory) this.#history.pop();
+ while (this.#history.length > config.maxHistory.get()) this.#history.pop();
this.notify("history");
this.#save();
}
@@ -148,5 +147,9 @@ export default class Math extends GObject.Object {
console.error("Math - Unable to load history", e);
}
}
+
+ config.maxHistory.subscribe(n => {
+ while (this.#history.length > n) this.#history.pop();
+ });
}
}