forked from ztjhz/BetterChatGPT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloud-auth-slice.ts
50 lines (48 loc) · 1.37 KB
/
cloud-auth-slice.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { SyncStatus } from '@type/google-api';
import { StoreSlice } from './cloud-auth-store';
export interface CloudAuthSlice {
googleAccessToken?: string;
googleRefreshToken?: string;
cloudSync: boolean;
syncStatus: SyncStatus;
fileId?: string;
setGoogleAccessToken: (googleAccessToken?: string) => void;
setGoogleRefreshToken: (googleRefreshToken?: string) => void;
setFileId: (fileId?: string) => void;
setCloudSync: (cloudSync: boolean) => void;
setSyncStatus: (syncStatus: SyncStatus) => void;
}
export const createCloudAuthSlice: StoreSlice<CloudAuthSlice> = (set, get) => ({
cloudSync: false,
syncStatus: 'unauthenticated',
setGoogleAccessToken: (googleAccessToken?: string) => {
set((prev: CloudAuthSlice) => ({
...prev,
googleAccessToken: googleAccessToken,
}));
},
setGoogleRefreshToken: (googleRefreshToken?: string) => {
set((prev: CloudAuthSlice) => ({
...prev,
googleRefreshToken: googleRefreshToken,
}));
},
setFileId: (fileId?: string) => {
set((prev: CloudAuthSlice) => ({
...prev,
fileId: fileId,
}));
},
setCloudSync: (cloudSync: boolean) => {
set((prev: CloudAuthSlice) => ({
...prev,
cloudSync: cloudSync,
}));
},
setSyncStatus: (syncStatus: SyncStatus) => {
set((prev: CloudAuthSlice) => ({
...prev,
syncStatus: syncStatus,
}));
},
});