enable native notification

This commit is contained in:
Ren Amamiya
2023-06-01 16:51:00 +07:00
parent ea3e5a69f6
commit f61adb2ff5
5 changed files with 111 additions and 20 deletions

View File

@@ -1,18 +1,27 @@
import { getActiveAccount, getLastLogin } from "@utils/storage";
import { create } from "zustand";
import { createJSONStorage, persist } from "zustand/middleware";
export const useActiveAccount = create((set) => ({
account: null,
lastLogin: 0,
fetch: async () => {
const response = await getActiveAccount();
set({ account: response });
},
fetchLastLogin: async () => {
const response = await getLastLogin();
set({ lastLogin: parseInt(response) });
},
updateFollows: (list: any) => {
set((state: any) => ({ account: { ...state.account, follows: list } }));
},
}));
export const useActiveAccount = create(
persist(
(set) => ({
account: null,
lastLogin: 0,
fetch: async () => {
const response = await getActiveAccount();
set({ account: response });
},
fetchLastLogin: async () => {
const response = await getLastLogin();
set({ lastLogin: parseInt(response) });
},
updateFollows: (list: any) => {
set((state: any) => ({ account: { ...state.account, follows: list } }));
},
}),
{
name: "account",
storage: createJSONStorage(() => sessionStorage),
},
),
);