From 5f76e68a735dab2b8414cc167e95b80be76bd5cc Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Sat, 25 May 2024 21:34:47 +0700 Subject: [PATCH] move image-related user options + update reminder --- .../modules/.configuration/user_options.js | 21 +++++++++++++++---- .config/ags/modules/sideleft/apis/booru.js | 6 ++++-- .config/ags/services/booru.js | 4 ++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.config/ags/modules/.configuration/user_options.js b/.config/ags/modules/.configuration/user_options.js index 6730feb1..090dca36 100644 --- a/.config/ags/modules/.configuration/user_options.js +++ b/.config/ags/modules/.configuration/user_options.js @@ -1,3 +1,5 @@ +import GLib from 'gi://GLib'; +import * as Utils from 'resource:///com/github/Aylur/ags/utils.js' import userOverrides from '../../user_options.js'; // Default options. @@ -72,9 +74,11 @@ let configOptions = { 'wsNumMarginScale': 0.07, }, 'sidebar': { - 'imageColumns': 2, - 'imageBooruCount': 20, - 'imageAllowNsfw': false, + 'image': { + 'columns': 2, + 'batchCount': 20, + 'allowNsfw': false, + }, }, 'search': { 'engineBaseUrl': "https://www.google.com/search?q=", @@ -173,9 +177,11 @@ let configOptions = { } // Override defaults with user's options +let optionsOkay = true; function overrideConfigRecursive(userOverrides, configOptions = {}) { for (const [key, value] of Object.entries(userOverrides)) { - if (typeof value === 'object') { + if (!configOptions[key]) optionsOkay = false; + else if (typeof value === 'object') { overrideConfigRecursive(value, configOptions[key]); } else { configOptions[key] = value; @@ -183,6 +189,13 @@ function overrideConfigRecursive(userOverrides, configOptions = {}) { } } overrideConfigRecursive(userOverrides, configOptions); +if (!optionsOkay) { + Utils.execAsync(['notify-send', + 'Update your user options', + 'One or more config options don\'t exist', + '-a', 'ags', + ]).catch(print); +} globalThis['userOptions'] = configOptions; export default configOptions; diff --git a/.config/ags/modules/sideleft/apis/booru.js b/.config/ags/modules/sideleft/apis/booru.js index 55233abf..308abba9 100644 --- a/.config/ags/modules/sideleft/apis/booru.js +++ b/.config/ags/modules/sideleft/apis/booru.js @@ -98,7 +98,9 @@ export const BooruSettings = () => MarginRevealer({ name: 'Lewds', desc: `Shows naughty stuff when enabled.\nYa like those? Add this to user_options.js: 'sidebar': { - 'imageAllowNsfw': true, + 'image': { + 'allowNsfw': true, + } },`, initValue: BooruService.nsfw, onChange: (self, newValue) => { @@ -312,7 +314,7 @@ const BooruPage = (taglist, serviceName = 'Booru') => { downloadState.shown = 'error'; return; } - const imageColumns = userOptions.sidebar.imageColumns; + const imageColumns = userOptions.sidebar.image.columns; const imageRows = data.length / imageColumns; // Init cols diff --git a/.config/ags/services/booru.js b/.config/ags/services/booru.js index 95417040..22bbe52e 100644 --- a/.config/ags/services/booru.js +++ b/.config/ags/services/booru.js @@ -38,7 +38,7 @@ function paramStringFromObj(params) { class BooruService extends Service { _baseUrl = 'https://yande.re/post.json'; _mode = 'yandere'; - _nsfw = userOptions.sidebar.imageAllowNsfw; + _nsfw = userOptions.sidebar.image.allowNsfw; _responses = []; _queries = []; @@ -102,7 +102,7 @@ class BooruService extends Service { const params = { 'tags': taglist.join('+'), 'page': `${page}`, - 'limit': `${userOptions.sidebar.imageBooruCount}`, + 'limit': `${userOptions.sidebar.image.batchCount}`, }; const paramString = paramStringFromObj(params); // Fetch