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;

View file

@ -104,7 +104,9 @@ const save = async () => {
type: "success",
});
if (identity.value) identity.value.account = data;
if (identity.value) {
identity.value.account = data;
}
} catch (e) {
const error = e as ResponseError<{ error: string }>;

View file

@ -187,7 +187,7 @@ const signIn = async () => {
const signOut = async (id?: string) => {
loadingAuth.value = true;
if (!appData.value || !identity.value) {
if (!(appData.value && identity.value)) {
console.error("No app or identity data to sign out");
return;
}
@ -208,7 +208,9 @@ const signOut = async (id?: string) => {
identityToRevoke.tokens.access_token,
identityToRevoke.tokens.access_token,
)
.catch(() => {});
.catch(() => {
// Do nothing
});
if (id === identity.value.id) {
identity.value = null;

View file

@ -41,10 +41,11 @@ const calculatedWidth = computed(
const getWidth = (index: number, lines: number) => {
if (isWidthSpecified.value) {
if (isContent.value)
if (isContent.value) {
return index === lines
? `${calculatedWidth.value}${props.widthUnit}`
: "100%";
}
return `${calculatedWidth.value}${props.widthUnit}`;
}
return undefined;

View file

@ -50,7 +50,9 @@ const openLightbox = () => {
};
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

@ -206,7 +206,9 @@ const numberFormat = (number = 0) =>
}).format(number);
const likeFn = async () => {
if (!outputtedNote.value) return;
if (!outputtedNote.value) {
return;
}
if (outputtedNote.value.favourited) {
const output = await client.value.unfavouriteStatus(
outputtedNote.value.id,
@ -227,7 +229,9 @@ const likeFn = async () => {
};
const reblogFn = async () => {
if (!outputtedNote.value) return;
if (!outputtedNote.value) {
return;
}
if (outputtedNote.value?.reblogged) {
const output = await client.value.unreblogStatus(
outputtedNote.value.id,

View file

@ -43,7 +43,9 @@ const { relationship } = useRelationship(
);
const acceptFollowRequest = async () => {
if (!props.notification?.account) return;
if (!props.notification?.account) {
return;
}
isWorkingOnFollowRequest.value = true;
const { data } = await client.value.acceptFollowRequest(
props.notification.account.id,
@ -53,7 +55,9 @@ const acceptFollowRequest = async () => {
};
const rejectFollowRequest = async () => {
if (!props.notification?.account) return;
if (!props.notification?.account) {
return;
}
isWorkingOnFollowRequest.value = true;
const { data } = await client.value.rejectFollowRequest(
props.notification.account.id,
@ -69,7 +73,9 @@ const { display_name } = useParsedAccount(
);
const text = computed(() => {
if (!props.notification) return "";
if (!props.notification) {
return "";
}
switch (props.notification.type) {
case "mention":
@ -82,13 +88,16 @@ const text = computed(() => {
return "followed you";
case "follow_request":
return "requested to follow you";
default:
default: {
console.error("Unknown notification type", props.notification.type);
return "";
}
}
});
const icon = computed(() => {
if (!props.notification) return "";
if (!props.notification) {
return "";
}
switch (props.notification.type) {
case "mention":

View file

@ -112,7 +112,9 @@ const accountId = computed(() => props.account?.id ?? null);
const { relationship, isLoading } = useRelationship(client, accountId);
const follow = () => {
if (!identity.value || !props.account || !relationship.value) return;
if (!(identity.value && props.account && relationship.value)) {
return;
}
relationship.value = {
...relationship.value,
following: true,
@ -120,7 +122,9 @@ const follow = () => {
};
const unfollow = () => {
if (!identity.value || !props.account || !relationship.value) return;
if (!(identity.value && props.account && relationship.value)) {
return;
}
relationship.value = {
...relationship.value,
following: false,

View file

@ -52,7 +52,9 @@ watch(
() => props.timeline,
(newTimeline, oldTimeline) => {
// If posts are deleted, don't start loading more posts
if (newTimeline.length === oldTimeline.length - 1) return;
if (newTimeline.length === oldTimeline.length - 1) {
return;
}
isLoading.value = false;
// If less than NOTES_PER_PAGE statuses are returned, we have reached the end
if (