From 349be5b9c3b26ce01bdfe315930d719ff79f20bd Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Sat, 20 Jan 2024 23:13:54 +0700 Subject: [PATCH] Update todo.js --- .config/ags/services/todo.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.config/ags/services/todo.js b/.config/ags/services/todo.js index 4ea21075..377fd8c2 100644 --- a/.config/ags/services/todo.js +++ b/.config/ags/services/todo.js @@ -65,17 +65,17 @@ class TodoService extends Service { constructor() { super(); this._todoPath = `${GLib.get_user_cache_dir()}/ags/user/todo.json`; - if (!fileExists(this._todoPath)) { // No? create file with empty array + try { + const fileContents = Utils.readFile(this._todoPath); + this._todoJson = JSON.parse(fileContents); + } + catch { Utils.exec(`bash -c 'mkdir -p ${GLib.get_user_cache_dir()}/ags/user'`); Utils.exec(`touch ${this._todoPath}`); Utils.writeFile("[]", this._todoPath).then(() => { this._todoJson = JSON.parse(Utils.readFile(this._todoPath)) }).catch(print); } - else { - const fileContents = Utils.readFile(this._todoPath); - this._todoJson = JSON.parse(fileContents); - } } }