From 9f8603de31f10cd36c99261905d0a569fafb1001 Mon Sep 17 00:00:00 2001 From: f0x Date: Fri, 13 Jan 2023 23:56:45 +0000 Subject: [PATCH] redux fixes --- web/source/settings/lib/api/index.js | 1 - web/source/settings/lib/api/oauth.js | 8 ++------ web/source/settings/lib/query/admin/index.js | 8 ++++++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/web/source/settings/lib/api/index.js b/web/source/settings/lib/api/index.js index 8cf26f718..1d44c9ef9 100644 --- a/web/source/settings/lib/api/index.js +++ b/web/source/settings/lib/api/index.js @@ -186,7 +186,6 @@ module.exports = { }, oauth: require("./oauth")(submoduleArgs), user: require("./user")(submoduleArgs), - admin: require("./admin")(submoduleArgs), apiCall, convertToForm, getChanges diff --git a/web/source/settings/lib/api/oauth.js b/web/source/settings/lib/api/oauth.js index 68095cac5..15fd5e9d8 100644 --- a/web/source/settings/lib/api/oauth.js +++ b/web/source/settings/lib/api/oauth.js @@ -24,7 +24,6 @@ const { OAUTHError, AuthenticationError } = require("../errors"); const oauth = require("../../redux/reducers/oauth").actions; const temporary = require("../../redux/reducers/temporary").actions; -const admin = require("../../redux/reducers/admin").actions; module.exports = function oauthAPI({ apiCall, getCurrentUrl }) { return { @@ -105,11 +104,8 @@ module.exports = function oauthAPI({ apiCall, getCurrentUrl }) { // no role info, try fetching an admin-only route and see if we get an error return Promise.try(() => { return dispatch(apiCall("GET", "/api/v1/admin/domain_blocks")); - }).then((data) => { - return Promise.all([ - dispatch(oauth.setAdmin(true)), - dispatch(admin.setBlockedInstances(data)) - ]); + }).then(() => { + return dispatch(oauth.setAdmin(true)); }).catch(AuthenticationError, () => { return dispatch(oauth.setAdmin(false)); }); diff --git a/web/source/settings/lib/query/admin/index.js b/web/source/settings/lib/query/admin/index.js index b52bf378d..daa49b6c7 100644 --- a/web/source/settings/lib/query/admin/index.js +++ b/web/source/settings/lib/query/admin/index.js @@ -20,7 +20,6 @@ const { replaceCacheOnMutation, - appendCacheOnMutation, removeFromCacheOnMutation, domainListToObject } = require("../lib"); @@ -60,7 +59,12 @@ const endpoints = (build) => ({ body: formData, discardEmpty: true }), - ...appendCacheOnMutation("instanceBlocks") + transformResponse: (data) => { + return { + [data.domain]: data + }; + }, + ...replaceCacheOnMutation("instanceBlocks") }), removeInstanceBlock: build.mutation({ query: (id) => ({