Skip to content
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

Fix close emoji click button #1992

Merged
merged 3 commits into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix emoji click on button while open closes it
Fixes #1980
  • Loading branch information
Bilb committed Oct 28, 2021
commit dfa04c68f40b51c71e343ba8d17d36af501e5923
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const MessageStatusSendingContainer = styled.div`
align-self: flex-end;
margin-bottom: 2px;
margin-inline-start: 5px;
cursor: pointer;
`;

const MessageStatusSending = () => {
Expand Down
44 changes: 27 additions & 17 deletions ts/components/session/conversation/SessionCompositionBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,21 @@ const StartRecordingButton = (props: { onClick: () => void }) => {
);
};

const ToggleEmojiButton = (props: { onClick: () => void }) => {
return (
<SessionIconButton
iconType="emoji"
backgroundColor="var(--color-compose-view-button-background)"
iconSize={'huge2'}
borderRadius="300px"
iconPadding="6px"
onClick={props.onClick}
/>
);
};
const ToggleEmojiButton = React.forwardRef<HTMLDivElement, { onClick: () => void }>(
(props, ref) => {
return (
<SessionIconButton
iconType="emoji"
ref={ref}
backgroundColor="var(--color-compose-view-button-background)"
iconSize={'huge2'}
borderRadius="300px"
iconPadding="6px"
onClick={props.onClick}
/>
);
}
);

const SendMessageButton = (props: { onClick: () => void }) => {
return (
Expand Down Expand Up @@ -205,7 +208,8 @@ const getDefaultState = (newConvoId?: string) => {
class SessionCompositionBoxInner extends React.Component<Props, State> {
private readonly textarea: React.RefObject<any>;
private readonly fileInput: React.RefObject<HTMLInputElement>;
private emojiPanel: any;
private readonly emojiPanel: any;
private readonly emojiPanelButton: any;
private linkPreviewAbortController?: AbortController;
private container: any;
private readonly mentionsRegex = /@\uFFD205[0-9a-f]{64}\uFFD7[^\uFFD2]+\uFFD2/gu;
Expand All @@ -219,7 +223,8 @@ class SessionCompositionBoxInner extends React.Component<Props, State> {
this.fileInput = React.createRef();

// Emojis
this.emojiPanel = null;
this.emojiPanel = React.createRef();
this.emojiPanelButton = React.createRef();
autoBind(this);
this.toggleEmojiPanel = debounce(this.toggleEmojiPanel.bind(this), 100);
}
Expand Down Expand Up @@ -271,7 +276,10 @@ class SessionCompositionBoxInner extends React.Component<Props, State> {
}

private handleClick(e: any) {
if (this.emojiPanel && this.emojiPanel.contains(e.target)) {
if (
(this.emojiPanel?.current && this.emojiPanel.current.contains(e.target)) ||
(this.emojiPanelButton?.current && this.emojiPanelButton.current.contains(e.target))
) {
return;
}

Expand Down Expand Up @@ -421,11 +429,13 @@ class SessionCompositionBoxInner extends React.Component<Props, State> {
{this.renderTextArea()}
</div>

{typingEnabled && <ToggleEmojiButton onClick={this.toggleEmojiPanel} />}
{typingEnabled && (
<ToggleEmojiButton ref={this.emojiPanelButton} onClick={this.toggleEmojiPanel} />
)}
<SendMessageButton onClick={this.onSendMessage} />

{typingEnabled && (
<div ref={ref => (this.emojiPanel = ref)} onKeyDown={this.onKeyDown} role="button">
<div ref={this.emojiPanel} onKeyDown={this.onKeyDown} role="button">
{showEmojiPanel && (
<SessionEmojiPanel onEmojiClicked={this.onEmojiClick} show={showEmojiPanel} />
)}
Expand Down
5 changes: 3 additions & 2 deletions ts/components/session/icon/SessionIconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface SProps extends SessionIconProps {
margin?: string;
}

const SessionIconButtonInner = (props: SProps) => {
const SessionIconButtonInner = React.forwardRef<HTMLDivElement, SProps>((props, ref) => {
const {
iconType,
iconSize,
Expand Down Expand Up @@ -40,6 +40,7 @@ const SessionIconButtonInner = (props: SProps) => {
<div
className={classNames('session-icon-button', iconSize, isSelected ? 'no-opacity' : '')}
role="button"
ref={ref}
onClick={clickHandler}
style={{ display: isHidden ? 'none' : 'flex', margin: margin ? margin : '' }}
>
Expand All @@ -58,6 +59,6 @@ const SessionIconButtonInner = (props: SProps) => {
{Boolean(notificationCount) && <SessionNotificationCount count={notificationCount} />}
</div>
);
};
});

export const SessionIconButton = React.memo(SessionIconButtonInner, _.isEqual);
1 change: 0 additions & 1 deletion ts/interactions/conversations/unsendingInteractions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ async function unsendMessagesForEveryone(
// sending to recipient all the messages separately for now
await Promise.all(
unsendMsgObjects.map(unsendObject => {
console.warn('sending unsend message', unsendObject);
getMessageQueue()
.sendToGroup(unsendObject, undefined, new PubKey(destinationId))
.catch(window?.log?.error);
Expand Down