From b984641108898b2af36fcdeabc62ac65087acb67 Mon Sep 17 00:00:00 2001 From: f0x Date: Fri, 16 Sep 2022 16:13:32 +0200 Subject: [PATCH] custom emoji base --- web/source/settings-panel/admin/emoji.js | 37 ++++++++++++++++++- web/source/settings-panel/lib/api/admin.js | 10 +++++ .../settings-panel/redux/reducers/admin.js | 7 +++- 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/web/source/settings-panel/admin/emoji.js b/web/source/settings-panel/admin/emoji.js index d19814f74..e4fff2104 100644 --- a/web/source/settings-panel/admin/emoji.js +++ b/web/source/settings-panel/admin/emoji.js @@ -18,6 +18,39 @@ "use strict"; -module.exports = function AdminCustomization() { - return "custom emoji"; +const Promise = require("bluebird"); +const React = require("react"); +const Redux = require("react-redux"); + +const api = require("../lib/api"); +const adminActions = require("../redux/reducers/admin").actions; + +module.exports = function CustomEmoji() { + return ( + <> +

Custom Emoji

+
+ +
+
+

Upload

+
+ + ); }; + +function EmojiOverview() { + const dispatch = Redux.useDispatch(); + const emoji = Redux.useSelector((state) => state.admin.emoji); + console.log(emoji); + + React.useEffect(() => { + dispatch(api.admin.fetchCustomEmoji()); + }, []); + + return ( + <> + + + ); +} \ No newline at end of file diff --git a/web/source/settings-panel/lib/api/admin.js b/web/source/settings-panel/lib/api/admin.js index 8c258f356..67b170f12 100644 --- a/web/source/settings-panel/lib/api/admin.js +++ b/web/source/settings-panel/lib/api/admin.js @@ -147,6 +147,16 @@ module.exports = function ({ apiCall, getChanges }) { return dispatch(apiCall("POST", `/api/v1/admin/media_cleanup?remote_cache_days=${days}`)); }); }; + }, + + fetchCustomEmoji: function fetchCustomEmoji() { + return function (dispatch, _getState) { + return Promise.try(() => { + return dispatch(apiCall("GET", "/api/v1/custom_emojis")); + }).then((emoji) => { + return dispatch(admin.setEmoji(emoji)); + }); + }; } }; return adminAPI; diff --git a/web/source/settings-panel/redux/reducers/admin.js b/web/source/settings-panel/redux/reducers/admin.js index 570c9f75e..07863cf11 100644 --- a/web/source/settings-panel/redux/reducers/admin.js +++ b/web/source/settings-panel/redux/reducers/admin.js @@ -43,7 +43,8 @@ module.exports = createSlice({ list: "", exportType: "plain", ...emptyBlock() - } + }, + emoji: [] }, reducers: { setBlockedInstances: (state, { payload }) => { @@ -86,6 +87,10 @@ module.exports = createSlice({ state.bulkBlock.list = Object.values(state.blockedInstances).map((entry) => { return entry.domain; }).join("\n"); + }, + + setEmoji: (state, {payload}) => { + state.emoji = payload; } } }); \ No newline at end of file