setup electron multi-window architecture (#102)
* prototype with two windows * use deps in separate window render process * enhance autoplay into desktop overlay * fix: autoplay window not applying tailwind styles
This commit was merged in pull request #102.
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
import { create } from "zustand";
|
||||
import type { Particle } from "@/api/types";
|
||||
|
||||
type MediaParticle = Extract<Particle, { type: "media" }>;
|
||||
|
||||
const STORAGE_KEY = "llink:autoplay-muted";
|
||||
|
||||
@@ -22,38 +19,17 @@ function saveMuted(muted: boolean) {
|
||||
}
|
||||
|
||||
interface AutoplayState {
|
||||
/** The media particle currently being autoplayed, null when idle */
|
||||
activeParticle: MediaParticle | null;
|
||||
/** The stream this particle belongs to (for click-to-navigate) */
|
||||
streamId: string | null;
|
||||
/** When true, incoming play requests are ignored */
|
||||
muted: boolean;
|
||||
/** Play a media particle, preempting any currently playing. No-op when muted. */
|
||||
play: (particle: MediaParticle, streamId: string) => void;
|
||||
/** Stop autoplay and clear state */
|
||||
stop: () => void;
|
||||
/** Toggle muted state */
|
||||
toggleMuted: () => void;
|
||||
}
|
||||
|
||||
export const useAutoplayStore = create<AutoplayState>((set, get) => ({
|
||||
activeParticle: null,
|
||||
streamId: null,
|
||||
muted: loadMuted(),
|
||||
play: (particle, streamId) => {
|
||||
if (get().muted) return;
|
||||
set({ activeParticle: particle, streamId });
|
||||
},
|
||||
stop: () => set({ activeParticle: null, streamId: null }),
|
||||
toggleMuted: () => {
|
||||
const wasMuted = get().muted;
|
||||
// If muting, also stop any current playback
|
||||
if (!wasMuted) {
|
||||
set({ muted: true, activeParticle: null, streamId: null });
|
||||
saveMuted(true);
|
||||
} else {
|
||||
set({ muted: false });
|
||||
saveMuted(false);
|
||||
}
|
||||
const next = !get().muted;
|
||||
set({ muted: next });
|
||||
saveMuted(next);
|
||||
},
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user