mirror of
https://github.com/versia-pub/frontend.git
synced 2025-12-06 08:28:20 +01:00
refactor: ♻️ Fix linter errors
This commit is contained in:
parent
8a984abfb2
commit
f9433e259b
62
biome.json
62
biome.json
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"$schema": "https://biomejs.dev/schemas/1.6.4/schema.json",
|
"$schema": "https://biomejs.dev/schemas/1.8.1/schema.json",
|
||||||
"organizeImports": {
|
"organizeImports": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"ignore": ["node_modules/**/*", "dist/**/*", ".output", ".nuxt"]
|
"ignore": ["node_modules/**/*", "dist/**/*", ".output", ".nuxt"]
|
||||||
|
|
@ -7,7 +7,65 @@
|
||||||
"linter": {
|
"linter": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"rules": {
|
"rules": {
|
||||||
"recommended": true
|
"all": true,
|
||||||
|
"correctness": {
|
||||||
|
"noNodejsModules": "off",
|
||||||
|
"noUndeclaredVariables": "off",
|
||||||
|
"useHookAtTopLevel": "off",
|
||||||
|
"noUnusedVariables": "off",
|
||||||
|
"noUnusedImports": "off"
|
||||||
|
},
|
||||||
|
"complexity": {
|
||||||
|
"noExcessiveCognitiveComplexity": "off"
|
||||||
|
},
|
||||||
|
"style": {
|
||||||
|
"noDefaultExport": "off",
|
||||||
|
"noParameterProperties": "off",
|
||||||
|
"noNamespaceImport": "off",
|
||||||
|
"useFilenamingConvention": "off",
|
||||||
|
"useNamingConvention": {
|
||||||
|
"level": "warn",
|
||||||
|
"options": {
|
||||||
|
"requireAscii": false,
|
||||||
|
"strictCase": false,
|
||||||
|
"conventions": [
|
||||||
|
{
|
||||||
|
"selector": {
|
||||||
|
"kind": "typeProperty"
|
||||||
|
},
|
||||||
|
"formats": [
|
||||||
|
"camelCase",
|
||||||
|
"CONSTANT_CASE",
|
||||||
|
"PascalCase",
|
||||||
|
"snake_case"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"selector": {
|
||||||
|
"kind": "objectLiteralProperty",
|
||||||
|
"scope": "any"
|
||||||
|
},
|
||||||
|
"formats": [
|
||||||
|
"camelCase",
|
||||||
|
"CONSTANT_CASE",
|
||||||
|
"PascalCase",
|
||||||
|
"snake_case"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nursery": {
|
||||||
|
"noDuplicateElseIf": "warn",
|
||||||
|
"noDuplicateJsonKeys": "warn",
|
||||||
|
"noEvolvingTypes": "warn",
|
||||||
|
"noYodaExpression": "warn",
|
||||||
|
"useConsistentBuiltinInstantiation": "warn",
|
||||||
|
"useErrorMessage": "warn",
|
||||||
|
"useImportExtensions": "off",
|
||||||
|
"useThrowNewError": "warn"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"ignore": ["node_modules/**/*", "dist/**/*", ".output", ".nuxt"]
|
"ignore": ["node_modules/**/*", "dist/**/*", ".output", ".nuxt"]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -121,15 +121,17 @@ onMounted(() => {
|
||||||
useListen("composer:reply", (note: Status) => {
|
useListen("composer:reply", (note: Status) => {
|
||||||
respondingTo.value = note;
|
respondingTo.value = note;
|
||||||
respondingType.value = "reply";
|
respondingType.value = "reply";
|
||||||
if (note.account.id !== identity.value?.account.id)
|
if (note.account.id !== identity.value?.account.id) {
|
||||||
content.value = `@${note.account.acct} `;
|
content.value = `@${note.account.acct} `;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
useListen("composer:quote", (note: Status) => {
|
useListen("composer:quote", (note: Status) => {
|
||||||
respondingTo.value = note;
|
respondingTo.value = note;
|
||||||
respondingType.value = "quote";
|
respondingType.value = "quote";
|
||||||
if (note.account.id !== identity.value?.account.id)
|
if (note.account.id !== identity.value?.account.id) {
|
||||||
content.value = `@${note.account.acct} `;
|
content.value = `@${note.account.acct} `;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
useListen("composer:edit", async (note: Status) => {
|
useListen("composer:edit", async (note: Status) => {
|
||||||
|
|
@ -176,7 +178,7 @@ const client = useClient();
|
||||||
|
|
||||||
const send = async () => {
|
const send = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
if (!identity.value || !client.value) {
|
if (!(identity.value && client.value)) {
|
||||||
throw new Error("Not authenticated");
|
throw new Error("Not authenticated");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,9 @@ const { Tab, ArrowRight, ArrowLeft, Enter } = useMagicKeys({
|
||||||
if (
|
if (
|
||||||
["Tab", "Enter", "ArrowRight", "ArrowLeft"].includes(e.key) &&
|
["Tab", "Enter", "ArrowRight", "ArrowLeft"].includes(e.key) &&
|
||||||
topEmojis.value !== null
|
topEmojis.value !== null
|
||||||
)
|
) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const identity = useCurrentIdentity();
|
const identity = useCurrentIdentity();
|
||||||
|
|
@ -34,9 +35,11 @@ const topEmojis = ref<Emoji[] | null>(null);
|
||||||
const selectedEmojiIndex = ref<number | null>(null);
|
const selectedEmojiIndex = ref<number | null>(null);
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
if (!identity.value) return;
|
if (!identity.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (props.currentlyTypingEmoji !== null)
|
if (props.currentlyTypingEmoji !== null) {
|
||||||
topEmojis.value = identity.value.emojis
|
topEmojis.value = identity.value.emojis
|
||||||
.map((emoji) => ({
|
.map((emoji) => ({
|
||||||
...emoji,
|
...emoji,
|
||||||
|
|
@ -47,7 +50,9 @@ watchEffect(() => {
|
||||||
}))
|
}))
|
||||||
.sort((a, b) => a.distance - b.distance)
|
.sort((a, b) => a.distance - b.distance)
|
||||||
.slice(0, 20);
|
.slice(0, 20);
|
||||||
else topEmojis.value = null;
|
} else {
|
||||||
|
topEmojis.value = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (ArrowRight?.value && topEmojis.value !== null) {
|
if (ArrowRight?.value && topEmojis.value !== null) {
|
||||||
selectedEmojiIndex.value = (selectedEmojiIndex.value ?? -1) + 1;
|
selectedEmojiIndex.value = (selectedEmojiIndex.value ?? -1) + 1;
|
||||||
|
|
@ -74,7 +79,9 @@ watchEffect(() => {
|
||||||
|
|
||||||
if ((Tab?.value || Enter?.value) && topEmojis.value !== null) {
|
if ((Tab?.value || Enter?.value) && topEmojis.value !== null) {
|
||||||
const emoji = topEmojis.value[selectedEmojiIndex.value ?? 0];
|
const emoji = topEmojis.value[selectedEmojiIndex.value ?? 0];
|
||||||
if (emoji) emit("autocomplete", emoji.shortcode);
|
if (emoji) {
|
||||||
|
emit("autocomplete", emoji.shortcode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,9 @@ watch(
|
||||||
files,
|
files,
|
||||||
(newFiles) => {
|
(newFiles) => {
|
||||||
for (const data of 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) => {
|
const getIcon = (mimeType: string) => {
|
||||||
if (mimeType.startsWith("image/")) return "tabler:photo";
|
if (mimeType.startsWith("image/")) {
|
||||||
if (mimeType.startsWith("video/")) return "tabler:video";
|
return "tabler:photo";
|
||||||
if (mimeType.startsWith("audio/")) return "tabler:music";
|
}
|
||||||
|
if (mimeType.startsWith("video/")) {
|
||||||
|
return "tabler:video";
|
||||||
|
}
|
||||||
|
if (mimeType.startsWith("audio/")) {
|
||||||
|
return "tabler:music";
|
||||||
|
}
|
||||||
return "tabler:file";
|
return "tabler:file";
|
||||||
};
|
};
|
||||||
|
|
||||||
const formatBytes = (bytes: number) => {
|
const formatBytes = (bytes: number) => {
|
||||||
if (bytes === 0) return "0 Bytes";
|
if (bytes === 0) {
|
||||||
|
return "0 Bytes";
|
||||||
|
}
|
||||||
const k = 1000;
|
const k = 1000;
|
||||||
const dm = 2;
|
const dm = 2;
|
||||||
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,9 @@ const { Tab, ArrowRight, ArrowLeft, Enter } = useMagicKeys({
|
||||||
if (
|
if (
|
||||||
["Tab", "Enter", "ArrowRight", "ArrowLeft"].includes(e.key) &&
|
["Tab", "Enter", "ArrowRight", "ArrowLeft"].includes(e.key) &&
|
||||||
topUsers.value !== null
|
topUsers.value !== null
|
||||||
)
|
) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const topUsers = ref<Account[] | null>(null);
|
const topUsers = ref<Account[] | null>(null);
|
||||||
|
|
@ -79,7 +80,9 @@ watch(
|
||||||
|
|
||||||
if ((Tab?.value || Enter?.value) && topUsers.value !== null) {
|
if ((Tab?.value || Enter?.value) && topUsers.value !== null) {
|
||||||
const user = topUsers.value[selectedUserIndex.value ?? 0];
|
const user = topUsers.value[selectedUserIndex.value ?? 0];
|
||||||
if (user) emit("autocomplete", user.username);
|
if (user) {
|
||||||
|
emit("autocomplete", user.username);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,9 @@ useListen("note:edit", async (note) => {
|
||||||
useEvent("composer:edit", note);
|
useEvent("composer:edit", note);
|
||||||
});
|
});
|
||||||
useListen("composer:open", () => {
|
useListen("composer:open", () => {
|
||||||
if (identity.value) open.value = true;
|
if (identity.value) {
|
||||||
|
open.value = true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
useListen("composer:close", () => {
|
useListen("composer:close", () => {
|
||||||
open.value = false;
|
open.value = false;
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,9 @@ const save = async () => {
|
||||||
type: "success",
|
type: "success",
|
||||||
});
|
});
|
||||||
|
|
||||||
if (identity.value) identity.value.account = data;
|
if (identity.value) {
|
||||||
|
identity.value.account = data;
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const error = e as ResponseError<{ error: string }>;
|
const error = e as ResponseError<{ error: string }>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ const signIn = async () => {
|
||||||
const signOut = async (id?: string) => {
|
const signOut = async (id?: string) => {
|
||||||
loadingAuth.value = true;
|
loadingAuth.value = true;
|
||||||
|
|
||||||
if (!appData.value || !identity.value) {
|
if (!(appData.value && identity.value)) {
|
||||||
console.error("No app or identity data to sign out");
|
console.error("No app or identity data to sign out");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -208,7 +208,9 @@ const signOut = async (id?: string) => {
|
||||||
identityToRevoke.tokens.access_token,
|
identityToRevoke.tokens.access_token,
|
||||||
identityToRevoke.tokens.access_token,
|
identityToRevoke.tokens.access_token,
|
||||||
)
|
)
|
||||||
.catch(() => {});
|
.catch(() => {
|
||||||
|
// Do nothing
|
||||||
|
});
|
||||||
|
|
||||||
if (id === identity.value.id) {
|
if (id === identity.value.id) {
|
||||||
identity.value = null;
|
identity.value = null;
|
||||||
|
|
|
||||||
|
|
@ -41,10 +41,11 @@ const calculatedWidth = computed(
|
||||||
|
|
||||||
const getWidth = (index: number, lines: number) => {
|
const getWidth = (index: number, lines: number) => {
|
||||||
if (isWidthSpecified.value) {
|
if (isWidthSpecified.value) {
|
||||||
if (isContent.value)
|
if (isContent.value) {
|
||||||
return index === lines
|
return index === lines
|
||||||
? `${calculatedWidth.value}${props.widthUnit}`
|
? `${calculatedWidth.value}${props.widthUnit}`
|
||||||
: "100%";
|
: "100%";
|
||||||
|
}
|
||||||
return `${calculatedWidth.value}${props.widthUnit}`;
|
return `${calculatedWidth.value}${props.widthUnit}`;
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,9 @@ const openLightbox = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const formatBytes = (bytes: number) => {
|
const formatBytes = (bytes: number) => {
|
||||||
if (bytes === 0) return "0 Bytes";
|
if (bytes === 0) {
|
||||||
|
return "0 Bytes";
|
||||||
|
}
|
||||||
const k = 1000;
|
const k = 1000;
|
||||||
const dm = 2;
|
const dm = 2;
|
||||||
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,9 @@ const numberFormat = (number = 0) =>
|
||||||
}).format(number);
|
}).format(number);
|
||||||
|
|
||||||
const likeFn = async () => {
|
const likeFn = async () => {
|
||||||
if (!outputtedNote.value) return;
|
if (!outputtedNote.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (outputtedNote.value.favourited) {
|
if (outputtedNote.value.favourited) {
|
||||||
const output = await client.value.unfavouriteStatus(
|
const output = await client.value.unfavouriteStatus(
|
||||||
outputtedNote.value.id,
|
outputtedNote.value.id,
|
||||||
|
|
@ -227,7 +229,9 @@ const likeFn = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const reblogFn = async () => {
|
const reblogFn = async () => {
|
||||||
if (!outputtedNote.value) return;
|
if (!outputtedNote.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (outputtedNote.value?.reblogged) {
|
if (outputtedNote.value?.reblogged) {
|
||||||
const output = await client.value.unreblogStatus(
|
const output = await client.value.unreblogStatus(
|
||||||
outputtedNote.value.id,
|
outputtedNote.value.id,
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,9 @@ const { relationship } = useRelationship(
|
||||||
);
|
);
|
||||||
|
|
||||||
const acceptFollowRequest = async () => {
|
const acceptFollowRequest = async () => {
|
||||||
if (!props.notification?.account) return;
|
if (!props.notification?.account) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
isWorkingOnFollowRequest.value = true;
|
isWorkingOnFollowRequest.value = true;
|
||||||
const { data } = await client.value.acceptFollowRequest(
|
const { data } = await client.value.acceptFollowRequest(
|
||||||
props.notification.account.id,
|
props.notification.account.id,
|
||||||
|
|
@ -53,7 +55,9 @@ const acceptFollowRequest = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const rejectFollowRequest = async () => {
|
const rejectFollowRequest = async () => {
|
||||||
if (!props.notification?.account) return;
|
if (!props.notification?.account) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
isWorkingOnFollowRequest.value = true;
|
isWorkingOnFollowRequest.value = true;
|
||||||
const { data } = await client.value.rejectFollowRequest(
|
const { data } = await client.value.rejectFollowRequest(
|
||||||
props.notification.account.id,
|
props.notification.account.id,
|
||||||
|
|
@ -69,7 +73,9 @@ const { display_name } = useParsedAccount(
|
||||||
);
|
);
|
||||||
|
|
||||||
const text = computed(() => {
|
const text = computed(() => {
|
||||||
if (!props.notification) return "";
|
if (!props.notification) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
switch (props.notification.type) {
|
switch (props.notification.type) {
|
||||||
case "mention":
|
case "mention":
|
||||||
|
|
@ -82,13 +88,16 @@ const text = computed(() => {
|
||||||
return "followed you";
|
return "followed you";
|
||||||
case "follow_request":
|
case "follow_request":
|
||||||
return "requested to follow you";
|
return "requested to follow you";
|
||||||
default:
|
default: {
|
||||||
console.error("Unknown notification type", props.notification.type);
|
console.error("Unknown notification type", props.notification.type);
|
||||||
return "";
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const icon = computed(() => {
|
const icon = computed(() => {
|
||||||
if (!props.notification) return "";
|
if (!props.notification) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
switch (props.notification.type) {
|
switch (props.notification.type) {
|
||||||
case "mention":
|
case "mention":
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,9 @@ const accountId = computed(() => props.account?.id ?? null);
|
||||||
const { relationship, isLoading } = useRelationship(client, accountId);
|
const { relationship, isLoading } = useRelationship(client, accountId);
|
||||||
|
|
||||||
const follow = () => {
|
const follow = () => {
|
||||||
if (!identity.value || !props.account || !relationship.value) return;
|
if (!(identity.value && props.account && relationship.value)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
relationship.value = {
|
relationship.value = {
|
||||||
...relationship.value,
|
...relationship.value,
|
||||||
following: true,
|
following: true,
|
||||||
|
|
@ -120,7 +122,9 @@ const follow = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const unfollow = () => {
|
const unfollow = () => {
|
||||||
if (!identity.value || !props.account || !relationship.value) return;
|
if (!(identity.value && props.account && relationship.value)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
relationship.value = {
|
relationship.value = {
|
||||||
...relationship.value,
|
...relationship.value,
|
||||||
following: false,
|
following: false,
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,9 @@ watch(
|
||||||
() => props.timeline,
|
() => props.timeline,
|
||||||
(newTimeline, oldTimeline) => {
|
(newTimeline, oldTimeline) => {
|
||||||
// If posts are deleted, don't start loading more posts
|
// 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;
|
isLoading.value = false;
|
||||||
// If less than NOTES_PER_PAGE statuses are returned, we have reached the end
|
// If less than NOTES_PER_PAGE statuses are returned, we have reached the end
|
||||||
if (
|
if (
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,13 @@ export const useAccount = (
|
||||||
const output = ref(null as Account | null);
|
const output = ref(null as Account | null);
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
if (toValue(accountId))
|
if (toValue(accountId)) {
|
||||||
toValue(client)
|
toValue(client)
|
||||||
?.getAccount(toValue(accountId) ?? "")
|
?.getAccount(toValue(accountId) ?? "")
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
output.value = res.data;
|
output.value = res.data;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,9 @@ import type { RolePermission } from "@lysand-org/client/types";
|
||||||
import { useCurrentIdentity } from "./Identities";
|
import { useCurrentIdentity } from "./Identities";
|
||||||
|
|
||||||
export const useCacheRefresh = (client: MaybeRef<LysandClient | null>) => {
|
export const useCacheRefresh = (client: MaybeRef<LysandClient | null>) => {
|
||||||
if (import.meta.server) return;
|
if (import.meta.server) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const identity = useCurrentIdentity();
|
const identity = useCurrentIdentity();
|
||||||
|
|
||||||
|
|
@ -14,7 +16,9 @@ export const useCacheRefresh = (client: MaybeRef<LysandClient | null>) => {
|
||||||
toValue(client)
|
toValue(client)
|
||||||
?.verifyAccountCredentials()
|
?.verifyAccountCredentials()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (identity.value) identity.value.account = res.data;
|
if (identity.value) {
|
||||||
|
identity.value.account = res.data;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
const code = err.response.status;
|
const code = err.response.status;
|
||||||
|
|
@ -34,7 +38,9 @@ export const useCacheRefresh = (client: MaybeRef<LysandClient | null>) => {
|
||||||
toValue(client)
|
toValue(client)
|
||||||
?.getInstanceCustomEmojis()
|
?.getInstanceCustomEmojis()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (identity.value) identity.value.emojis = res.data;
|
if (identity.value) {
|
||||||
|
identity.value.emojis = res.data;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
toValue(client)
|
toValue(client)
|
||||||
|
|
@ -47,16 +53,19 @@ export const useCacheRefresh = (client: MaybeRef<LysandClient | null>) => {
|
||||||
.flatMap((r) => r.permissions)
|
.flatMap((r) => r.permissions)
|
||||||
.filter((p, i, arr) => arr.indexOf(p) === i);
|
.filter((p, i, arr) => arr.indexOf(p) === i);
|
||||||
|
|
||||||
if (identity.value)
|
if (identity.value) {
|
||||||
identity.value.permissions =
|
identity.value.permissions =
|
||||||
permissions as unknown as RolePermission[];
|
permissions as unknown as RolePermission[];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
toValue(client)
|
toValue(client)
|
||||||
?.getInstance()
|
?.getInstance()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (identity.value) identity.value.instance = res.data;
|
if (identity.value) {
|
||||||
|
identity.value.instance = res.data;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -45,12 +45,15 @@ export const useCurrentIdentity = (): Ref<Identity | null> => {
|
||||||
if (newCurrent) {
|
if (newCurrent) {
|
||||||
currentId.value = newCurrent.id;
|
currentId.value = newCurrent.id;
|
||||||
// If the identity is updated, update the identity in the list
|
// If the identity is updated, update the identity in the list
|
||||||
if (identities.value.find((i) => i.id === newCurrent.id))
|
if (identities.value.find((i) => i.id === newCurrent.id)) {
|
||||||
identities.value = identities.value.map((i) =>
|
identities.value = identities.value.map((i) =>
|
||||||
i.id === newCurrent.id ? newCurrent : i,
|
i.id === newCurrent.id ? newCurrent : i,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
// If the identity is not in the list, add it
|
// If the identity is not in the list, add it
|
||||||
else identities.value.push(newCurrent);
|
else {
|
||||||
|
identities.value.push(newCurrent);
|
||||||
|
}
|
||||||
|
|
||||||
// Force update the identities
|
// Force update the identities
|
||||||
identities.value = [...identities.value];
|
identities.value = [...identities.value];
|
||||||
|
|
|
||||||
|
|
@ -3,84 +3,21 @@ import type { Status } from "@lysand-org/client/types";
|
||||||
|
|
||||||
export const useLocalTimeline = (
|
export const useLocalTimeline = (
|
||||||
client: LysandClient | null,
|
client: LysandClient | null,
|
||||||
options: MaybeRef<
|
options: MaybeRef<{
|
||||||
Partial<{
|
only_media: boolean;
|
||||||
only_media: boolean;
|
max_id: string;
|
||||||
max_id: string;
|
since_id: string;
|
||||||
since_id: string;
|
min_id: string;
|
||||||
min_id: string;
|
limit: number;
|
||||||
limit: number;
|
}>,
|
||||||
}>
|
|
||||||
>,
|
|
||||||
): {
|
): {
|
||||||
timeline: Ref<Status[]>;
|
timeline: Ref<Status[]>;
|
||||||
loadNext: () => Promise<void>;
|
loadNext: () => Promise<void>;
|
||||||
loadPrev: () => Promise<void>;
|
loadPrev: () => Promise<void>;
|
||||||
} => {
|
} => {
|
||||||
if (!client) {
|
return useTimeline(
|
||||||
return {
|
client,
|
||||||
timeline: ref([]),
|
(client, options) => client?.getLocalTimeline(options),
|
||||||
loadNext: async () => {},
|
options,
|
||||||
loadPrev: async () => {},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const fetchedNotes = ref<Status[]>([]);
|
|
||||||
const fetchedNoteIds = new Set<string>();
|
|
||||||
let nextMaxId: string | undefined = undefined;
|
|
||||||
let prevMinId: string | undefined = undefined;
|
|
||||||
|
|
||||||
const loadNext = async () => {
|
|
||||||
const response = await client.getLocalTimeline({
|
|
||||||
...ref(options).value,
|
|
||||||
max_id: nextMaxId,
|
|
||||||
limit: useConfig().NOTES_PER_PAGE,
|
|
||||||
});
|
|
||||||
|
|
||||||
const newNotes = response.data.filter(
|
|
||||||
(note) => !fetchedNoteIds.has(note.id),
|
|
||||||
);
|
|
||||||
if (newNotes.length > 0) {
|
|
||||||
fetchedNotes.value = [...fetchedNotes.value, ...newNotes];
|
|
||||||
nextMaxId = newNotes[newNotes.length - 1]?.id;
|
|
||||||
for (const note of newNotes) {
|
|
||||||
fetchedNoteIds.add(note.id);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
nextMaxId = undefined;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const loadPrev = async () => {
|
|
||||||
const response = await client.getLocalTimeline({
|
|
||||||
...ref(options).value,
|
|
||||||
min_id: prevMinId,
|
|
||||||
limit: useConfig().NOTES_PER_PAGE,
|
|
||||||
});
|
|
||||||
|
|
||||||
const newNotes = response.data.filter(
|
|
||||||
(note) => !fetchedNoteIds.has(note.id),
|
|
||||||
);
|
|
||||||
if (newNotes.length > 0) {
|
|
||||||
fetchedNotes.value = [...newNotes, ...fetchedNotes.value];
|
|
||||||
prevMinId = newNotes[0]?.id;
|
|
||||||
for (const note of newNotes) {
|
|
||||||
fetchedNoteIds.add(note.id);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
prevMinId = undefined;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => ref(options).value,
|
|
||||||
async ({ max_id, min_id }) => {
|
|
||||||
nextMaxId = max_id;
|
|
||||||
prevMinId = min_id;
|
|
||||||
await loadNext();
|
|
||||||
},
|
|
||||||
{ immediate: true },
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return { timeline: fetchedNotes, loadNext, loadPrev };
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,13 @@ export const useNoteContext = (
|
||||||
const output = ref(null as Context | null);
|
const output = ref(null as Context | null);
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
if (toValue(noteId))
|
if (toValue(noteId)) {
|
||||||
ref(client)
|
ref(client)
|
||||||
.value?.getStatusContext(toValue(noteId) ?? "")
|
.value?.getStatusContext(toValue(noteId) ?? "")
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
output.value = res.data;
|
output.value = res.data;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,7 @@ export const useNoteData = (
|
||||||
const shouldHide = computed(
|
const shouldHide = computed(
|
||||||
() =>
|
() =>
|
||||||
(renderedNote.value?.sensitive ||
|
(renderedNote.value?.sensitive ||
|
||||||
!!renderedNote.value?.spoiler_text ||
|
!!renderedNote.value?.spoiler_text) &&
|
||||||
false) &&
|
|
||||||
(showContentWarning.value.value as boolean),
|
(showContentWarning.value.value as boolean),
|
||||||
);
|
);
|
||||||
const mentions = useResolveMentions(
|
const mentions = useResolveMentions(
|
||||||
|
|
|
||||||
|
|
@ -89,13 +89,13 @@ export const useParsedAccount = (
|
||||||
account: MaybeRef<Account | undefined | null>,
|
account: MaybeRef<Account | undefined | null>,
|
||||||
settings: MaybeRef<Settings>,
|
settings: MaybeRef<Settings>,
|
||||||
) => {
|
) => {
|
||||||
const display_name = computed(() => toValue(account)?.display_name ?? "");
|
const displayName = computed(() => toValue(account)?.display_name ?? "");
|
||||||
const note = computed(() => toValue(account)?.note ?? "");
|
const note = computed(() => toValue(account)?.note ?? "");
|
||||||
const fields = computed(() => toValue(account)?.fields ?? []);
|
const fields = computed(() => toValue(account)?.fields ?? []);
|
||||||
const emojis = computed(() => toValue(account)?.emojis ?? []);
|
const emojis = computed(() => toValue(account)?.emojis ?? []);
|
||||||
|
|
||||||
const parsedDisplayName = useParsedContent(
|
const parsedDisplayName = useParsedContent(
|
||||||
display_name,
|
displayName,
|
||||||
emojis,
|
emojis,
|
||||||
undefined,
|
undefined,
|
||||||
settings,
|
settings,
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,13 @@ export const useRelationship = (
|
||||||
}
|
}
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
if (toValue(accountId))
|
if (toValue(accountId)) {
|
||||||
toValue(client)
|
toValue(client)
|
||||||
?.getRelationship(toValue(accountId) ?? "")
|
?.getRelationship(toValue(accountId) ?? "")
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
relationship.value = res.data;
|
relationship.value = res.data;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(relationship, (newOutput, oldOutput) => {
|
watch(relationship, (newOutput, oldOutput) => {
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,15 @@ export const useTimeline = <
|
||||||
loadNext: () => Promise<void>;
|
loadNext: () => Promise<void>;
|
||||||
loadPrev: () => Promise<void>;
|
loadPrev: () => Promise<void>;
|
||||||
} => {
|
} => {
|
||||||
if (!client || !fetchTimeline) {
|
if (!(client && fetchTimeline)) {
|
||||||
return {
|
return {
|
||||||
timeline: ref([]),
|
timeline: ref([]),
|
||||||
loadNext: async () => {},
|
loadNext: async () => {
|
||||||
loadPrev: async () => {},
|
// ...
|
||||||
|
},
|
||||||
|
loadPrev: async () => {
|
||||||
|
// ...
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -107,11 +111,15 @@ export const useIdTimeline = <
|
||||||
loadNext: () => Promise<void>;
|
loadNext: () => Promise<void>;
|
||||||
loadPrev: () => Promise<void>;
|
loadPrev: () => Promise<void>;
|
||||||
} => {
|
} => {
|
||||||
if (!client || !fetchTimeline) {
|
if (!(client && fetchTimeline)) {
|
||||||
return {
|
return {
|
||||||
timeline: ref([]),
|
timeline: ref([]),
|
||||||
loadNext: async () => {},
|
loadNext: async () => {
|
||||||
loadPrev: async () => {},
|
// ...
|
||||||
|
},
|
||||||
|
loadPrev: async () => {
|
||||||
|
// ...
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,12 @@ const loaded = computed(() => note.value !== null && context.value !== null);
|
||||||
watch(
|
watch(
|
||||||
[() => context.value?.ancestors, loaded],
|
[() => context.value?.ancestors, loaded],
|
||||||
async () => {
|
async () => {
|
||||||
if (context.value?.ancestors.length === 0) return;
|
if (context.value?.ancestors.length === 0) {
|
||||||
if (!loaded.value) return;
|
return;
|
||||||
|
}
|
||||||
|
if (!loaded.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
await nextTick();
|
await nextTick();
|
||||||
// Wait for 200ms
|
// Wait for 200ms
|
||||||
await new Promise((resolve) => setTimeout(resolve, 200));
|
await new Promise((resolve) => setTimeout(resolve, 200));
|
||||||
|
|
|
||||||
|
|
@ -111,14 +111,14 @@ const hostname = useRequestURL().hostname;
|
||||||
const query = new URLSearchParams(
|
const query = new URLSearchParams(
|
||||||
window?.location.search ?? useRequestURL().search,
|
window?.location.search ?? useRequestURL().search,
|
||||||
);
|
);
|
||||||
const redirect_uri = query.get("redirect_uri");
|
const redirectUri = query.get("redirect_uri");
|
||||||
const response_type = query.get("response_type");
|
const responseType = query.get("response_type");
|
||||||
const client_id = query.get("client_id");
|
const clientId = query.get("client_id");
|
||||||
const scope = query.get("scope");
|
const scope = query.get("scope");
|
||||||
const error = query.get("error");
|
const error = query.get("error");
|
||||||
const error_description = query.get("error_description");
|
const errorDescription = query.get("error_description");
|
||||||
|
|
||||||
const validUrlParameters = redirect_uri && response_type && client_id && scope;
|
const validUrlParameters = redirectUri && responseType && clientId && scope;
|
||||||
|
|
||||||
const ssoConfig = useSSOConfig();
|
const ssoConfig = useSSOConfig();
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -92,11 +92,11 @@ const application = query.application;
|
||||||
const website = query.website
|
const website = query.website
|
||||||
? decodeURIComponent(query.website as string)
|
? decodeURIComponent(query.website as string)
|
||||||
: null;
|
: null;
|
||||||
const redirect_uri = query.redirect_uri as string;
|
const redirectUri = query.redirect_uri as string;
|
||||||
const client_id = query.client_id;
|
const clientId = query.client_id;
|
||||||
const scope = query.scope ? decodeURIComponent(query.scope as string) : "";
|
const scope = query.scope ? decodeURIComponent(query.scope as string) : "";
|
||||||
|
|
||||||
const validUrlParameters = application && redirect_uri && client_id && scope;
|
const validUrlParameters = application && redirectUri && clientId && scope;
|
||||||
|
|
||||||
const oauthScopeText: Record<string, string> = {
|
const oauthScopeText: Record<string, string> = {
|
||||||
"rw:accounts": "$VERB your account information",
|
"rw:accounts": "$VERB your account information",
|
||||||
|
|
@ -123,7 +123,7 @@ const scopes = scope.split(" ");
|
||||||
// Return an array of strings to display
|
// Return an array of strings to display
|
||||||
// "read write:accounts" returns all the fields with $VERB as read, plus the accounts field with $VERB as write
|
// "read write:accounts" returns all the fields with $VERB as read, plus the accounts field with $VERB as write
|
||||||
const getScopeText = (fullScopes: string[]) => {
|
const getScopeText = (fullScopes: string[]) => {
|
||||||
const scopeTexts = [];
|
const scopeTexts: string[][] = [];
|
||||||
|
|
||||||
const readScopes = fullScopes.filter((scope) => scope.includes("read"));
|
const readScopes = fullScopes.filter((scope) => scope.includes("read"));
|
||||||
const writeScopes = fullScopes.filter((scope) => scope.includes("write"));
|
const writeScopes = fullScopes.filter((scope) => scope.includes("write"));
|
||||||
|
|
@ -138,12 +138,14 @@ const getScopeText = (fullScopes: string[]) => {
|
||||||
(writeScopes.includes(`write:${scopeName}`) ||
|
(writeScopes.includes(`write:${scopeName}`) ||
|
||||||
writeScopes.find((scope) => scope === "write"))
|
writeScopes.find((scope) => scope === "write"))
|
||||||
) {
|
) {
|
||||||
if (oauthScopeText[possibleScope]?.includes("$VERB"))
|
if (oauthScopeText[possibleScope]?.includes("$VERB")) {
|
||||||
scopeTexts.push([
|
scopeTexts.push([
|
||||||
"Read and write",
|
"Read and write",
|
||||||
oauthScopeText[possibleScope]?.replace("$VERB", ""),
|
oauthScopeText[possibleScope]?.replace("$VERB", "") ?? "",
|
||||||
]);
|
]);
|
||||||
else scopeTexts.push(["", oauthScopeText[possibleScope]]);
|
} else {
|
||||||
|
scopeTexts.push(["", oauthScopeText[possibleScope] ?? ""]);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,12 +154,14 @@ const getScopeText = (fullScopes: string[]) => {
|
||||||
(readScopes.includes(`read:${scopeName}`) ||
|
(readScopes.includes(`read:${scopeName}`) ||
|
||||||
readScopes.find((scope) => scope === "read"))
|
readScopes.find((scope) => scope === "read"))
|
||||||
) {
|
) {
|
||||||
if (oauthScopeText[possibleScope]?.includes("$VERB"))
|
if (oauthScopeText[possibleScope]?.includes("$VERB")) {
|
||||||
scopeTexts.push([
|
scopeTexts.push([
|
||||||
"Read",
|
"Read",
|
||||||
oauthScopeText[possibleScope]?.replace("$VERB", ""),
|
oauthScopeText[possibleScope]?.replace("$VERB", "") ?? "",
|
||||||
]);
|
]);
|
||||||
else scopeTexts.push(["", oauthScopeText[possibleScope]]);
|
} else {
|
||||||
|
scopeTexts.push(["", oauthScopeText[possibleScope] ?? ""]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
@ -165,12 +169,14 @@ const getScopeText = (fullScopes: string[]) => {
|
||||||
(writeScopes.includes(`write:${scopeName}`) ||
|
(writeScopes.includes(`write:${scopeName}`) ||
|
||||||
writeScopes.find((scope) => scope === "write"))
|
writeScopes.find((scope) => scope === "write"))
|
||||||
) {
|
) {
|
||||||
if (oauthScopeText[possibleScope]?.includes("$VERB"))
|
if (oauthScopeText[possibleScope]?.includes("$VERB")) {
|
||||||
scopeTexts.push([
|
scopeTexts.push([
|
||||||
"Write",
|
"Write",
|
||||||
oauthScopeText[possibleScope]?.replace("$VERB", ""),
|
oauthScopeText[possibleScope]?.replace("$VERB", "") ?? "",
|
||||||
]);
|
]);
|
||||||
else scopeTexts.push(["", oauthScopeText[possibleScope]]);
|
} else {
|
||||||
|
scopeTexts.push(["", oauthScopeText[possibleScope] ?? ""]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return scopeTexts;
|
return scopeTexts;
|
||||||
|
|
|
||||||
|
|
@ -99,14 +99,14 @@ const query = new URLSearchParams(
|
||||||
window?.location.search ?? useRequestURL().search,
|
window?.location.search ?? useRequestURL().search,
|
||||||
);
|
);
|
||||||
const token = query.get("token");
|
const token = query.get("token");
|
||||||
const login_reset = query.get("login_reset") === "true";
|
const loginReset = query.get("login_reset") === "true";
|
||||||
const success = query.get("success") === "true";
|
const success = query.get("success") === "true";
|
||||||
let error = query.get("error");
|
let error = query.get("error");
|
||||||
let error_description = query.get("error_description");
|
let errorDescription = query.get("error_description");
|
||||||
|
|
||||||
if (login_reset) {
|
if (loginReset) {
|
||||||
error = "Login reset";
|
error = "Login reset";
|
||||||
error_description =
|
errorDescription =
|
||||||
"Your password has been reset by an administrator. Please change it here.";
|
"Your password has been reset by an administrator. Please change it here.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<ButtonsPrimary type="submit" class="w-full" :disabled="isLoading">{{ isLoading ? "Registering..." :
|
<ButtonsPrimary type="submit" class="w-full" :disabled="isLoading">{{ isLoading ? "Registering..." :
|
||||||
"Register" }}</ButtonsPrimary>
|
"Register" }}</ButtonsPrimary>
|
||||||
</VeeForm>
|
</VeeForm>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
|
|
@ -158,10 +158,10 @@ const register = (result: {
|
||||||
"en",
|
"en",
|
||||||
result.reason || "Empty reason",
|
result.reason || "Empty reason",
|
||||||
)
|
)
|
||||||
.then(async () => {
|
.then(() => {
|
||||||
navigateTo("/register/success");
|
navigateTo("/register/success");
|
||||||
})
|
})
|
||||||
.catch(async (e) => {
|
.catch((e) => {
|
||||||
const error = e as ResponseError<{
|
const error = e as ResponseError<{
|
||||||
error: string;
|
error: string;
|
||||||
}>;
|
}>;
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ export const parseFromJson = (json: Record<string, unknown>) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export enum SettingIds {
|
export enum SettingIds {
|
||||||
MFM = "mfm",
|
Mfm = "mfm",
|
||||||
CustomCSS = "custom-css",
|
CustomCSS = "custom-css",
|
||||||
Theme = "theme",
|
Theme = "theme",
|
||||||
CustomEmojis = "custom-emojis",
|
CustomEmojis = "custom-emojis",
|
||||||
|
|
@ -73,7 +73,7 @@ export enum SettingIds {
|
||||||
|
|
||||||
export const settings = [
|
export const settings = [
|
||||||
{
|
{
|
||||||
id: SettingIds.MFM,
|
id: SettingIds.Mfm,
|
||||||
title: "Render MFM",
|
title: "Render MFM",
|
||||||
description: "Render Misskey-Flavoured Markdown",
|
description: "Render Misskey-Flavoured Markdown",
|
||||||
type: SettingType.Boolean,
|
type: SettingType.Boolean,
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ export const signInWithCode = (code: string, appData: ApplicationData) => {
|
||||||
!identities.value.find(
|
!identities.value.find(
|
||||||
(i) => i.account.id === accountOutput.data.id,
|
(i) => i.account.id === accountOutput.data.id,
|
||||||
)
|
)
|
||||||
)
|
) {
|
||||||
identity.value = {
|
identity.value = {
|
||||||
id: nanoid(),
|
id: nanoid(),
|
||||||
tokens: res.data,
|
tokens: res.data,
|
||||||
|
|
@ -35,6 +35,7 @@ export const signInWithCode = (code: string, appData: ApplicationData) => {
|
||||||
permissions: [],
|
permissions: [],
|
||||||
emojis: [],
|
emojis: [],
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Remove code from URL
|
// Remove code from URL
|
||||||
window.history.replaceState(
|
window.history.replaceState(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue