@@ -59,7 +59,9 @@ const removeObjReplacementChar = (text: string): string => {
5959 return text . replaceAll ( OBJ_REPLACEMENT_CHAR , ' ' ) . trim ( )
6060}
6161
62- function assignReactions ( currentUserID : string , message : BeeperMessage , _reactionRows : MappedReactionMessageRow [ ] = [ ] , filterIndex ?: number ) {
62+ const reactionStickerAssetURL = ( accountID : string , rowID : MappedReactionMessageRow [ 'ROWID' ] ) => `asset://${ accountID } /reaction-sticker/${ rowID } `
63+
64+ function assignReactions ( currentUserID : string , accountID : string , message : BeeperMessage , _reactionRows : MappedReactionMessageRow [ ] = [ ] , filterIndex ?: number ) {
6365 const reactions : MessageReaction [ ] = [ ]
6466 const reactionRows = filterIndex != null
6567 ? _reactionRows . filter ( r => r . associated_message_guid . startsWith ( `p:${ filterIndex } /` ) )
@@ -75,6 +77,7 @@ function assignReactions(currentUserID: string, message: BeeperMessage, _reactio
7577 id : participantID ,
7678 reactionKey : actionKey === 'emoji' ? reaction . associated_message_emoji : actionKey ,
7779 participantID,
80+ imgURL : actionKey === 'sticker' ? reactionStickerAssetURL ( accountID , reaction . ROWID ) : undefined ,
7881 } )
7982 } else if ( actionType === 'unreacted' ) {
8083 const index = reactions . findIndex ( r => r . id === participantID )
@@ -241,7 +244,7 @@ const UUID_START = 11
241244const UUID_LENGTH = 36
242245const UUID_REGEX = / ^ [ 0 - 9 a - f ] { 8 } - [ 0 - 9 a - f ] { 4 } - [ 1 - 5 ] [ 0 - 9 a - f ] { 3 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 12 } $ / i
243246// eslint-disable-next-line @typescript-eslint/default-param-last -- FIXME(skip)
244- export function mapMessage ( msgRow : MappedMessageRow , attachmentRows : MappedAttachmentRow [ ] = [ ] , reactionRows : MappedReactionMessageRow [ ] , currentUserID : string ) : BeeperMessage [ ] {
247+ export function mapMessage ( msgRow : MappedMessageRow , attachmentRows : MappedAttachmentRow [ ] = [ ] , reactionRows : MappedReactionMessageRow [ ] , currentUserID : string , accountID : string ) : BeeperMessage [ ] {
245248 const attachments = attachmentRows . map ( a => mapAttachment ( a , msgRow ) ) . filter ( attachment => attachment != null )
246249 const isSMS = msgRow . service === 'SMS' || msgRow . service === 'RCS'
247250 const isGroup = ! ! msgRow . room_name
@@ -615,9 +618,10 @@ export function mapMessage(msgRow: MappedMessageRow, attachmentRows: MappedAttac
615618 type : reactionType ,
616619 messageID : m . linkedMessageID ,
617620 participantID : m . senderID ,
621+ imgURL : assocMsgType === 'reacted_sticker' ? attachmentRows [ 0 ] ?. filename : undefined ,
618622 reactionKey : actionKey === 'emoji' ? msgRow . associated_message_emoji : actionKey ,
619623 }
620- if ( actionKey === 'emoji' || actionKey in supportedReactions ) {
624+ if ( actionKey === 'emoji' || actionKey === 'sticker' || actionKey in supportedReactions ) {
621625 m . parseTemplate = true
622626 m . text = `${ msgRow . is_from_me ? 'You' : '{{sender}}' } ${ REACTION_VERB_MAP [ assocMsgType ] } ${ msi ?. ams ? `"${ msi ?. ams } "` : 'a message' } `
623627 m . isHidden = true
@@ -629,7 +633,7 @@ export function mapMessage(msgRow: MappedMessageRow, attachmentRows: MappedAttac
629633
630634 return messages . map ( msg => {
631635 // texts.log('assigning reactions', msg.id, msg.index, reactionRows)
632- assignReactions ( currentUserID , msg , reactionRows , messages . length === 1 ? undefined : msg . extra ?. part )
636+ assignReactions ( currentUserID , accountID , msg , reactionRows , messages . length === 1 ? undefined : msg . extra ?. part )
633637 return msg
634638 } )
635639}
@@ -672,6 +676,7 @@ function mapParticipant({ participantID: id, uncanonicalized_id }: MappedHandleR
672676export const mapAccountLogin = ( al : string ) => al ?. replace ( / ^ ( E | P ) : / , '' )
673677
674678type Context = {
679+ accountID : string
675680 currentUserID : string
676681 handleRowsMap : { [ threadID : string ] : MappedHandleRow [ ] }
677682 mapMessageArgsMap : { [ threadID : string ] : [ MappedMessageRow [ ] , MappedAttachmentRow [ ] , MappedReactionMessageRow [ ] ] }
@@ -688,16 +693,16 @@ type Context = {
688693
689694// @ts -expect-error FIXME(skip): argument ordering
690695// eslint-disable-next-line @typescript-eslint/default-param-last
691- export function mapMessages ( messages : MappedMessageRow [ ] , attachmentRows ?: MappedAttachmentRow [ ] , reactionRows ?: MappedReactionMessageRow [ ] , currentUserID : string ) : BeeperMessage [ ] {
696+ export function mapMessages ( messages : MappedMessageRow [ ] , attachmentRows ?: MappedAttachmentRow [ ] , reactionRows ?: MappedReactionMessageRow [ ] , currentUserID : string , accountID : string ) : BeeperMessage [ ] {
692697 const groupedAttachmentRows = groupBy ( attachmentRows , 'msgRowID' )
693698 const groupedReactionRows = groupBy ( reactionRows , r => r . associated_message_guid . replace ( assocMsgGuidPrefix , '' ) )
694699 return messages
695- . flatMap ( message => mapMessage ( message , groupedAttachmentRows [ message . ROWID ] , groupedReactionRows [ message . guid ] , currentUserID ) )
700+ . flatMap ( message => mapMessage ( message , groupedAttachmentRows [ message . ROWID ] , groupedReactionRows [ message . guid ] , currentUserID , accountID ) )
696701 . filter ( Boolean )
697702}
698703
699704export function mapThread ( chat : MappedChatRow , context : Context ) : BeeperThread {
700- const { currentUserID } = context
705+ const { currentUserID, accountID } = context
701706 const handleRows = context . handleRowsMap [ chat . guid ]
702707 const mapMessageArgs = context . mapMessageArgsMap ?. [ chat . guid ]
703708 const selfID = chat . last_addressed_handle || mapAccountLogin ( chat . account_login ) || currentUserID
@@ -707,7 +712,7 @@ export function mapThread(chat: MappedChatRow, context: Context): BeeperThread {
707712 const participants = [ ...handleRows . map ( h => mapParticipant ( h , chat . display_name ) ) , selfParticipant ] . filter ( participant => participant != null )
708713 const isGroup = ! ! chat . room_name
709714 const isReadOnly = chat . state === 0 && chat . properties != null
710- const messages = mapMessageArgs ? mapMessages ( ...mapMessageArgs , currentUserID ) : [ ]
715+ const messages = mapMessageArgs ? mapMessages ( ...mapMessageArgs , currentUserID , accountID ) : [ ]
711716 /*
712717 props = {
713718 "com.apple.iChat.LastArchivedMessageID": [ 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', 101010 ],
0 commit comments