Skip to content

Commit

Permalink
useObserve.tsとuseTreeManagement.tsの変更をコミット
Browse files Browse the repository at this point in the history
  • Loading branch information
Jun-Murakami committed May 5, 2024
1 parent 470024f commit 881b15d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 18 deletions.
13 changes: 1 addition & 12 deletions src/hooks/useObserve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ export const useObserve = () => {
const setIsLoading = useAppStateStore((state) => state.setIsLoading);
const quickMemoText = useAppStateStore((state) => state.quickMemoText);
const setQuickMemoText = useAppStateStore((state) => state.setQuickMemoText);
const isLoadedItemsFromDb = useAppStateStore((state) => state.isLoadedItemsFromDb);
const setIsLoadedItemsFromDb = useAppStateStore((state) => state.setIsLoadedItemsFromDb);
const isLoadedMemoFromDb = useAppStateStore((state) => state.isLoadedMemoFromDb);
const setIsLoadedMemoFromDb = useAppStateStore((state) => state.setIsLoadedMemoFromDb);
const setTreesList = useTreeStateStore((state) => state.setTreesList);
Expand Down Expand Up @@ -91,6 +89,7 @@ export const useObserve = () => {
const serverTimestamp = snapshot.val();
const currentLocalTimestamp = useAppStateStore.getState().localTimestamp;
if (serverTimestamp && serverTimestamp > currentLocalTimestamp) {
setLocalTimestamp(serverTimestamp);
const newTreesList = await loadTreesListFromDb(uid);
setTreesList(newTreesList);
await saveTreesListIdb(newTreesList);
Expand Down Expand Up @@ -127,7 +126,6 @@ export const useObserve = () => {
}

}
setLocalTimestamp(serverTimestamp);
setIsLoading(false);
});
};
Expand All @@ -153,15 +151,6 @@ export const useObserve = () => {
return;
}

if (!isLoadedItemsFromDb) {
setIsLoadedItemsFromDb(false);
return;
}

if (items.length === 0) {
return;
}

setPrevItems(items);
const targetTree = currentTree;
const debounceSave = setTimeout(() => {
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/useTreeManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export const useTreeManagement = () => {
const email = useAppStateStore((state) => state.email);
const isLoading = useAppStateStore((state) => state.isLoading);
const setIsLoading = useAppStateStore((state) => state.setIsLoading);
const setIsLoadedItemsFromDb = useAppStateStore((state) => state.setIsLoadedItemsFromDb);
const setIsAccordionExpanded = useAppStateStore((state) => state.setIsAccordionExpanded);
const setIsFocusedTreeName = useAppStateStore((state) => state.setIsFocusedTreeName);

Expand Down Expand Up @@ -77,7 +76,6 @@ export const useTreeManagement = () => {
members.push({ uid: member, email: treeData.membersV2[member] });
}
setCurrentTreeMembers(members);
setIsLoadedItemsFromDb(true);
setItems(treeData.items);
}

Expand Down
4 changes: 0 additions & 4 deletions src/store/appStateStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ type AppState = {
searchKey: string;
isEditingText: boolean;
quickMemoText: string;
isLoadedItemsFromDb: boolean;
isLoadedMemoFromDb: boolean;
setIsOffline: (isOffline: boolean) => void;
setLocalTimestamp: (localTimestamp: number) => void;
Expand All @@ -37,7 +36,6 @@ type AppState = {
setSearchKey: (searchKey: string) => void;
setIsEditingText: (isEditingText: boolean) => void;
setQuickMemoText: (quickMemoText: string) => void;
setIsLoadedItemsFromDb: (isLoadedItemsFromDb: boolean) => void;
setIsLoadedMemoFromDb: (isLoadedMemoFromDb: boolean) => void;
};

Expand All @@ -59,7 +57,6 @@ export const useAppStateStore = create<AppState>((set) => ({
searchKey: '',
isEditingText: false,
quickMemoText: '',
isLoadedItemsFromDb: false,
isLoadedMemoFromDb: false,
setIsOffline: (isOffline) => set({ isOffline }),
setLocalTimestamp: (localTimestamp) => set({ localTimestamp }),
Expand All @@ -78,6 +75,5 @@ export const useAppStateStore = create<AppState>((set) => ({
setSearchKey: (searchKey) => set({ searchKey }),
setIsEditingText: (isEditingText) => set({ isEditingText }),
setQuickMemoText: (quickMemoText) => set({ quickMemoText }),
setIsLoadedItemsFromDb: (isLoadedItemsFromDb) => set({ isLoadedItemsFromDb }),
setIsLoadedMemoFromDb: (isLoadedMemoFromDb) => set({ isLoadedMemoFromDb }),
}));

0 comments on commit 881b15d

Please sign in to comment.