forked from cinnyapp/cinny
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix unread reset and notification settings (cinnyapp#1824)
* reset unread with client sync state change * fix notification toggle setting not working * revert formatOnSave vscode setting
- Loading branch information
Showing
9 changed files
with
62 additions
and
100 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 was deleted.
Oops, something went wrong.
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,30 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
export function usePermissionState(name: PermissionName, initialValue: PermissionState = 'prompt') { | ||
const [permissionState, setPermissionState] = useState<PermissionState>(initialValue); | ||
|
||
useEffect(() => { | ||
let permissionStatus: PermissionStatus; | ||
|
||
function handlePermissionChange(this: PermissionStatus) { | ||
setPermissionState(this.state); | ||
} | ||
|
||
navigator.permissions | ||
.query({ name }) | ||
.then((permStatus: PermissionStatus) => { | ||
permissionStatus = permStatus; | ||
handlePermissionChange.apply(permStatus); | ||
permStatus.addEventListener("change", handlePermissionChange); | ||
}) | ||
.catch(() => { | ||
// Silence error since FF doesn't support microphone permission | ||
}); | ||
|
||
return () => { | ||
permissionStatus?.removeEventListener("change", handlePermissionChange); | ||
}; | ||
}, [name]); | ||
|
||
return permissionState; | ||
} |
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
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