From 774cb787325b936bd072c85215808f7f0bf99c2c Mon Sep 17 00:00:00 2001 From: f0x Date: Sun, 8 Jan 2023 17:38:50 +0000 Subject: [PATCH] cleanup old code --- web/source/settings/admin/federation.js | 7 ----- web/source/settings/lib/api/admin.js | 30 -------------------- web/source/settings/lib/api/user.js | 32 +--------------------- web/source/settings/redux/reducers/user.js | 7 ----- 4 files changed, 1 insertion(+), 75 deletions(-) diff --git a/web/source/settings/admin/federation.js b/web/source/settings/admin/federation.js index 26c46ed0b..5cfe2254c 100644 --- a/web/source/settings/admin/federation.js +++ b/web/source/settings/admin/federation.js @@ -35,15 +35,8 @@ const { matchSorter } = require("match-sorter"); const base = "/settings/admin/federation"; -// const { -// TextInput, -// TextArea, -// File -// } = require("../components/form-fields").formFields(adminActions.setAdminSettingsVal, (state) => state.instances.adminSettings); - module.exports = function AdminSettings() { const dispatch = Redux.useDispatch(); - // const instance = Redux.useSelector(state => state.instances.adminSettings); const loadedBlockedInstances = Redux.useSelector(state => state.admin.loadedBlockedInstances); React.useEffect(() => { diff --git a/web/source/settings/lib/api/admin.js b/web/source/settings/lib/api/admin.js index 848772db7..75f332bc1 100644 --- a/web/source/settings/lib/api/admin.js +++ b/web/source/settings/lib/api/admin.js @@ -21,32 +21,10 @@ const Promise = require("bluebird"); const isValidDomain = require("is-valid-domain"); -const instance = require("../../redux/reducers/instances").actions; const admin = require("../../redux/reducers/admin").actions; module.exports = function ({ apiCall, getChanges }) { const adminAPI = { - updateInstance: function updateInstance() { - return function (dispatch, getState) { - return Promise.try(() => { - const state = getState().instances.adminSettings; - - const update = getChanges(state, { - formKeys: ["title", "short_description", "description", "contact_account.username", "email", "terms", "thumbnail_description"], - renamedKeys: { - "email": "contact_email", - "contact_account.username": "contact_username" - }, - fileKeys: ["thumbnail"] - }); - - return dispatch(apiCall("PATCH", "/api/v1/instance", update, "form")); - }).then((data) => { - return dispatch(instance.setInstanceInfo(data)); - }); - }; - }, - fetchDomainBlocks: function fetchDomainBlocks() { return function (dispatch, _getState) { return Promise.try(() => { @@ -155,14 +133,6 @@ module.exports = function ({ apiCall, getChanges }) { }); }; }, - - mediaCleanup: function mediaCleanup(days) { - return function (dispatch, _getState) { - return Promise.try(() => { - return dispatch(apiCall("POST", `/api/v1/admin/media_cleanup?remote_cache_days=${days}`)); - }); - }; - }, }; return adminAPI; }; \ No newline at end of file diff --git a/web/source/settings/lib/api/user.js b/web/source/settings/lib/api/user.js index 41031d489..c59220259 100644 --- a/web/source/settings/lib/api/user.js +++ b/web/source/settings/lib/api/user.js @@ -22,21 +22,7 @@ const Promise = require("bluebird"); const user = require("../../redux/reducers/user").actions; -module.exports = function ({ apiCall, getChanges }) { - function updateCredentials(selector, keys) { - return function (dispatch, getState) { - return Promise.try(() => { - const state = selector(getState()); - - const update = getChanges(state, keys); - - return dispatch(apiCall("PATCH", "/api/v1/accounts/update_credentials", update, "form")); - }).then((account) => { - return dispatch(user.setAccount(account)); - }); - }; - } - +module.exports = function ({ apiCall }) { return { fetchAccount: function fetchAccount() { return function (dispatch, _getState) { @@ -46,22 +32,6 @@ module.exports = function ({ apiCall, getChanges }) { return dispatch(user.setAccount(account)); }); }; - }, - - updateProfile: function updateProfile() { - const formKeys = ["display_name", "locked", "source", "custom_css", "source.note", "enable_rss"]; - const renamedKeys = { - "source.note": "note" - }; - const fileKeys = ["header", "avatar"]; - - return updateCredentials((state) => state.user.profile, {formKeys, renamedKeys, fileKeys}); - }, - - updateSettings: function updateProfile() { - const formKeys = ["source"]; - - return updateCredentials((state) => state.user.settings, {formKeys}); } }; }; \ No newline at end of file diff --git a/web/source/settings/redux/reducers/user.js b/web/source/settings/redux/reducers/user.js index 21177ebdc..fe0ba7bfe 100644 --- a/web/source/settings/redux/reducers/user.js +++ b/web/source/settings/redux/reducers/user.js @@ -19,7 +19,6 @@ "use strict"; const { createSlice } = require("@reduxjs/toolkit"); -const d = require("dotty"); module.exports = createSlice({ name: "user", @@ -39,12 +38,6 @@ module.exports = createSlice({ state.settings = { source: payload.source }; - }, - setProfileVal: (state, { payload: [key, val] }) => { - d.put(state.profile, key, val); - }, - setSettingsVal: (state, { payload: [key, val] }) => { - d.put(state.settings, key, val); } } }); \ No newline at end of file