diff --git a/web/source/settings/admin/emoji.js b/web/source/settings/admin/emoji.js index 1ef4a54a3..ad7fcab06 100644 --- a/web/source/settings/admin/emoji.js +++ b/web/source/settings/admin/emoji.js @@ -30,21 +30,11 @@ const { formFields } = require("../components/form-fields"); const api = require("../lib/api"); const adminActions = require("../redux/reducers/admin").actions; const submit = require("../lib/submit"); +const BackButton = require("../components/back-button"); const base = "/settings/admin/custom-emoji"; module.exports = function CustomEmoji() { - return ( - - - - - - - ); -}; - -function EmojiOverview() { const dispatch = Redux.useDispatch(); const [loaded, setLoaded] = React.useState(false); @@ -74,12 +64,25 @@ function EmojiOverview() { return ( <> -

Custom Emoji

- - {errorMsg.length > 0 &&
{errorMsg}
} + + + + + + + + ); +}; + +function EmojiOverview() { + return ( + <> +

Custom Emoji

+ + ); } @@ -176,10 +179,10 @@ function EmojiCategory({category, entries}) {
{entries.map((e) => { return ( - // - + + {/* */} - {e.shortcode} + {e.shortcode} ); @@ -195,6 +198,13 @@ function EmojiDetailWrapped() { inputs get re-created on every change, causing them to lose focus, and bad performance */ let [_match, {emojiId}] = useRoute(`${base}/:emojiId`); + const emojiById = Redux.useSelector((state) => state.admin.emojiById); + const emoji = emojiById[emojiId]; + if (emoji == undefined) { + return ( +

Custom Emoji:

+ ); + } function alterEmoji([key, val]) { return adminActions.updateDomainBlockVal([emojiId, key, val]); @@ -202,11 +212,18 @@ function EmojiDetailWrapped() { const fields = formFields(alterEmoji, (state) => state.admin.blockedInstances[emojiId]); - return ; + return ; } -function EmojiDetail({id, Form}) { +function EmojiDetail({emoji, Form}) { return ( - "Not implemented yet" +
+

Custom Emoji: {emoji.shortcode}

+

+ Editing custom emoji isn't implemented yet.
+ View implementation progress. +

+ {emoji.shortcode} +
); } \ No newline at end of file diff --git a/web/source/settings/admin/federation.js b/web/source/settings/admin/federation.js index 7afc3c699..99f10e69e 100644 --- a/web/source/settings/admin/federation.js +++ b/web/source/settings/admin/federation.js @@ -29,6 +29,7 @@ const { formFields } = require("../components/form-fields"); const api = require("../lib/api"); const adminActions = require("../redux/reducers/admin").actions; const submit = require("../lib/submit"); +const BackButton = require("../components/back-button"); const base = "/settings/admin/federation"; @@ -280,14 +281,6 @@ function BulkBlocking() { ); } -function BackButton() { - return ( - - < back - - ); -} - function InstancePageWrapped() { /* We wrap the component to generate formFields with a setter depending on the domain if formFields() is used inside the same component that is re-rendered with their state, @@ -345,7 +338,7 @@ function InstancePage({domain, Form}) { return (
-

Federation settings for: {domain}

+

Federation settings for: {domain}

{entry.new && "No stored block yet, you can add one below:"} . +*/ + +"use strict"; + +const React = require("react"); +const { Link } = require("wouter"); + +module.exports = function BackButton({to}) { + return ( + + < back + + ); +}; \ No newline at end of file diff --git a/web/source/settings/lib/api/admin.js b/web/source/settings/lib/api/admin.js index 1df47b693..56513b900 100644 --- a/web/source/settings/lib/api/admin.js +++ b/web/source/settings/lib/api/admin.js @@ -164,7 +164,7 @@ module.exports = function ({ apiCall, getChanges }) { fetchCustomEmoji: function fetchCustomEmoji() { return function (dispatch, _getState) { return Promise.try(() => { - return dispatch(apiCall("GET", "/api/v1/custom_emojis")); + return dispatch(apiCall("GET", "/api/v1/admin/custom_emojis?filter=domain:local&limit=0")); }).then((emoji) => { return dispatch(admin.setEmoji(emoji)); }); diff --git a/web/source/settings/redux/reducers/admin.js b/web/source/settings/redux/reducers/admin.js index 20d3d748d..666286178 100644 --- a/web/source/settings/redux/reducers/admin.js +++ b/web/source/settings/redux/reducers/admin.js @@ -37,6 +37,7 @@ function emptyBlock() { function emptyEmojiForm() { return { + id: Date.now(), shortcode: "" }; } @@ -53,6 +54,7 @@ module.exports = createSlice({ }, newInstanceBlocks: {}, emoji: {}, + emojiById: {}, newEmoji: emptyEmojiForm() }, reducers: { @@ -113,6 +115,7 @@ module.exports = createSlice({ } state.emoji[emoji.category] = defaultValue(state.emoji[emoji.category], []); state.emoji[emoji.category].push(emoji); + state.emojiById[emoji.id] = emoji; }); }, @@ -124,8 +127,12 @@ module.exports = createSlice({ if (emoji.category == undefined) { emoji.category = "Unsorted"; } + if (emoji.id == undefined) { + emoji.id = Date.now(); + } state.emoji[emoji.category] = defaultValue(state.emoji[emoji.category], []); state.emoji[emoji.category].push(emoji); + state.emojiById[emoji.id] = emoji; }, } }); \ No newline at end of file