-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for reaction & redaction capabilities in widget mode
Signed-off-by: Milton Moura <[email protected]>
- Loading branch information
Showing
6 changed files
with
133 additions
and
83 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
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
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,49 @@ | ||
/* | ||
Copyright 2024 Milton Moura <[email protected]> | ||
SPDX-License-Identifier: AGPL-3.0-only | ||
Please see LICENSE in the repository root for full details. | ||
*/ | ||
|
||
import React, { createContext, useContext, useState, ReactNode } from "react"; | ||
|
||
interface ReactionsContextType { | ||
raisedHands: string[]; | ||
setRaisedHands: React.Dispatch<React.SetStateAction<string[]>>; | ||
supportsReactions: boolean; | ||
setSupportsReactions: React.Dispatch<React.SetStateAction<boolean>>; | ||
} | ||
|
||
const ReactionsContext = createContext<ReactionsContextType | undefined>( | ||
undefined, | ||
); | ||
|
||
export const useReactions = (): ReactionsContextType => { | ||
const context = useContext(ReactionsContext); | ||
if (!context) { | ||
throw new Error("useReactions must be used within a ReactionsProvider"); | ||
Check failure on line 24 in src/useReactions.tsx GitHub Actions / Run vitest testssrc/tile/GridTile.test.tsx > GridTile is accessible
|
||
} | ||
return context; | ||
}; | ||
|
||
export const ReactionsProvider = ({ | ||
children, | ||
}: { | ||
children: ReactNode; | ||
}): JSX.Element => { | ||
const [raisedHands, setRaisedHands] = useState<string[]>([]); | ||
const [supportsReactions, setSupportsReactions] = useState<boolean>(true); | ||
|
||
return ( | ||
<ReactionsContext.Provider | ||
value={{ | ||
raisedHands, | ||
setRaisedHands, | ||
supportsReactions, | ||
setSupportsReactions, | ||
}} | ||
> | ||
{children} | ||
</ReactionsContext.Provider> | ||
); | ||
}; |