Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select chat after forwarding #4029

Merged
merged 3 commits into from
Jul 22, 2024
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- fix update unread badge on when muting / unmuting a chat #4020
- fix update unread badge on receiving device messages #4020
- fix target chat was not opened on notification click #3983
- fix scroll to forwarded message #3834
- fix CSP bypass in webxdc (not a vulnerability) #4011

<a id="1_46_1"></a>
Expand Down
18 changes: 16 additions & 2 deletions src/renderer/components/dialogs/ForwardMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function ForwardMessage(props: Props) {
const tx = useTranslationFunction()
const { openDialog } = useDialog()
const { selectChat } = useChat()
const { forwardMessage } = useMessage()
const { forwardMessage, jumpToMessage } = useMessage()

const { chatListIds, queryStr, setQueryStr } = useChatList(LIST_FLAGS)
const { isChatLoaded, loadChats, chatCache } =
Expand All @@ -45,14 +45,28 @@ export default function ForwardMessage(props: Props) {
const chat = await BackendRemote.rpc.getFullChatById(accountId, chatId)
onClose()
if (!chat.isSelfTalk) {
// show the target chat to avoid unintended forwarding to the wrong chat
selectChat(accountId, chat.id)
Copy link
Member

@Simon-Laux Simon-Laux Jul 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is there because then you see the chat you are going to forward to, to prevent user mistakes.
In other words this behaviour of opening the chat before confirm and going back if you cancel is intentional.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok - that should be worth a line of an explaining comment in the code :-)

So I have to find why the already opened chat is not scrolling down I guess

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe calling select chat again could already work. or whatever happens when you click again on the chat in the chat-list if you have already selected the chat,

const yes = await confirmForwardMessage(
openDialog,
accountId,
message,
chat
)
if (!yes) {
if (yes) {
// get the id of forwarded message
// to jump to the message
const messageIds = await BackendRemote.rpc.getMessageIds(
accountId,
chatId,
false,
true
)
const lastMessage = messageIds[messageIds.length - 1]
if (lastMessage) {
jumpToMessage(accountId, lastMessage)
}
} else {
selectChat(accountId, message.chatId)
}
} else {
Expand Down
Loading