-
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.
🐛 Shows client side loading state to allow backend time to connect to…
… instance Signed-off-by: ibolton336 <ibolton@redhat.com>
- Loading branch information
1 parent
9cf7840
commit e4c2be5
Showing
4 changed files
with
80 additions
and
22 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: 27 additions & 0 deletions
27
client/src/app/pages/external/jira/useUpdatingTrackerId.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,27 @@ | ||
import { useState, useEffect } from "react"; | ||
|
||
type UpdatableId = string | number | null; | ||
|
||
const useUpdatingTrackerId = (delay: number = 5000) => { | ||
const [updatingTrackerId, setUpdatingTrackerId] = useState<UpdatableId>(null); | ||
|
||
useEffect(() => { | ||
let timerId: number | null = null; | ||
|
||
if (updatingTrackerId !== null) { | ||
timerId = window.setTimeout(() => { | ||
setUpdatingTrackerId(null); | ||
}, delay); | ||
} | ||
|
||
return () => { | ||
if (timerId !== null) { | ||
window.clearTimeout(timerId); | ||
} | ||
}; | ||
}, [updatingTrackerId, delay]); | ||
|
||
return [updatingTrackerId, setUpdatingTrackerId] as const; | ||
}; | ||
|
||
export default useUpdatingTrackerId; |
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