-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to allow multiple ids to be edited
Signed-off-by: ibolton336 <[email protected]>
- Loading branch information
1 parent
09b4a42
commit 2a1c0f9
Showing
4 changed files
with
43 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
client/src/app/pages/external/jira/useUpdatingTrackerId.ts
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
client/src/app/pages/external/jira/useUpdatingTrackerIds.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useState, useEffect } from "react"; | ||
|
||
export type UpdatableId = string | number | null; | ||
|
||
const useUpdatingTrackerIds = (delay: number = 5000) => { | ||
const [updatingTrackerIds, setUpdatingTrackerIds] = useState< | ||
Set<UpdatableId> | ||
>(new Set()); | ||
|
||
useEffect(() => { | ||
let timerId: number | null = null; | ||
|
||
if (updatingTrackerIds.size > 0) { | ||
timerId = window.setTimeout(() => { | ||
setUpdatingTrackerIds(new Set()); | ||
}, delay); | ||
} | ||
|
||
return () => { | ||
if (timerId !== null) { | ||
window.clearTimeout(timerId); | ||
} | ||
}; | ||
}, [updatingTrackerIds, delay]); | ||
|
||
const addUpdatingTrackerId = (id: UpdatableId) => { | ||
setUpdatingTrackerIds((prevSet) => new Set(prevSet.add(id))); | ||
}; | ||
|
||
return [Array.from(updatingTrackerIds), addUpdatingTrackerId] as const; | ||
}; | ||
|
||
export default useUpdatingTrackerIds; |