cleanup old code
This commit is contained in:
parent
4bb308b1f2
commit
774cb78732
|
@ -35,15 +35,8 @@ const { matchSorter } = require("match-sorter");
|
||||||
|
|
||||||
const base = "/settings/admin/federation";
|
const base = "/settings/admin/federation";
|
||||||
|
|
||||||
// const {
|
|
||||||
// TextInput,
|
|
||||||
// TextArea,
|
|
||||||
// File
|
|
||||||
// } = require("../components/form-fields").formFields(adminActions.setAdminSettingsVal, (state) => state.instances.adminSettings);
|
|
||||||
|
|
||||||
module.exports = function AdminSettings() {
|
module.exports = function AdminSettings() {
|
||||||
const dispatch = Redux.useDispatch();
|
const dispatch = Redux.useDispatch();
|
||||||
// const instance = Redux.useSelector(state => state.instances.adminSettings);
|
|
||||||
const loadedBlockedInstances = Redux.useSelector(state => state.admin.loadedBlockedInstances);
|
const loadedBlockedInstances = Redux.useSelector(state => state.admin.loadedBlockedInstances);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
|
|
@ -21,32 +21,10 @@
|
||||||
const Promise = require("bluebird");
|
const Promise = require("bluebird");
|
||||||
const isValidDomain = require("is-valid-domain");
|
const isValidDomain = require("is-valid-domain");
|
||||||
|
|
||||||
const instance = require("../../redux/reducers/instances").actions;
|
|
||||||
const admin = require("../../redux/reducers/admin").actions;
|
const admin = require("../../redux/reducers/admin").actions;
|
||||||
|
|
||||||
module.exports = function ({ apiCall, getChanges }) {
|
module.exports = function ({ apiCall, getChanges }) {
|
||||||
const adminAPI = {
|
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() {
|
fetchDomainBlocks: function fetchDomainBlocks() {
|
||||||
return function (dispatch, _getState) {
|
return function (dispatch, _getState) {
|
||||||
return Promise.try(() => {
|
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;
|
return adminAPI;
|
||||||
};
|
};
|
|
@ -22,21 +22,7 @@ const Promise = require("bluebird");
|
||||||
|
|
||||||
const user = require("../../redux/reducers/user").actions;
|
const user = require("../../redux/reducers/user").actions;
|
||||||
|
|
||||||
module.exports = function ({ apiCall, getChanges }) {
|
module.exports = function ({ apiCall }) {
|
||||||
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));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fetchAccount: function fetchAccount() {
|
fetchAccount: function fetchAccount() {
|
||||||
return function (dispatch, _getState) {
|
return function (dispatch, _getState) {
|
||||||
|
@ -46,22 +32,6 @@ module.exports = function ({ apiCall, getChanges }) {
|
||||||
return dispatch(user.setAccount(account));
|
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});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
|
@ -19,7 +19,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const { createSlice } = require("@reduxjs/toolkit");
|
const { createSlice } = require("@reduxjs/toolkit");
|
||||||
const d = require("dotty");
|
|
||||||
|
|
||||||
module.exports = createSlice({
|
module.exports = createSlice({
|
||||||
name: "user",
|
name: "user",
|
||||||
|
@ -39,12 +38,6 @@ module.exports = createSlice({
|
||||||
state.settings = {
|
state.settings = {
|
||||||
source: payload.source
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
Loading…
Reference in New Issue