-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
67 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,7 @@ export function ConnectingToUploader({ | |
</p> | ||
</div> | ||
</div> | ||
<ReturnHome /> | ||
</> | ||
) | ||
} | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { useEffect, useState } from 'react' | ||
|
||
type RotationListener = (isRotating: boolean) => void | ||
|
||
let isRotating = false | ||
const listeners = new Set<RotationListener>() | ||
|
||
export function setRotating(rotating: boolean): void { | ||
isRotating = rotating | ||
notifyListeners() | ||
} | ||
|
||
export function getRotating(): boolean { | ||
return isRotating | ||
} | ||
|
||
export function addRotationListener(listener: RotationListener): void { | ||
listeners.add(listener) | ||
} | ||
|
||
export function removeRotationListener(listener: RotationListener): void { | ||
listeners.delete(listener) | ||
} | ||
|
||
function notifyListeners(): void { | ||
listeners.forEach(listener => listener(isRotating)) | ||
} | ||
|
||
export function useRotatingSpinner(): boolean { | ||
const [rotating, setRotatingState] = useState(isRotating) | ||
|
||
useEffect(() => { | ||
const listener = (newRotating: boolean) => { | ||
setRotatingState(newRotating) | ||
} | ||
|
||
addRotationListener(listener) | ||
return () => removeRotationListener(listener) | ||
}, []) | ||
|
||
return rotating | ||
} |
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