From: SleeplessOne1917 Date: Sat, 24 Jun 2023 02:46:33 +0000 (-0400) Subject: Fix emojis being unable to save X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/readmes/%7B%7D/%7Bthis.state.thumbnail%7D?a=commitdiff_plain;h=0ad285b16674fb98dc17fb636a9f1a0dbb9dd2a4;p=lemmy-ui.git Fix emojis being unable to save --- diff --git a/src/shared/components/home/admin-settings.tsx b/src/shared/components/home/admin-settings.tsx index 7ac69fe..76877d8 100644 --- a/src/shared/components/home/admin-settings.tsx +++ b/src/shared/components/home/admin-settings.tsx @@ -44,7 +44,6 @@ interface AdminSettingsState { instancesRes: RequestState; bannedRes: RequestState; leaveAdminTeamRes: RequestState; - emojiLoading: boolean; loading: boolean; themeList: string[]; isIsomorphic: boolean; @@ -59,7 +58,6 @@ export class AdminSettings extends Component { bannedRes: { state: "empty" }, instancesRes: { state: "empty" }, leaveAdminTeamRes: { state: "empty" }, - emojiLoading: false, loading: false, themeList: [], isIsomorphic: false, @@ -215,7 +213,6 @@ export class AdminSettings extends Component { onCreate={this.handleCreateEmoji} onDelete={this.handleDeleteEmoji} onEdit={this.handleEditEmoji} - loading={this.state.emojiLoading} /> @@ -345,35 +342,23 @@ export class AdminSettings extends Component { } async handleEditEmoji(form: EditCustomEmoji) { - this.setState({ emojiLoading: true }); - const res = await HttpService.client.editCustomEmoji(form); if (res.state === "success") { updateEmojiDataModel(res.data.custom_emoji); } - - this.setState({ emojiLoading: false }); } async handleDeleteEmoji(form: DeleteCustomEmoji) { - this.setState({ emojiLoading: true }); - const res = await HttpService.client.deleteCustomEmoji(form); if (res.state === "success") { removeFromEmojiDataModel(res.data.id); } - - this.setState({ emojiLoading: false }); } async handleCreateEmoji(form: CreateCustomEmoji) { - this.setState({ emojiLoading: true }); - const res = await HttpService.client.createCustomEmoji(form); if (res.state === "success") { updateEmojiDataModel(res.data.custom_emoji); } - - this.setState({ emojiLoading: false }); } } diff --git a/src/shared/components/home/emojis-form.tsx b/src/shared/components/home/emojis-form.tsx index 8428a54..caf8221 100644 --- a/src/shared/components/home/emojis-form.tsx +++ b/src/shared/components/home/emojis-form.tsx @@ -1,4 +1,5 @@ import { myAuthRequired, setIsoData } from "@utils/app"; +import { capitalizeFirstLetter } from "@utils/helpers"; import { Component, linkEvent } from "inferno"; import { CreateCustomEmoji, @@ -11,14 +12,13 @@ import { HttpService, I18NextService } from "../../services"; import { pictrsDeleteToast, toast } from "../../toast"; import { EmojiMart } from "../common/emoji-mart"; import { HtmlTags } from "../common/html-tags"; -import { Icon } from "../common/icon"; +import { Icon, Spinner } from "../common/icon"; import { Paginator } from "../common/paginator"; interface EmojiFormProps { onEdit(form: EditCustomEmoji): void; onCreate(form: CreateCustomEmoji): void; onDelete(form: DeleteCustomEmoji): void; - loading: boolean; } interface EmojiFormState { @@ -36,6 +36,7 @@ interface CustomEmojiViewForm { keywords: string; changed: boolean; page: number; + loading: boolean; } export class EmojiForm extends Component { @@ -52,6 +53,7 @@ export class EmojiForm extends Component { keywords: x.keywords.map(x => x.keyword).join(" "), changed: false, page: 1 + Math.floor(index / this.itemsPerPage), + loading: false, })), page: 1, }; @@ -119,33 +121,39 @@ export class EmojiForm extends Component { .map((cv, index) => ( (this.scrollRef[cv.shortcode] = e)}> - - + {cv.image_url.length > 0 && ( + {cv.alt_text} + )} + {cv.image_url.length === 0 && ( +
+ +
+ )} {