Skip to content

Commit

Permalink
style: fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: YXL <[email protected]>
  • Loading branch information
YXL76 committed Apr 13, 2024
1 parent 88edc52 commit e4fa7d7
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions packages/client/src/utils/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class IPCClient<T, U = T> {

resolve(true);
})
.catch(() => resolve(false))
.catch(() => resolve(false)),
);
}

Expand Down Expand Up @@ -92,11 +92,11 @@ const ipc = new IPCClient<IPCClientMsg, IPCServerMsg>(ipcServerPath);
const ipcB = new IPCClient<IPCBroadcastMsg>(ipcBroadcastServerPath);

let _nextChann = 0;
const removePicUrl = (items?: PlayTreeItemData[]) => {
if (items)
for (const item of items) {
if ("al" in item && item.al.picUrl.length > 1000) item.al.picUrl = "";
}
const removePicUrl = (items: PlayTreeItemData[]) => {
for (const item of items) {
if ("al" in item && item.al.picUrl.length > 1000) item.al.picUrl = "";
}
return items;
};

export const IPC = {
Expand All @@ -105,7 +105,7 @@ export const IPC = {
connect: (
ipcHandler: Parameters<typeof ipc.connect>[0],
ipcBHandler: Parameters<typeof ipcB.connect>[0],
retry = 4
retry = 4,
): Promise<[boolean, boolean]> => Promise.all([ipc.connect(ipcHandler, retry), ipcB.connect(ipcBHandler, retry)]),
disconnect: () => {
ipc.disconnect();
Expand All @@ -129,7 +129,7 @@ export const IPC = {
next: next && "mainSong" in next ? next.mainSong : next,
play,
seek,
})
}),
)
.catch(console.error);
},
Expand Down Expand Up @@ -160,21 +160,16 @@ export const IPC = {
volume: (level: number) => ipc.send({ t: IPCPlayer.volume, level }),
speed: (speed: number) => ipc.send({ t: IPCPlayer.speed, speed }),
seek: (seekOffset: number) => ipc.send({ t: IPCPlayer.seek, seekOffset }),
add: (items: PlayTreeItemData[], index?: number) => {
removePicUrl(items);
ipcB.send({ t: IPCQueue.add, items, index });
},
add: (items: PlayTreeItemData[], index?: number) => ipcB.send({ t: IPCQueue.add, items: removePicUrl(items), index }),
clear: () => ipcB.send({ t: IPCQueue.clear }),
delete: (id: number | string) => ipcB.send({ t: IPCQueue.delete, id }),
fm: (uid: number) => ipc.send({ t: IPCQueue.fm, uid }),
new: (items?: PlayTreeItemData[]) => {
removePicUrl(items);
new: (items?: PlayTreeItemData[]) =>
ipcB.send(
items
? { t: IPCQueue.new, id: QueueProvider.id + 1, items }
: { t: IPCQueue.new, id: QueueProvider.id, items: QueueProvider.songs }
);
},
? { t: IPCQueue.new, id: QueueProvider.id + 1, items: removePicUrl(items) }
: { t: IPCQueue.new, id: QueueProvider.id, items: QueueProvider.songs },
),
playSong: (id: number | string) => ipcB.send({ t: IPCQueue.play, id }),
random: () => ipcB.send({ t: IPCQueue.new, id: QueueProvider.id + 1, items: QueueProvider.random() }),
shift: (index: number) => ipcB.send({ t: IPCQueue.shift, index }),
Expand Down

0 comments on commit e4fa7d7

Please sign in to comment.