mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-02 00:22:45 +00:00
fix validation order
This commit is contained in:
parent
886e663382
commit
41f25653d1
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
const Promise = require("bluebird");
|
const Promise = require("bluebird");
|
||||||
const React = require("react");
|
const React = require("react");
|
||||||
const Redux = require("react-redux");
|
|
||||||
const {Link} = require("wouter");
|
const {Link} = require("wouter");
|
||||||
const defaultValue = require('default-value');
|
const defaultValue = require('default-value');
|
||||||
const prettierBytes = require("prettier-bytes");
|
const prettierBytes = require("prettier-bytes");
|
||||||
|
@ -166,28 +165,26 @@ function NewEmoji({emoji}) {
|
||||||
function onShortChange(e) {
|
function onShortChange(e) {
|
||||||
let input = e.target.value;
|
let input = e.target.value;
|
||||||
setShortcode(input);
|
setShortcode(input);
|
||||||
validateShortcode(input);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateShortcode(code) {
|
React.useEffect(() => {
|
||||||
console.log("code: (%s)", code);
|
if (emojiCodes.has(shortcode)) {
|
||||||
if (emojiCodes.has(code)) {
|
|
||||||
shortcodeRef.current.setCustomValidity("Shortcode already in use");
|
shortcodeRef.current.setCustomValidity("Shortcode already in use");
|
||||||
} else {
|
} else {
|
||||||
shortcodeRef.current.setCustomValidity("");
|
shortcodeRef.current.setCustomValidity("");
|
||||||
}
|
}
|
||||||
shortcodeRef.current.reportValidity();
|
shortcodeRef.current.reportValidity();
|
||||||
}
|
}, [shortcode, shortcodeRef, emojiCodes]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (shortcode.length == 0) {
|
if (shortcode.length == 0) {
|
||||||
if (file != undefined) {
|
if (file != undefined) {
|
||||||
let [name, _ext] = file.name.split(".");
|
let [name, _ext] = file.name.split(".");
|
||||||
setShortcode(name);
|
setShortcode(name);
|
||||||
validateShortcode(name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [file, shortcode]);
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [file]);
|
||||||
|
|
||||||
function uploadEmoji(e) {
|
function uploadEmoji(e) {
|
||||||
if (e) {
|
if (e) {
|
||||||
|
|
Loading…
Reference in a new issue