mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-02-15 07:28:59 +00:00
Fix go to pinned message targeting outgoing messages
This commit is contained in:
@@ -895,6 +895,7 @@ type ReadableInterface = {
|
||||
_getAllReactions: () => Array<ReactionType>;
|
||||
|
||||
getMessageByAuthorAciAndSentAt: (
|
||||
ourAci: AciString,
|
||||
authorAci: AciString,
|
||||
sentAtTimestamp: number,
|
||||
options: { includeEdits: boolean }
|
||||
|
||||
@@ -3450,11 +3450,18 @@ function getAllMessageIds(db: ReadableDB): Array<string> {
|
||||
|
||||
function getMessageByAuthorAciAndSentAt(
|
||||
db: ReadableDB,
|
||||
ourAci: AciString,
|
||||
authorAci: AciString,
|
||||
sentAtTimestamp: number,
|
||||
options: { includeEdits: boolean }
|
||||
): MessageType | null {
|
||||
return db.transaction(() => {
|
||||
const isSentByUs = ourAci === authorAci;
|
||||
|
||||
const senderPredicate = isSentByUs
|
||||
? sqlFragment`(messages.sourceServiceId = ${authorAci} OR messages.type IS 'outgoing')`
|
||||
: sqlFragment`(messages.sourceServiceId = ${authorAci})`;
|
||||
|
||||
// Return sentAt/readStatus from the messages table, when we edit a message
|
||||
// we add the original message to messages.editHistory and update original
|
||||
// message's sentAt/readStatus columns.
|
||||
@@ -3466,14 +3473,14 @@ function getMessageByAuthorAciAndSentAt(
|
||||
FROM edited_messages
|
||||
INNER JOIN messages ON
|
||||
messages.id = edited_messages.messageId
|
||||
WHERE messages.sourceServiceId = ${authorAci}
|
||||
WHERE ${senderPredicate}
|
||||
AND edited_messages.sentAt = ${sentAtTimestamp}
|
||||
`;
|
||||
|
||||
const messagesQuery = sqlFragment`
|
||||
SELECT ${MESSAGE_COLUMNS_FRAGMENT}
|
||||
FROM messages
|
||||
WHERE messages.sourceServiceId = ${authorAci}
|
||||
WHERE ${senderPredicate}
|
||||
AND messages.sent_at = ${sentAtTimestamp}
|
||||
`;
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ import {
|
||||
isVideoTypeSupported,
|
||||
} from '../../util/GoogleChrome.std.js';
|
||||
import type { StateThunk } from '../types.std.js';
|
||||
import { itemStorage } from '../../textsecure/Storage.preload.js';
|
||||
|
||||
const { debounce, isEqual } = lodash;
|
||||
|
||||
@@ -390,7 +391,10 @@ function scrollToPinnedMessage(
|
||||
pinMessage: PinMessageData
|
||||
): StateThunk<ShowToastActionType | ScrollToMessageActionType> {
|
||||
return async (dispatch, getState) => {
|
||||
const ourAci = itemStorage.user.getCheckedAci();
|
||||
|
||||
const pinnedMessage = await DataReader.getMessageByAuthorAciAndSentAt(
|
||||
ourAci,
|
||||
pinMessage.targetAuthorAci,
|
||||
pinMessage.targetSentTimestamp,
|
||||
{ includeEdits: true }
|
||||
|
||||
Reference in New Issue
Block a user