Skip to content

Commit

Permalink
[bugfix] use instance configured emoji maxsize on emoji update valida…
Browse files Browse the repository at this point in the history
…tion (#3056)
  • Loading branch information
f0x52 authored Jun 29, 2024
1 parent 137ef5a commit a76670a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions web/source/settings/views/admin/emoji/local/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import React, { useEffect } from "react";
import React, { useEffect, useMemo } from "react";
import { Redirect, useParams } from "wouter";
import { useComboBoxInput, useFileInput, useValue } from "../../../../lib/form";
import useFormSubmit from "../../../../lib/form/submit";
Expand All @@ -29,6 +29,7 @@ import { FileInput } from "../../../../components/form/inputs";
import MutationButton from "../../../../components/form/mutation-button";
import { Error } from "../../../../components/error";
import { useGetEmojiQuery, useEditEmojiMutation, useDeleteEmojiMutation } from "../../../../lib/query/admin/custom-emoji";
import { useInstanceV1Query } from "../../../../lib/query/gts-api";
import { CategorySelect } from "../category-select";
import BackButton from "../../../../components/back-button";

Expand All @@ -44,13 +45,18 @@ export default function EmojiDetail() {
}

function EmojiDetailForm({ data: emoji }) {
const { data: instance } = useInstanceV1Query();
const emojiMaxSize = useMemo(() => {
return instance?.configuration?.emojis?.emoji_size_limit ?? 50 * 1024;
}, [instance]);

const baseUrl = useBaseUrl();
const form = {
id: useValue("id", emoji.id),
category: useComboBoxInput("category", { source: emoji }),
image: useFileInput("image", {
withPreview: true,
maxSize: 50 * 1024 // TODO: get from instance api
maxSize: emojiMaxSize
})
};

Expand Down

0 comments on commit a76670a

Please sign in to comment.