mirror of
https://github.com/sussy-code/smov.git
synced 2025-01-17 01:51:24 +01:00
38 lines
890 B
TypeScript
38 lines
890 B
TypeScript
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",
|
|
},
|
|
),
|
|
);
|