refactor: ♻️ Fix linter errors

This commit is contained in:
Jesse Wierzbinski 2024-06-19 14:07:56 -10:00
parent 8a984abfb2
commit f9433e259b
No known key found for this signature in database
30 changed files with 235 additions and 157 deletions

View file

@ -121,15 +121,17 @@ onMounted(() => {
useListen("composer:reply", (note: Status) => {
respondingTo.value = note;
respondingType.value = "reply";
if (note.account.id !== identity.value?.account.id)
if (note.account.id !== identity.value?.account.id) {
content.value = `@${note.account.acct} `;
}
});
useListen("composer:quote", (note: Status) => {
respondingTo.value = note;
respondingType.value = "quote";
if (note.account.id !== identity.value?.account.id)
if (note.account.id !== identity.value?.account.id) {
content.value = `@${note.account.acct} `;
}
});
useListen("composer:edit", async (note: Status) => {
@ -176,7 +178,7 @@ const client = useClient();
const send = async () => {
loading.value = true;
if (!identity.value || !client.value) {
if (!(identity.value && client.value)) {
throw new Error("Not authenticated");
}

View file

@ -25,8 +25,9 @@ const { Tab, ArrowRight, ArrowLeft, Enter } = useMagicKeys({
if (
["Tab", "Enter", "ArrowRight", "ArrowLeft"].includes(e.key) &&
topEmojis.value !== null
)
) {
e.preventDefault();
}
},
});
const identity = useCurrentIdentity();
@ -34,9 +35,11 @@ const topEmojis = ref<Emoji[] | null>(null);
const selectedEmojiIndex = ref<number | null>(null);
watchEffect(() => {
if (!identity.value) return;
if (!identity.value) {
return;
}
if (props.currentlyTypingEmoji !== null)
if (props.currentlyTypingEmoji !== null) {
topEmojis.value = identity.value.emojis
.map((emoji) => ({
...emoji,
@ -47,7 +50,9 @@ watchEffect(() => {
}))
.sort((a, b) => a.distance - b.distance)
.slice(0, 20);
else topEmojis.value = null;
} else {
topEmojis.value = null;
}
if (ArrowRight?.value && topEmojis.value !== null) {
selectedEmojiIndex.value = (selectedEmojiIndex.value ?? -1) + 1;
@ -74,7 +79,9 @@ watchEffect(() => {
if ((Tab?.value || Enter?.value) && topEmojis.value !== null) {
const emoji = topEmojis.value[selectedEmojiIndex.value ?? 0];
if (emoji) emit("autocomplete", emoji.shortcode);
if (emoji) {
emit("autocomplete", emoji.shortcode);
}
}
});

View file

@ -104,7 +104,9 @@ watch(
files,
(newFiles) => {
for (const data of newFiles) {
if (data.progress === 0) uploadFile(data.file);
if (data.progress === 0) {
uploadFile(data.file);
}
}
},
{
@ -137,14 +139,22 @@ const updateAltText = (id: string, altText?: string) => {
};
const getIcon = (mimeType: string) => {
if (mimeType.startsWith("image/")) return "tabler:photo";
if (mimeType.startsWith("video/")) return "tabler:video";
if (mimeType.startsWith("audio/")) return "tabler:music";
if (mimeType.startsWith("image/")) {
return "tabler:photo";
}
if (mimeType.startsWith("video/")) {
return "tabler:video";
}
if (mimeType.startsWith("audio/")) {
return "tabler:music";
}
return "tabler:file";
};
const formatBytes = (bytes: number) => {
if (bytes === 0) return "0 Bytes";
if (bytes === 0) {
return "0 Bytes";
}
const k = 1000;
const dm = 2;
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];

View file

@ -24,8 +24,9 @@ const { Tab, ArrowRight, ArrowLeft, Enter } = useMagicKeys({
if (
["Tab", "Enter", "ArrowRight", "ArrowLeft"].includes(e.key) &&
topUsers.value !== null
)
) {
e.preventDefault();
}
},
});
const topUsers = ref<Account[] | null>(null);
@ -79,7 +80,9 @@ watch(
if ((Tab?.value || Enter?.value) && topUsers.value !== null) {
const user = topUsers.value[selectedUserIndex.value ?? 0];
if (user) emit("autocomplete", user.username);
if (user) {
emit("autocomplete", user.username);
}
}
},
);

View file

@ -50,7 +50,9 @@ useListen("note:edit", async (note) => {
useEvent("composer:edit", note);
});
useListen("composer:open", () => {
if (identity.value) open.value = true;
if (identity.value) {
open.value = true;
}
});
useListen("composer:close", () => {
open.value = false;