From fcf612fbe1a3df4145fe24b4cc7255545001d991 Mon Sep 17 00:00:00 2001 From: Pleroma Renovate Bot Date: Thu, 27 Mar 2025 08:52:18 +0000 Subject: [PATCH 01/31] Update dependency eslint-plugin-n to v17.17.0 --- package.json | 2 +- yarn.lock | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 7b82c637e..6301577c5 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "eslint-config-standard": "17.1.0", "eslint-formatter-friendly": "7.0.0", "eslint-plugin-import": "2.31.0", - "eslint-plugin-n": "17.16.2", + "eslint-plugin-n": "17.17.0", "eslint-plugin-promise": "7.2.1", "eslint-plugin-vue": "9.33.0", "eventsource-polyfill": "0.9.6", diff --git a/yarn.lock b/yarn.lock index ff2554243..bb5e0676c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1162,13 +1162,20 @@ resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.25.1.tgz#7d79922cb2d88f9048f06393dbf62d2e4accb584" integrity sha512-Y1EQdcfwMSeQN/ujR5VayLOJ1BHaK+ssyk0AEzPjC+t1lITgsnccPqFjb6V+LsTp/9Iov4ysfjxLaGJ9RPtkVg== -"@eslint-community/eslint-utils@^4.1.2", "@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0", "@eslint-community/eslint-utils@^4.4.1": +"@eslint-community/eslint-utils@^4.1.2", "@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0": version "4.4.1" resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz#d1145bf2c20132d6400495d6df4bf59362fd9d56" integrity sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA== dependencies: eslint-visitor-keys "^3.4.3" +"@eslint-community/eslint-utils@^4.5.0": + version "4.5.1" + resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.5.1.tgz#b0fc7e06d0c94f801537fd4237edc2706d3b8e4c" + integrity sha512-soEIOALTfTK6EjmKMMoLugwaP0rzkad90iIWd1hMO9ARkSAyjfMfkRRhLvD5qH7vvM0Cg72pieUfR6yh6XxC4w== + dependencies: + eslint-visitor-keys "^3.4.3" + "@eslint-community/regexpp@^4.11.0", "@eslint-community/regexpp@^4.12.1": version "4.12.1" resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.12.1.tgz#cfc6cffe39df390a3841cde2abccf92eaa7ae0e0" @@ -3858,12 +3865,12 @@ eslint-plugin-import@2.31.0: string.prototype.trimend "^1.0.8" tsconfig-paths "^3.15.0" -eslint-plugin-n@17.16.2: - version "17.16.2" - resolved "https://registry.yarnpkg.com/eslint-plugin-n/-/eslint-plugin-n-17.16.2.tgz#042eae252b1f4201c77596fc28ee9a391dc07c83" - integrity sha512-iQM5Oj+9o0KaeLoObJC/uxNGpktZCkYiTTBo8PkRWq3HwNcRxwpvSDFjBhQ5+HLJzBTy+CLDC5+bw0Z5GyhlOQ== +eslint-plugin-n@17.17.0: + version "17.17.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-n/-/eslint-plugin-n-17.17.0.tgz#6644433d395c2ecae0b2fe58018807e85d8e0724" + integrity sha512-2VvPK7Mo73z1rDFb6pTvkH6kFibAmnTubFq5l83vePxu0WiY1s0LOtj2WHb6Sa40R3w4mnh8GFYbHBQyMlotKw== dependencies: - "@eslint-community/eslint-utils" "^4.4.1" + "@eslint-community/eslint-utils" "^4.5.0" enhanced-resolve "^5.17.1" eslint-plugin-es-x "^7.8.0" get-tsconfig "^4.8.1" From dfbd17ea371099209be680fd2bc1ace113f3b835 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 26 Mar 2025 15:50:38 +0200 Subject: [PATCH 02/31] make a separate file to store all information about fields and their migrations --- src/modules/config_declaration.js | 42 +++++++++++++++++++++++++++++++ src/modules/users.js | 41 ++++++++++-------------------- src/stores/serverSideStorage.js | 1 - 3 files changed, 55 insertions(+), 29 deletions(-) create mode 100644 src/modules/config_declaration.js diff --git a/src/modules/config_declaration.js b/src/modules/config_declaration.js new file mode 100644 index 000000000..e3328d448 --- /dev/null +++ b/src/modules/config_declaration.js @@ -0,0 +1,42 @@ +export const CONFIG_MIGRATION = 1 +import { v4 as uuidv4 } from 'uuid'; + +// for future use +/* +const simpleDeclaration = { + store: 'server-side', + migrationFlag: 'configMigration', + migration(serverside, rootState) { + serverside.setPreference({ path: 'simple.' + field, value: rootState.config[oldField ?? field] }) + } +} +*/ + +export const declarations = [ + { + field: 'muteFilters', + store: 'server-side', + migrationFlag: 'configMigration', + migrationNum: 1, + description: 'Mute filters, wordfilter/regexp/etc', + valueType: 'complex', + migration (serverside, rootState) { + rootState.config.muteWords.forEach((word, order) => { + const uniqueId = uuidv4() + + serverside.setPreference({ + path: 'simple.muteFilters.' + uniqueId, + value: { + type: 'word', + value: word, + name: word, + enabled: true, + expires: null, + hide: false, + order + } + }) + }) + } + } +] diff --git a/src/modules/users.js b/src/modules/users.js index d9dae91ea..d5ef6cdf5 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -1,5 +1,4 @@ import { compact, map, each, mergeWith, last, concat, uniq, isArray } from 'lodash' -import { v4 as uuidv4 } from 'uuid'; import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js' import { windowWidth, windowHeight } from '../services/window_utils/window_utils' @@ -9,7 +8,9 @@ import { registerPushNotifications, unregisterPushNotifications } from '../servi import { useInterfaceStore } from 'src/stores/interface.js' import { useOAuthStore } from 'src/stores/oauth.js' -import { useServerSideStorageStore, CONFIG_MIGRATION } from 'src/stores/serverSideStorage' +import { useServerSideStorageStore } from 'src/stores/serverSideStorage' + +import { declarations } from 'src/modules/config_declaration' // TODO: Unify with mergeOrAdd in statuses.js export const mergeOrAdd = (arr, obj, item) => { @@ -637,33 +638,17 @@ const users = { /**/ const { configMigration } = useServerSideStorageStore().flagStorage - - // Wordfilter migration - if (configMigration < 1) { - // Convert existing wordfilter into synced one - store.rootState.config.muteWords.forEach((word, order) => { - const uniqueId = uuidv4() - - useServerSideStorageStore().setPreference({ - path: 'simple.muteFilters.' + uniqueId, - value: { - type: 'word', - value: word, - name: word, - enabled: true, - expires: null, - hide: false, - order - } - }) + declarations + .filter(x => { + return x.store === 'server-side' && + (x.migrationNum ?? x.migrationNum > configMigration) + }) + .toSorted((a, b) => a.configMigration - b.configMigration) + .forEach(value => { + value.migration(useServerSideStorageStore(), store.rootState) + useServerSideStorageStore().setFlag({ flag: 'configMigration', value: value.migrationNum }) + useServerSideStorageStore().pushServerSideStorage() }) - } - - if (configMigration < CONFIG_MIGRATION) { - // Update the flag - useServerSideStorageStore().setFlag({ flag: 'configMigration', value: CONFIG_MIGRATION }) - useServerSideStorageStore().pushServerSideStorage() - } if (user.token) { dispatch('setWsToken', user.token) diff --git a/src/stores/serverSideStorage.js b/src/stores/serverSideStorage.js index b7c192f0c..9cfdac1a8 100644 --- a/src/stores/serverSideStorage.js +++ b/src/stores/serverSideStorage.js @@ -17,7 +17,6 @@ import { import { CURRENT_UPDATE_COUNTER } from 'src/components/update_notification/update_notification.js' export const VERSION = 1 -export const CONFIG_MIGRATION = 1 export const NEW_USER_DATE = new Date('2022-08-04') // date of writing this, basically export const COMMAND_TRIM_FLAGS = 1000 From 845d091c3eef2b7793916d3a72f40d46f103ccf5 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Thu, 27 Mar 2025 13:38:59 +0200 Subject: [PATCH 03/31] lint --- src/components/settings_modal/tabs/filtering_tab.js | 2 +- src/components/settings_modal/tabs/filtering_tab.vue | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/settings_modal/tabs/filtering_tab.js b/src/components/settings_modal/tabs/filtering_tab.js index 4b404023d..0a630a61b 100644 --- a/src/components/settings_modal/tabs/filtering_tab.js +++ b/src/components/settings_modal/tabs/filtering_tab.js @@ -1,4 +1,4 @@ -import { throttle, cloneDeep } from 'lodash' +import { cloneDeep } from 'lodash' import { mapState, mapActions } from 'pinia' import { useServerSideStorageStore } from 'src/stores/serverSideStorage' import { v4 as uuidv4 } from 'uuid'; diff --git a/src/components/settings_modal/tabs/filtering_tab.vue b/src/components/settings_modal/tabs/filtering_tab.vue index be4ac3fcf..ddbcef536 100644 --- a/src/components/settings_modal/tabs/filtering_tab.vue +++ b/src/components/settings_modal/tabs/filtering_tab.vue @@ -74,10 +74,10 @@

{{ $t('settings.filter.mute_filter') }}