@@ -40,6 +40,7 @@ import {
4040import { showStickerPackPreview } from './globalModals' ;
4141import { useBoundActions } from '../../hooks/useBoundActions' ;
4242import { DataReader } from '../../sql/Client' ;
43+ import { MessageModel } from '../../models/messages' ;
4344
4445// eslint-disable-next-line local-rules/type-alias-readonlydeep
4546export type LightboxStateType =
@@ -196,6 +197,8 @@ function showLightboxForViewOnceMedia(
196197
197198 const { contentType } = tempAttachment ;
198199
200+ const authorId = getAuthorId ( message ) ;
201+
199202 const media = [
200203 {
201204 attachment : tempAttachment ,
@@ -208,6 +211,7 @@ function showLightboxForViewOnceMedia(
208211 attachments : message . get ( 'attachments' ) || [ ] ,
209212 id : message . get ( 'id' ) ,
210213 conversationId : message . get ( 'conversationId' ) ,
214+ authorId,
211215 receivedAt : message . get ( 'received_at' ) ,
212216 receivedAtMs : Number ( message . get ( 'received_at_ms' ) ) ,
213217 sentAt : message . get ( 'sent_at' ) ,
@@ -228,6 +232,16 @@ function showLightboxForViewOnceMedia(
228232 } ;
229233}
230234
235+ function getAuthorId ( message : MessageModel ) {
236+ return (
237+ window . ConversationController . lookupOrCreate ( {
238+ serviceId : message . get ( 'sourceServiceId' ) ,
239+ e164 : message . get ( 'source' ) ,
240+ reason : 'conversation_view.showLightBox' ,
241+ } ) ?. id || message . get ( 'conversationId' )
242+ ) ;
243+ }
244+
231245function filterValidAttachments (
232246 attributes : ReadonlyMessageAttributesType
233247) : Array < AttachmentType > {
@@ -278,12 +292,8 @@ function showLightbox(opts: {
278292 const attachments = filterValidAttachments ( message . attributes ) ;
279293 const loop = isGIF ( attachments ) ;
280294
281- const authorId =
282- window . ConversationController . lookupOrCreate ( {
283- serviceId : message . get ( 'sourceServiceId' ) ,
284- e164 : message . get ( 'source' ) ,
285- reason : 'conversation_view.showLightBox' ,
286- } ) ?. id || message . get ( 'conversationId' ) ;
295+ const authorId = getAuthorId ( message ) ;
296+ const conversationId = message . get ( 'conversationId' ) ;
287297 const receivedAt = message . get ( 'received_at' ) ;
288298 const sentAt = message . get ( 'sent_at' ) ;
289299
@@ -296,7 +306,8 @@ function showLightbox(opts: {
296306 message : {
297307 attachments : message . get ( 'attachments' ) || [ ] ,
298308 id : messageId ,
299- conversationId : authorId ,
309+ conversationId,
310+ authorId,
300311 receivedAt,
301312 receivedAtMs : Number ( message . get ( 'received_at_ms' ) ) ,
302313 sentAt,
0 commit comments