refactor (minor): update MkPostForm

This commit is contained in:
naskya 2023-11-22 22:21:47 +09:00
parent a5dac3931f
commit e0c1d9ce00
No known key found for this signature in database
GPG key ID: 164DFF24E2D40139

View file

@ -344,7 +344,6 @@ const visibleUsers = ref([]);
if (props.initialVisibleUsers) {
props.initialVisibleUsers.forEach(pushVisibleUser);
}
const autocomplete = ref(null);
const draghover = ref(false);
const quoteId = ref(null);
const hasNotSpecifiedMentions = ref(false);
@ -476,11 +475,11 @@ if (props.reply && props.reply.text != null) {
? `@${x.username}`
: `@${x.username}@${toASCII(otherHost)}`;
//
// exclude me
if ($i.username === x.username && (x.host == null || x.host === host))
continue;
//
// remove duplicates
if (text.value.includes(`${mention} `)) continue;
text.value += `${mention} `;
@ -489,10 +488,10 @@ if (props.reply && props.reply.text != null) {
if (props.channel) {
visibility.value = "public";
localOnly.value = true; // TODO:
localOnly.value = true; // TODO: Delete this once channels get federated
}
//
// Inherit the original visibility
if (
props.reply &&
["home", "followers", "specified"].includes(props.reply.visibility)
@ -611,10 +610,6 @@ function togglePoll() {
}
}
function addTag(tag: string) {
insertTextAtCursor(textareaEl.value, ` #${tag} `);
}
function focus() {
if (textareaEl.value) {
textareaEl.value.focus();
@ -718,6 +713,8 @@ function clear() {
quoteId.value = null;
}
// FIXME: ev.which is deprecated
// https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/which
function onKeydown(ev: KeyboardEvent) {
if (
(ev.which === 10 || ev.which === 13) &&
@ -754,7 +751,7 @@ async function onPaste(ev: ClipboardEvent) {
}
}
const paste = ev.clipboardData.getData("text");
const paste = ev.clipboardData?.getData("text") ?? "";
if (!props.renote && !quoteId.value && paste.startsWith(url + "/notes/")) {
ev.preventDefault();
@ -769,7 +766,7 @@ async function onPaste(ev: ClipboardEvent) {
}
quoteId.value = paste
.substr(url.length)
.substring(url.length)
.match(/^\/notes\/(.+?)\/?$/)[1];
});
}