Skip to content

Commit

Permalink
Prevent sticker picker from being opened in incompatible situations
Browse files Browse the repository at this point in the history
The sticker picker could be opened when the user is about to send an attachment, or a reply, or text, neither of which can be combined with stickers
  • Loading branch information
hackerbirds committed Nov 1, 2024
1 parent 92d22d0 commit b346626
Showing 1 changed file with 31 additions and 30 deletions.
61 changes: 31 additions & 30 deletions ts/components/CompositionArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -655,35 +655,36 @@ export const CompositionArea = memo(function CompositionArea({
</>
) : null;

const shouldShowStickers =
!quotedMessageProps && isComposerEmpty && withStickers;
const stickerButtonPlacement = large ? 'top-start' : 'top-end';
const stickerButtonFragment =
!draftEditMessage && withStickers ? (
<div className="CompositionArea__button-cell">
<StickerButton
i18n={i18n}
knownPacks={knownPacks}
receivedPacks={receivedPacks}
installedPack={installedPack}
installedPacks={installedPacks}
blessedPacks={blessedPacks}
recentStickers={recentStickers}
clearInstalledStickerPack={clearInstalledStickerPack}
onClickAddPack={() =>
pushPanelForConversation({
type: PanelType.StickerManager,
})
}
onPickSticker={(packId, stickerId) =>
sendStickerMessage(conversationId, { packId, stickerId })
}
showIntroduction={showIntroduction}
clearShowIntroduction={clearShowIntroduction}
showPickerHint={showPickerHint}
clearShowPickerHint={clearShowPickerHint}
position={stickerButtonPlacement}
/>
</div>
) : null;
const stickerButtonFragment = shouldShowStickers ? (
<div className="CompositionArea__button-cell">
<StickerButton
i18n={i18n}
knownPacks={knownPacks}
receivedPacks={receivedPacks}
installedPack={installedPack}
installedPacks={installedPacks}
blessedPacks={blessedPacks}
recentStickers={recentStickers}
clearInstalledStickerPack={clearInstalledStickerPack}
onClickAddPack={() =>
pushPanelForConversation({
type: PanelType.StickerManager,
})
}
onPickSticker={(packId, stickerId) =>
sendStickerMessage(conversationId, { packId, stickerId })
}
showIntroduction={showIntroduction}
clearShowIntroduction={clearShowIntroduction}
showPickerHint={showPickerHint}
clearShowPickerHint={clearShowPickerHint}
position={stickerButtonPlacement}
/>
</div>
) : null;

// Listen for cmd/ctrl-shift-x to toggle large composition mode
useEffect(() => {
Expand Down Expand Up @@ -1053,7 +1054,7 @@ export const CompositionArea = memo(function CompositionArea({
</div>
{!large ? (
<>
{stickerButtonFragment}
{!dirty ? stickerButtonFragment : null}
{!dirty ? micButtonFragment : null}
{editMessageFragment}
{attButton}
Expand All @@ -1068,7 +1069,7 @@ export const CompositionArea = memo(function CompositionArea({
)}
>
{leftHandSideButtonsFragment}
{stickerButtonFragment}
{!dirty ? stickerButtonFragment : null}
{attButton}
{!dirty ? micButtonFragment : null}
{editMessageFragment}
Expand Down

0 comments on commit b346626

Please sign in to comment.