2025-05-26 11:19:15 +02:00
|
|
|
import type { Account, Attachment, Status } from "@versia/client/schemas";
|
2024-04-28 07:02:27 +02:00
|
|
|
import mitt from "mitt";
|
2025-05-26 11:19:15 +02:00
|
|
|
import type { z } from "zod";
|
2024-06-10 05:24:55 +02:00
|
|
|
import type { Identity } from "./Identities";
|
2024-04-28 07:02:27 +02:00
|
|
|
|
|
|
|
|
type ApplicationEvents = {
|
2025-05-26 11:19:15 +02:00
|
|
|
"note:reply": z.infer<typeof Status>;
|
|
|
|
|
"note:delete": z.infer<typeof Status>;
|
|
|
|
|
"note:edit": z.infer<typeof Status>;
|
|
|
|
|
"note:like": z.infer<typeof Status>;
|
|
|
|
|
"note:unlike": z.infer<typeof Status>;
|
|
|
|
|
"note:reblog": z.infer<typeof Status>;
|
|
|
|
|
"note:unreblog": z.infer<typeof Status>;
|
|
|
|
|
"note:quote": z.infer<typeof Status>;
|
|
|
|
|
"note:report": z.infer<typeof Status>;
|
2024-04-28 07:02:27 +02:00
|
|
|
"composer:open": undefined;
|
2025-05-26 11:19:15 +02:00
|
|
|
"composer:reply": z.infer<typeof Status>;
|
|
|
|
|
"composer:quote": z.infer<typeof Status>;
|
|
|
|
|
"composer:edit": z.infer<typeof Status>;
|
|
|
|
|
"composer:send": z.infer<typeof Status>;
|
|
|
|
|
"composer:send-edit": z.infer<typeof Status>;
|
2024-04-28 07:02:27 +02:00
|
|
|
"composer:close": undefined;
|
2025-05-26 11:19:15 +02:00
|
|
|
"account:report": z.infer<typeof Account>;
|
|
|
|
|
"account:update": z.infer<typeof Account>;
|
|
|
|
|
"attachment:view": z.infer<typeof Attachment>;
|
2024-06-10 05:24:55 +02:00
|
|
|
"identity:change": Identity;
|
2025-05-01 01:45:46 +02:00
|
|
|
"preferences:open": undefined;
|
2024-06-12 06:41:27 +02:00
|
|
|
error: {
|
|
|
|
|
code: string;
|
|
|
|
|
title: string;
|
|
|
|
|
message: string;
|
|
|
|
|
} | null;
|
2024-04-28 07:02:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const emitter = mitt<ApplicationEvents>();
|
|
|
|
|
|
|
|
|
|
export const useEvent = emitter.emit;
|
|
|
|
|
export const useListen = emitter.on;
|