Skip to content

Commit ac36214

Browse files
committed
Lightbox: Added Button to jump to current image within the conversation
1 parent 07b966e commit ac36214

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

_locales/en/messages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8343,5 +8343,9 @@
83438343
"icu:WhatsNew__v7.50--0": {
83448344
"messageformat": "If you link a new Desktop on Signal Android and choose to transfer your message history, now you can also selectively transfer old attachments from your primary device too. Bring the past into the present by scrolling back in time and clicking on the download icon. As always, the transfer process is end-to-end encrypted and secure.",
83458345
"description": "Release notes for version 7.49"
8346+
},
8347+
"icu:jumpto": {
8348+
"messageformat": "Jump to",
8349+
"description": "Jumps to the medias position in the conversation"
83468350
}
83478351
}

stylesheets/components/Lightbox.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,15 @@
360360
}
361361
}
362362

363+
&--jump {
364+
&::before {
365+
@include mixins.color-svg(
366+
'../images/icons/v3/chat/chat.svg',
367+
variables.$color-gray-15
368+
);
369+
}
370+
}
371+
363372
&--close {
364373
&::before {
365374
@include mixins.color-svg(

ts/components/Lightbox.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type {
1313
ConversationType,
1414
SaveAttachmentActionCreatorType,
1515
} from '../state/ducks/conversations';
16+
import { useConversationsActions } from '../state/ducks/conversations';
1617
import type { LocalizerType } from '../types/Util';
1718
import type { MediaItemType } from '../types/MediaItem';
1819
import * as GoogleChrome from '../util/GoogleChrome';
@@ -99,6 +100,7 @@ export function Lightbox({
99100
hasNextMessage,
100101
hasPrevMessage,
101102
}: PropsType): JSX.Element | null {
103+
const { scrollToMessage } = useConversationsActions();
102104
const hasThumbnails = media.length > 1;
103105
const messageId = media.at(0)?.message.id;
104106
const prevMessageId = usePrevious(messageId, messageId);
@@ -243,6 +245,21 @@ export function Lightbox({
243245
[isViewOnce, media, saveAttachment, selectedIndex]
244246
);
245247

248+
const handleJumpToConversation = useCallback(
249+
(
250+
event: KeyboardEvent | React.MouseEvent<HTMLButtonElement, MouseEvent>
251+
) => {
252+
if (isViewOnce) {
253+
return;
254+
}
255+
const mediaItem = media[selectedIndex];
256+
const { message } = mediaItem;
257+
const { conversationId, id } = message;
258+
scrollToMessage(conversationId, id);
259+
},
260+
[isViewOnce, media, selectedIndex, scrollToMessage]
261+
);
262+
246263
const handleForward = (
247264
event: React.MouseEvent<HTMLButtonElement, MouseEvent>
248265
) => {
@@ -726,6 +743,14 @@ export function Lightbox({
726743
<div />
727744
)}
728745
<div className="Lightbox__controls">
746+
{!isViewOnce ? (
747+
<button
748+
aria-label={i18n('icu:jumpto')}
749+
className="Lightbox__button Lightbox__button--jump"
750+
onClick={handleJumpToConversation}
751+
type="button"
752+
/>
753+
) : null}
729754
{!isViewOnce ? (
730755
<button
731756
aria-label={i18n('icu:forwardMessage')}

0 commit comments

Comments
 (0)