mirror of
https://github.com/versia-pub/frontend.git
synced 2026-03-13 03:29:16 +01:00
refactor: ⬆️ Update @lysand-org/client to 0.2.0, use its types instead
This commit is contained in:
parent
cd1fb48b68
commit
8a984abfb2
75 changed files with 63 additions and 640 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import type { LysandClient } from "@lysand-org/client";
|
||||
import type { Account } from "~/types/mastodon/account";
|
||||
import type { Account } from "@lysand-org/client/types";
|
||||
|
||||
export const useAccount = (
|
||||
client: MaybeRef<LysandClient | null>,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { LysandClient } from "@lysand-org/client";
|
||||
import type { Account } from "~/types/mastodon/account";
|
||||
import type { Account } from "@lysand-org/client/types";
|
||||
|
||||
export const useAccountSearch = (
|
||||
client: MaybeRef<LysandClient | null>,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { LysandClient } from "@lysand-org/client";
|
||||
import type { Status } from "~/types/mastodon/status";
|
||||
import type { Status } from "@lysand-org/client/types";
|
||||
|
||||
export const useAccountTimeline = (
|
||||
client: LysandClient | null,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
import type { LysandClient } from "@lysand-org/client";
|
||||
import type { ApplicationData } from "@lysand-org/client/types";
|
||||
import { StorageSerializers } from "@vueuse/core";
|
||||
|
||||
export type ApplicationData = Awaited<
|
||||
ReturnType<LysandClient["createApp"]>
|
||||
>["data"];
|
||||
|
||||
export const useAppData = () => {
|
||||
return useLocalStorage<ApplicationData | null>("lysand:app_data", null, {
|
||||
serializer: StorageSerializers.object,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import type { LysandClient } from "@lysand-org/client";
|
||||
import { type RolePermissions, useCurrentIdentity } from "./Identities";
|
||||
import type { RolePermission } from "@lysand-org/client/types";
|
||||
import { useCurrentIdentity } from "./Identities";
|
||||
|
||||
export const useCacheRefresh = (client: MaybeRef<LysandClient | null>) => {
|
||||
if (import.meta.server) return;
|
||||
|
|
@ -48,7 +49,7 @@ export const useCacheRefresh = (client: MaybeRef<LysandClient | null>) => {
|
|||
|
||||
if (identity.value)
|
||||
identity.value.permissions =
|
||||
permissions as unknown as RolePermissions[];
|
||||
permissions as unknown as RolePermission[];
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import type { Attachment, Status } from "@lysand-org/client/types";
|
||||
import mitt from "mitt";
|
||||
import type { Attachment } from "~/types/mastodon/attachment";
|
||||
import type { Status } from "~/types/mastodon/status";
|
||||
import type { Identity } from "./Identities";
|
||||
|
||||
export type NotificationEvent = {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { LysandClient } from "@lysand-org/client";
|
||||
import type { Status } from "~/types/mastodon/status";
|
||||
import type { Status } from "@lysand-org/client/types";
|
||||
|
||||
export const useHomeTimeline = (
|
||||
client: LysandClient | null,
|
||||
|
|
|
|||
|
|
@ -1,65 +1,19 @@
|
|||
import type { LysandClient, Token } from "@lysand-org/client";
|
||||
import type { Token } from "@lysand-org/client";
|
||||
import type {
|
||||
Account,
|
||||
Emoji,
|
||||
Instance,
|
||||
RolePermission,
|
||||
} from "@lysand-org/client/types";
|
||||
import { StorageSerializers } from "@vueuse/core";
|
||||
import type { Account } from "~/types/mastodon/account";
|
||||
import type { Instance } from "./Instance";
|
||||
|
||||
export type Role = Awaited<ReturnType<LysandClient["getRole"]>>["data"];
|
||||
export enum RolePermissions {
|
||||
MANAGE_NOTES = "notes",
|
||||
MANAGE_OWN_NOTES = "owner:note",
|
||||
VIEW_NOTES = "read:note",
|
||||
VIEW_NOTE_LIKES = "read:note_likes",
|
||||
VIEW_NOTE_BOOSTS = "read:note_boosts",
|
||||
MANAGE_ACCOUNTS = "accounts",
|
||||
MANAGE_OWN_ACCOUNT = "owner:account",
|
||||
VIEW_ACCOUNT_FOLLOWS = "read:account_follows",
|
||||
MANAGE_LIKES = "likes",
|
||||
MANAGE_OWN_LIKES = "owner:like",
|
||||
MANAGE_BOOSTS = "boosts",
|
||||
MANAGE_OWN_BOOSTS = "owner:boost",
|
||||
VIEW_ACCOUNTS = "read:account",
|
||||
MANAGE_EMOJIS = "emojis",
|
||||
VIEW_EMOJIS = "read:emoji",
|
||||
MANAGE_OWN_EMOJIS = "owner:emoji",
|
||||
MANAGE_MEDIA = "media",
|
||||
MANAGE_OWN_MEDIA = "owner:media",
|
||||
MANAGE_BLOCKS = "blocks",
|
||||
MANAGE_OWN_BLOCKS = "owner:block",
|
||||
MANAGE_FILTERS = "filters",
|
||||
MANAGE_OWN_FILTERS = "owner:filter",
|
||||
MANAGE_MUTES = "mutes",
|
||||
MANAGE_OWN_MUTES = "owner:mute",
|
||||
MANAGE_REPORTS = "reports",
|
||||
MANAGE_OWN_REPORTS = "owner:report",
|
||||
MANAGE_SETTINGS = "settings",
|
||||
MANAGE_OWN_SETTINGS = "owner:settings",
|
||||
MANAGE_ROLES = "roles",
|
||||
MANAGE_NOTIFICATIONS = "notifications",
|
||||
MANAGE_OWN_NOTIFICATIONS = "owner:notification",
|
||||
MANAGE_FOLLOWS = "follows",
|
||||
MANAGE_OWN_FOLLOWS = "owner:follow",
|
||||
MANAGE_OWN_APPS = "owner:app",
|
||||
SEARCH = "search",
|
||||
VIEW_PUBLIC_TIMELINES = "public_timelines",
|
||||
VIEW_PRIVATE_TIMELINES = "private_timelines",
|
||||
IGNORE_RATE_LIMITS = "ignore_rate_limits",
|
||||
IMPERSONATE = "impersonate",
|
||||
MANAGE_INSTANCE = "instance",
|
||||
MANAGE_INSTANCE_FEDERATION = "instance:federation",
|
||||
MANAGE_INSTANCE_SETTINGS = "instance:settings",
|
||||
OAUTH = "oauth",
|
||||
}
|
||||
export type CustomEmoji = Awaited<
|
||||
ReturnType<LysandClient["getInstanceCustomEmojis"]>
|
||||
>["data"][0];
|
||||
|
||||
export type Identity = {
|
||||
id: string;
|
||||
tokens: Token;
|
||||
account: Account;
|
||||
instance: Instance;
|
||||
permissions: RolePermissions[];
|
||||
emojis: CustomEmoji[];
|
||||
permissions: RolePermission[];
|
||||
emojis: Emoji[];
|
||||
};
|
||||
|
||||
export const useIdentities = (): Ref<Identity[]> => {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,5 @@
|
|||
import type { LysandClient } from "@lysand-org/client";
|
||||
|
||||
// Return type of LysandClient.getInstance
|
||||
export type Instance = Awaited<ReturnType<LysandClient["getInstance"]>>["data"];
|
||||
export type ExtendedDescription = Awaited<
|
||||
ReturnType<LysandClient["getInstanceExtendedDescription"]>
|
||||
>["data"];
|
||||
import type { ExtendedDescription, Instance } from "@lysand-org/client/types";
|
||||
|
||||
export const useInstance = () => {
|
||||
const identity = useCurrentIdentity();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { LysandClient } from "@lysand-org/client";
|
||||
import type { Status } from "~/types/mastodon/status";
|
||||
import type { Status } from "@lysand-org/client/types";
|
||||
|
||||
export const useLocalTimeline = (
|
||||
client: LysandClient | null,
|
||||
|
|
@ -42,7 +42,7 @@ export const useLocalTimeline = (
|
|||
);
|
||||
if (newNotes.length > 0) {
|
||||
fetchedNotes.value = [...fetchedNotes.value, ...newNotes];
|
||||
nextMaxId = newNotes[newNotes.length - 1].id;
|
||||
nextMaxId = newNotes[newNotes.length - 1]?.id;
|
||||
for (const note of newNotes) {
|
||||
fetchedNoteIds.add(note.id);
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ export const useLocalTimeline = (
|
|||
);
|
||||
if (newNotes.length > 0) {
|
||||
fetchedNotes.value = [...newNotes, ...fetchedNotes.value];
|
||||
prevMinId = newNotes[0].id;
|
||||
prevMinId = newNotes[0]?.id;
|
||||
for (const note of newNotes) {
|
||||
fetchedNoteIds.add(note.id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { LysandClient } from "@lysand-org/client";
|
||||
import type { Status } from "~/types/mastodon/status";
|
||||
import type { Status } from "@lysand-org/client/types";
|
||||
|
||||
export const useNote = (
|
||||
client: MaybeRef<LysandClient | null>,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { LysandClient } from "@lysand-org/client";
|
||||
import type { Context } from "~/types/mastodon/context";
|
||||
import type { Context } from "@lysand-org/client/types";
|
||||
|
||||
export const useNoteContext = (
|
||||
client: MaybeRef<LysandClient | null>,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type { LysandClient } from "@lysand-org/client";
|
||||
import type { Status } from "@lysand-org/client/types";
|
||||
import { SettingIds, type Settings } from "~/settings";
|
||||
import type { Status } from "~/types/mastodon/status";
|
||||
|
||||
export const useNoteData = (
|
||||
noteProp: MaybeRef<Status | undefined>,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { LysandClient } from "@lysand-org/client";
|
||||
import type { Notification } from "~/types/mastodon/notification";
|
||||
import type { Notification } from "@lysand-org/client/types";
|
||||
|
||||
export const useNotificationTimeline = (
|
||||
client: LysandClient | null,
|
||||
|
|
@ -18,6 +18,7 @@ export const useNotificationTimeline = (
|
|||
} => {
|
||||
return useTimeline(
|
||||
client,
|
||||
// @ts-expect-error dont listen to the voices jesse
|
||||
(client, options) => client?.getNotifications(options),
|
||||
options,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import type { Account, Emoji } from "@lysand-org/client/types";
|
||||
import { renderToString } from "vue/server-renderer";
|
||||
import { SettingIds, type Settings, getSettingById } from "~/settings";
|
||||
import type { Account } from "~/types/mastodon/account";
|
||||
import type { Emoji } from "~/types/mastodon/emoji";
|
||||
import MentionComponent from "../components/social-elements/notes/mention.vue";
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { LysandClient } from "@lysand-org/client";
|
||||
import type { Status } from "~/types/mastodon/status";
|
||||
import type { Status } from "@lysand-org/client/types";
|
||||
|
||||
export const usePublicTimeline = (
|
||||
client: LysandClient | null,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { LysandClient } from "@lysand-org/client";
|
||||
import type { Relationship } from "~/types/mastodon/relationship";
|
||||
import type { Relationship } from "@lysand-org/client/types";
|
||||
import { useCurrentIdentity } from "./Identities";
|
||||
|
||||
export const useRelationship = (
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import type { LysandClient } from "@lysand-org/client";
|
||||
import type { Account } from "~/types/mastodon/account";
|
||||
import type { Mention } from "~/types/mastodon/mention";
|
||||
import type { Account, Mention } from "@lysand-org/client/types";
|
||||
|
||||
export const useResolveMentions = (
|
||||
mentions: Ref<Mention[]>,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { Instance } from "./Instance";
|
||||
import type { Instance } from "@lysand-org/client/types";
|
||||
|
||||
export const useSSOConfig = (): Ref<Instance["sso"] | null> => {
|
||||
const instance = useInstance();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue