-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: emoji reactions #45
Draft
m-doescode
wants to merge
4
commits into
upryzing:main
Choose a base branch
from
m-doescode:feature/emoji-reactions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+143
−3
Draft
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fb7cb63
feat(reactions): added add reaction button to message menu + emoji se…
m-doescode 8230945
fix: replaced patch-package with yarn patch for emoji picker
m-doescode 9bdbfa2
fix: hide add reaction button when it is not allowed
m-doescode 2bfc58c
fix(reactions): added settings check to wrong context menu item
m-doescode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
diff --git a/node_modules/react-native-emoji-selector/index.js b/node_modules/react-native-emoji-selector/index.js | ||
index 0737acd..a1d1f2c 100644 | ||
--- a/node_modules/react-native-emoji-selector/index.js | ||
+++ b/node_modules/react-native-emoji-selector/index.js | ||
@@ -70,6 +70,7 @@ const categoryKeys = Object.keys(Categories); | ||
|
||
const TabBar = ({ theme, activeCategory, onPress, width }) => { | ||
const tabSize = width / categoryKeys.length; | ||
+ if (tabSize - 12 < 1) return; | ||
|
||
return categoryKeys.map(c => { | ||
const category = Categories[c]; | ||
@@ -80,7 +81,7 @@ const TabBar = ({ theme, activeCategory, onPress, width }) => { | ||
onPress={() => onPress(category)} | ||
style={{ | ||
flex: 1, | ||
- height: tabSize, | ||
+ height: tabSize + 12, | ||
borderColor: category === activeCategory ? theme : "#EEEEEE", | ||
borderBottomWidth: 2, | ||
alignItems: "center", | ||
@@ -91,7 +92,7 @@ const TabBar = ({ theme, activeCategory, onPress, width }) => { | ||
style={{ | ||
textAlign: "center", | ||
paddingBottom: 8, | ||
- fontSize: tabSize - 24 | ||
+ fontSize: tabSize - 12 | ||
}} | ||
> | ||
{category.symbol} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { useContext, useRef, useState, useMemo } from 'react'; | ||
import { View, Text } from 'react-native'; | ||
import { observer } from 'mobx-react-lite'; | ||
import EmojiSelector from 'react-native-emoji-selector'; | ||
// import EmojiPicker from 'emoji-picker-react'; | ||
|
||
import type BottomSheetCore from '@gorhom/bottom-sheet'; | ||
|
||
import type { Message } from 'revolt.js'; | ||
|
||
import { client } from '@clerotri/lib/client'; | ||
import { showToast } from '@clerotri/lib/utils'; | ||
import { app, setFunction } from '@clerotri/Generic'; | ||
import { BottomSheet } from '@clerotri/components/common/BottomSheet'; | ||
import { ThemeContext } from '@clerotri/lib/themes'; | ||
import { useBackHandler } from '@clerotri/lib/ui'; | ||
|
||
export const AddReactionSheet = observer(() => { | ||
const { currentTheme } = useContext(ThemeContext); | ||
|
||
const [message, setMessage] = useState(null as Message | null); | ||
|
||
const sheetRef = useRef<BottomSheetCore>(null); | ||
|
||
useBackHandler(() => { | ||
if (message) { | ||
sheetRef.current?.close(); | ||
return true; | ||
} | ||
|
||
return false; | ||
}); | ||
|
||
setFunction('openAddReaction', async (m: Message | null) => { | ||
setMessage(m); | ||
m ? sheetRef.current?.expand() : sheetRef.current?.close(); | ||
}); | ||
|
||
function selectEmoji(emoji: string) { | ||
if (!message) return; | ||
|
||
const reaction = message.reactions.get(emoji) || []; | ||
|
||
message.channel?.havePermission('React') | ||
? !Array.from(reaction).includes(client.user?._id!) | ||
? message.react(emoji) | ||
: message.unreact(emoji) | ||
: showToast('You cannot react to this message.'); | ||
app.openAddReaction(null); | ||
} | ||
|
||
return ( | ||
// BottomSheet cannot wrap our children in a scroll view because it will | ||
// create a nested set of scroll views which causes issues | ||
<BottomSheet innerScroll={true} sheetRef={sheetRef}> | ||
<View style={{ paddingHorizontal: 16, flex: 1 }}> | ||
{!message ? ( | ||
<></> | ||
) : ( | ||
<EmojiSelector | ||
onEmojiSelected={selectEmoji} | ||
columns={8} /> | ||
)} | ||
</View> | ||
</BottomSheet> | ||
); | ||
}); |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it'd probably be better to just hide the button if the user doesn't have react perms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I'll wrap it in a ternary checking for permission, then.