Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions ts/models/conversations.preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3991,7 +3991,14 @@ export class ConversationModel {
return getQuoteAttachment(attachments, preview, sticker);
}

async sendStickerMessage(packId: string, stickerId: number): Promise<void> {
async sendStickerMessage(
packId: string,
stickerId: number,
options: {
quote?: QuoteType;
extraReduxActions?: () => void;
} = {}
): Promise<void> {
const packData = Stickers.getStickerPack(packId);
const stickerData = Stickers.getSticker(packId, stickerId);
if (!stickerData || !packData) {
Expand Down Expand Up @@ -4047,8 +4054,12 @@ export class ConversationModel {
body: undefined,
attachments: [],
sticker,
quote: options.quote,
},
{ dontClearDraft: true }
{
dontClearDraft: true,
extraReduxActions: options.extraReduxActions,
}
)
);
window.reduxActions.stickers.useSticker(packId, stickerId);
Expand Down
23 changes: 20 additions & 3 deletions ts/state/ducks/composer.preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,9 +772,9 @@ function sendStickerMessage(
void,
RootStateType,
unknown,
NoopActionType | ShowToastActionType
NoopActionType | ShowToastActionType | SetQuotedMessageActionType
> {
return async dispatch => {
return async (dispatch, getState) => {
const conversation = window.ConversationController.get(conversationId);
if (!conversation) {
throw new Error('sendStickerMessage: No conversation found');
Expand Down Expand Up @@ -803,7 +803,24 @@ function sendStickerMessage(
}

const { packId, stickerId } = options;
void conversation.sendStickerMessage(packId, stickerId);

const state = getState();
const conversationComposerState = getComposerStateForConversation(
state.composer,
conversationId
);
const quote = conversationComposerState.quotedMessage?.quote;

void conversation.sendStickerMessage(packId, stickerId, {
quote,
extraReduxActions: () => {
setQuoteByMessageId(conversationId, undefined)(
dispatch,
getState,
undefined
);
},
});
} catch (error) {
log.error('clickSend error:', Errors.toLogFormat(error));
}
Expand Down