migrate from ts-rs to tauri-specta
This commit is contained in:
@@ -1,21 +1,18 @@
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import { writable } from "svelte/store";
|
||||
import type { CursorPositions } from "../types/bindings/CursorPositions";
|
||||
import type { DollDto } from "../types/bindings/DollDto";
|
||||
import type { FriendDisconnectedPayload } from "../types/bindings/FriendDisconnectedPayload";
|
||||
import type { FriendActiveDollChangedPayload } from "../types/bindings/FriendActiveDollChangedPayload";
|
||||
import { AppEvents } from "../types/bindings/AppEventsConstants";
|
||||
import {
|
||||
events,
|
||||
type CursorPositions,
|
||||
type DollDto,
|
||||
type FriendActiveDollChangedPayload,
|
||||
type FriendDisconnectedPayload,
|
||||
type OutgoingFriendCursorPayload,
|
||||
} from "$lib/bindings";
|
||||
import {
|
||||
createMultiListenerSubscription,
|
||||
removeFromStore,
|
||||
setupHmrCleanup,
|
||||
} from "./listener-utils";
|
||||
|
||||
export type FriendCursorPosition = {
|
||||
userId: string;
|
||||
position: CursorPositions;
|
||||
};
|
||||
|
||||
type FriendCursorData = {
|
||||
position: CursorPositions;
|
||||
lastUpdated: number;
|
||||
@@ -40,10 +37,9 @@ export async function startFriendCursorTracking() {
|
||||
try {
|
||||
// TODO: Add initial sync for existing friends' cursors and dolls if needed
|
||||
|
||||
const unlistenFriendCursor = await listen<FriendCursorPosition>(
|
||||
AppEvents.FriendCursorPosition,
|
||||
const unlistenFriendCursor = await events.friendCursorPositionUpdated.listen(
|
||||
(event) => {
|
||||
const data = event.payload;
|
||||
const data: OutgoingFriendCursorPayload = event.payload;
|
||||
|
||||
friendCursorState[data.userId] = {
|
||||
position: data.position,
|
||||
@@ -60,8 +56,7 @@ export async function startFriendCursorTracking() {
|
||||
);
|
||||
subscription.addUnlisten(unlistenFriendCursor);
|
||||
|
||||
const unlistenFriendDisconnected = await listen<FriendDisconnectedPayload>(
|
||||
AppEvents.FriendDisconnected,
|
||||
const unlistenFriendDisconnected = await events.friendDisconnected.listen(
|
||||
(event) => {
|
||||
const data = event.payload;
|
||||
|
||||
@@ -77,8 +72,7 @@ export async function startFriendCursorTracking() {
|
||||
subscription.addUnlisten(unlistenFriendDisconnected);
|
||||
|
||||
const unlistenFriendActiveDollChanged =
|
||||
await listen<FriendActiveDollChangedPayload>(
|
||||
AppEvents.FriendActiveDollChanged,
|
||||
await events.friendActiveDollChanged.listen(
|
||||
(event) => {
|
||||
const payload = event.payload;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user