Skip to content

Commit

Permalink
feat: Add async/await to checkAndUpdateItems in useObserve hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Jun-Murakami committed Jul 5, 2024
1 parent bffab41 commit c2d770f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/hooks/useObserve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export const useObserve = () => {
return;
}

const checkAndUpdateItems = () => {
const checkAndUpdateItems = async () => {
const recentItems = useTreeStateStore.getState().items;
const updatedItems = [...recentItems];
let hasChanges = false;
Expand Down Expand Up @@ -203,11 +203,15 @@ export const useObserve = () => {

if (hasChanges) {
setItems(updatedItems);
notificationMessages.forEach((message) => showDialog(message, 'Alerm'));
for (const message of notificationMessages) {
await showDialog(message, 'Alerm');
}
}
};

const intervalId = setInterval(checkAndUpdateItems, 60000); // 1分ごとにチェック
const intervalId = setInterval(async () => {
await checkAndUpdateItems();
}, 60000); // 1分ごとにチェック

if (!isEqual(items, prevItems)) {
if (currentTree !== prevCurrentTree) {
Expand Down

0 comments on commit c2d770f

Please sign in to comment.