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-12-23 06:24:43 +01:00
|
|
|
},
|
|
|
|
),
|
2023-10-18 20:31:03 +02:00
|
|
|
);
|