1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2025-01-17 01:51:24 +01:00
smov/src/stores/quality/index.ts

39 lines
890 B
TypeScript
Raw Normal View History

2023-10-18 20:31:03 +02:00
import { create } from "zustand";
import { persist } from "zustand/middleware";
import { immer } from "zustand/middleware/immer";
import { SourceQuality } from "@/stores/player/utils/qualities";
export interface QualityStore {
quality: {
lastChosenQuality: SourceQuality | null;
automaticQuality: boolean;
};
setLastChosenQuality(v: SourceQuality | null): void;
setAutomaticQuality(v: boolean): void;
}
export const useQualityStore = create(
persist(
immer<QualityStore>((set) => ({
quality: {
automaticQuality: true,
lastChosenQuality: null,
},
setLastChosenQuality(v) {
set((s) => {
s.quality.lastChosenQuality = v;
});
},
setAutomaticQuality(v) {
set((s) => {
s.quality.automaticQuality = v;
});
},
})),
{
name: "__MW::quality",
},
),
2023-10-18 20:31:03 +02:00
);