forked from Shinonome/dots-hyprland
move image-related user options + update reminder
This commit is contained in:
@@ -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';
|
import userOverrides from '../../user_options.js';
|
||||||
|
|
||||||
// Default options.
|
// Default options.
|
||||||
@@ -72,9 +74,11 @@ let configOptions = {
|
|||||||
'wsNumMarginScale': 0.07,
|
'wsNumMarginScale': 0.07,
|
||||||
},
|
},
|
||||||
'sidebar': {
|
'sidebar': {
|
||||||
'imageColumns': 2,
|
'image': {
|
||||||
'imageBooruCount': 20,
|
'columns': 2,
|
||||||
'imageAllowNsfw': false,
|
'batchCount': 20,
|
||||||
|
'allowNsfw': false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
'search': {
|
'search': {
|
||||||
'engineBaseUrl': "https://www.google.com/search?q=",
|
'engineBaseUrl': "https://www.google.com/search?q=",
|
||||||
@@ -173,9 +177,11 @@ let configOptions = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Override defaults with user's options
|
// Override defaults with user's options
|
||||||
|
let optionsOkay = true;
|
||||||
function overrideConfigRecursive(userOverrides, configOptions = {}) {
|
function overrideConfigRecursive(userOverrides, configOptions = {}) {
|
||||||
for (const [key, value] of Object.entries(userOverrides)) {
|
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]);
|
overrideConfigRecursive(value, configOptions[key]);
|
||||||
} else {
|
} else {
|
||||||
configOptions[key] = value;
|
configOptions[key] = value;
|
||||||
@@ -183,6 +189,13 @@ function overrideConfigRecursive(userOverrides, configOptions = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
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;
|
globalThis['userOptions'] = configOptions;
|
||||||
export default configOptions;
|
export default configOptions;
|
||||||
|
|||||||
@@ -98,7 +98,9 @@ export const BooruSettings = () => MarginRevealer({
|
|||||||
name: 'Lewds',
|
name: 'Lewds',
|
||||||
desc: `Shows naughty stuff when enabled.\nYa like those? Add this to user_options.js:
|
desc: `Shows naughty stuff when enabled.\nYa like those? Add this to user_options.js:
|
||||||
'sidebar': {
|
'sidebar': {
|
||||||
'imageAllowNsfw': true,
|
'image': {
|
||||||
|
'allowNsfw': true,
|
||||||
|
}
|
||||||
},`,
|
},`,
|
||||||
initValue: BooruService.nsfw,
|
initValue: BooruService.nsfw,
|
||||||
onChange: (self, newValue) => {
|
onChange: (self, newValue) => {
|
||||||
@@ -312,7 +314,7 @@ const BooruPage = (taglist, serviceName = 'Booru') => {
|
|||||||
downloadState.shown = 'error';
|
downloadState.shown = 'error';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const imageColumns = userOptions.sidebar.imageColumns;
|
const imageColumns = userOptions.sidebar.image.columns;
|
||||||
const imageRows = data.length / imageColumns;
|
const imageRows = data.length / imageColumns;
|
||||||
|
|
||||||
// Init cols
|
// Init cols
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ function paramStringFromObj(params) {
|
|||||||
class BooruService extends Service {
|
class BooruService extends Service {
|
||||||
_baseUrl = 'https://yande.re/post.json';
|
_baseUrl = 'https://yande.re/post.json';
|
||||||
_mode = 'yandere';
|
_mode = 'yandere';
|
||||||
_nsfw = userOptions.sidebar.imageAllowNsfw;
|
_nsfw = userOptions.sidebar.image.allowNsfw;
|
||||||
_responses = [];
|
_responses = [];
|
||||||
_queries = [];
|
_queries = [];
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ class BooruService extends Service {
|
|||||||
const params = {
|
const params = {
|
||||||
'tags': taglist.join('+'),
|
'tags': taglist.join('+'),
|
||||||
'page': `${page}`,
|
'page': `${page}`,
|
||||||
'limit': `${userOptions.sidebar.imageBooruCount}`,
|
'limit': `${userOptions.sidebar.image.batchCount}`,
|
||||||
};
|
};
|
||||||
const paramString = paramStringFromObj(params);
|
const paramString = paramStringFromObj(params);
|
||||||
// Fetch
|
// Fetch
|
||||||
|
|||||||
Reference in New Issue
Block a user