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 multiple messages in chat for forwarding & deletion #3606

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
31950ae
draft of the new Button component
farooqkz Dec 25, 2023
4494c80
rename
farooqkz Dec 25, 2023
b2f090e
Button component final
farooqkz Dec 25, 2023
c6c187c
type prop of Button is optional
farooqkz Dec 25, 2023
7c986d1
use the new Button component
farooqkz Dec 25, 2023
ffbfa4a
styles for da new button
farooqkz Dec 25, 2023
c7ae293
the left out conversion
farooqkz Dec 25, 2023
97387cc
update location of radios
farooqkz Dec 25, 2023
2c3c235
no style prop for Button
farooqkz Dec 25, 2023
ac1417b
pretty code and a fix
farooqkz Dec 25, 2023
8cd09eb
update changelog
farooqkz Dec 26, 2023
573e91a
message multi select first step. styles, actions, etc
farooqkz Dec 26, 2023
db99f2e
pretty pretty code
farooqkz Dec 26, 2023
20497a1
correct classname for SelectedMessagesAction component
farooqkz Dec 28, 2023
f0a6008
fix ForwardMessage dialog to accept multiple message ids
farooqkz Dec 28, 2023
61c37a9
fix component func signature
farooqkz Dec 28, 2023
6ec8633
using a mask for select mode
farooqkz Dec 28, 2023
c672b4f
fix select mode mask
farooqkz Dec 28, 2023
9461e8e
add selected label to selected messages action
farooqkz Dec 28, 2023
ae2d17f
pretty fixed code
farooqkz Dec 28, 2023
dbeaf0c
add new changelog entry
farooqkz Dec 28, 2023
223f62c
let's make eslint happy
farooqkz Dec 28, 2023
7f96ead
fix fix fix
farooqkz Dec 28, 2023
7e24443
fix quantity not present
farooqkz Dec 30, 2023
7d6cd22
pretty fixed code
farooqkz Dec 30, 2023
aced7b9
fix ForwardMessage dialogue. ForwardMessage.tsx seems unused and old
farooqkz Dec 30, 2023
e877813
fix openForwardDialog fn signature
farooqkz Dec 30, 2023
dd652f4
preserve chronical order
farooqkz Dec 30, 2023
429d89f
fix pretty pretty code
farooqkz Dec 30, 2023
86be3d7
use Contexts for message selection
farooqkz Dec 31, 2023
35d42bf
implement and use useSelectedMessages hook. not working yet
farooqkz Jan 2, 2024
10469c6
up
farooqkz Jan 7, 2024
0be7c39
add PR number
farooqkz Feb 18, 2024
9813240
use scss modules
farooqkz Feb 18, 2024
790b067
use scss modules
farooqkz Feb 18, 2024
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 @@ -17,6 +17,7 @@
- Prefer light theme for the help and webxdc loading pages
- Helper method to easily use confirmation dialogs #3601
- Refactor using new `useConfirmationDialog` hook #3602
- Add multi selecting messages for forwarding and deleting #3602

<a id="1_42_2"></a>

Expand Down
1 change: 1 addition & 0 deletions scss/manifest.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
@import 'message/_status-icon';
@import 'message/_message-calls';
@import 'message/_message-markdown';
@import 'message/_selected-messages-action.scss';

// misc
@import 'misc/_avatar.scss';
Expand Down
16 changes: 16 additions & 0 deletions scss/message/_selected-messages-action.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.selected-messages-action {
display: flex;
flex-direction: row;
background-color: var(--navBarBackground);
justify-content: flex-start;
align-items: center;
& > p {
width: 100%;
text-align: right;
margin: 8px;
}
& > button {
margin: 4px;
margin-bottom: 6px !important;
}
adzialocha marked this conversation as resolved.
Show resolved Hide resolved
}
52 changes: 51 additions & 1 deletion scss/misc/_delta-buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ button.delta-button-round {
border-color: rgba(206, 217, 224, 0.5);
background-image: none;
cursor: not-allowed;
color: rgba(0, 0, 0, 0.2);
color: var(--globalText);
&:hover {
background-color: rgba(206, 217, 224, 0.5);
}
Expand All @@ -35,6 +35,56 @@ button.delta-button-round {
}
}

button.delta-button {
color: var(--colorNone);
background-color: rgba(0, 0, 0, 0);
padding: 0 2px;
margin-bottom: 0px;
letter-spacing: 0px;
font-size: initial;
font-weight: 'initial';
text-align: center;
text-transform: uppercase;
padding: 5px;
border-style: solid;
border-color: transparent;
border-radius: 2px;
&:hover {
cursor: pointer;
background-color: #f1f1f1;
}

&.no-padding {
padding: 0px;
}

&.bold {
letter-spacing: 2px;
font-weight: bold;
}

&.light-bold {
letter-spacing: 1px;
font-weight: 100;
}

&.primary {
color: var(--colorPrimary);
}

&.danger {
color: var(--colorDanger);
}

&:disabled {
color: grey;
cursor: default;
&:hover {
cursor: default;
background-color: none;
}
}
}
button.delta-button-tab {
padding: 8px;
margin: 5px;
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/components/attachment/messageAttachment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ type AttachmentProps = {
conversationType: ConversationType
message: Type.Message
hasQuote: boolean
isSelectMode: boolean
}

export default function Attachment({
text,
conversationType,
message,
hasQuote,
isSelectMode,
}: AttachmentProps) {
const tx = useTranslationFunction()
const { openDialog } = useDialog()
Expand All @@ -42,6 +44,7 @@ export default function Attachment({
}
const direction = getDirection(message)
const onClickAttachment = (ev: any) => {
if (isSelectMode) return
if (message.viewType === 'Sticker') return
ev.stopPropagation()
if (isDisplayableByFullscreenMedia(message.fileMime)) {
Expand Down
15 changes: 5 additions & 10 deletions src/renderer/components/composer/EmojiAndStickerPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { useThemeCssVar } from '../../ThemeManager'

import type { EmojiData } from 'emoji-mart/index'
import useTranslationFunction from '../../hooks/useTranslationFunction'
import Button from '../ui/Button'

const DisplayedStickerPack = ({
stickerPackName,
Expand Down Expand Up @@ -89,24 +90,18 @@ export const StickerPicker = ({
))}
</div>
<div className='sticker-actions-container'>
<button
className='delta-button-round secondary'
onClick={onOpenStickerFolder}
>
<Button round type='secondary' onClick={onOpenStickerFolder}>
{tx('open_sticker_folder')}
</button>
</Button>
</div>
</>
) : (
<div className='sticker-container'>
<div className='no-stickers'>
<p className='description'>{tx('add_stickers_instructions')}</p>
<button
className='delta-button-round'
onClick={onOpenStickerFolder}
>
<Button round onClick={onOpenStickerFolder}>
{tx('open_sticker_folder')}
</button>
</Button>
</div>
</div>
)}
Expand Down
5 changes: 3 additions & 2 deletions src/renderer/components/dialogs/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { DialogBody, DialogContent, DialogWithHeader } from '../Dialog'
import useTranslationFunction from '../../hooks/useTranslationFunction'

import type { DialogProps } from '../../contexts/DialogContext'
import Button from '../ui/Button'

const log = getLogger('renderer/dialogs/About')

Expand Down Expand Up @@ -56,9 +57,9 @@ export function DCInfo(_props: any) {
</table>
</div>
<div style={{ display: 'flex', justifyContent: 'center' }}>
<button className='delta-button-round' onClick={copy2Clipboard}>
<Button round onClick={copy2Clipboard}>
{tx('copy_json')}
</button>
</Button>
</div>
</>
)
Expand Down
9 changes: 5 additions & 4 deletions src/renderer/components/dialogs/ConfirmSendingFiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from './DeltaDialog'

import type { DialogProps } from '../../contexts/DialogContext'
import Button from '../ui/Button'

type Props = {
onClick: (isConfirmed: boolean) => void
Expand Down Expand Up @@ -56,12 +57,12 @@ export default function ConfirmSendingFiles({
</div>
<DeltaDialogFooter style={{ padding: '0px 20px 10px' }}>
<DeltaDialogFooterActions>
<p className='delta-button bold primary' onClick={handleCancel}>
<Button type='primary' onClick={handleCancel}>
{tx('cancel')}
</p>
<p className={`delta-button bold primary`} onClick={handleConfirm}>
</Button>
<Button type='primary' onClick={handleConfirm}>
{tx('menu_send')}
</p>
</Button>
</DeltaDialogFooterActions>
</DeltaDialogFooter>
</SmallDialog>
Expand Down
39 changes: 17 additions & 22 deletions src/renderer/components/dialogs/DeltaDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Dialog, Classes, RadioGroup, Radio } from '@blueprintjs/core'
import classNames from 'classnames'

import type { DialogProps } from '../../contexts/DialogContext'
import Button from '../ui/Button'

export const DeltaDialogBase = React.memo<
React.PropsWithChildren<
Expand Down Expand Up @@ -311,18 +312,18 @@ export function SmallSelectDialog({
</DeltaDialogBody>
<DeltaDialogFooter style={{ marginTop: '0px', padding: '20px' }}>
<DeltaDialogFooterActions>
<p
className='delta-button primary bold'
<Button
type='primary'
onClick={() => {
onCancel && onCancel()
onClose()
}}
>
{tx('cancel')}
</p>
<p className='delta-button primary bold' onClick={saveAndClose}>
</Button>
<Button type='primary' onClick={saveAndClose}>
{tx('save_desktop')}
</p>
</Button>
</DeltaDialogFooterActions>
</DeltaDialogFooter>
</SmallDialog>
Expand Down Expand Up @@ -368,25 +369,19 @@ export function DeltaDialogOkCancelFooter({
return (
<DeltaDialogFooter>
<DeltaDialogFooterActions>
<p
className='delta-button primary bold'
style={{ marginRight: '10px' }}
onClick={onCancel}
>
{cancelLabel}
</p>
<p
<span style={{ marginRight: '10px' }}>
<Button type='primary' onClick={onCancel}>
{cancelLabel}
</Button>
</span>
<Button
//className={ 'delta-button bold primary' + disableOK ? " disabled" : "" }
className={classNames(
'delta-button bold primary test-selector-confirm',
{
disabled: disableOK,
}
)}
className='test-selector-confirm'
disabled={disableOK}
onClick={onOk}
>
{confirmLabel}
</p>
</Button>
</DeltaDialogFooterActions>
</DeltaDialogFooter>
)
Expand All @@ -398,9 +393,9 @@ export function DeltaDialogCloseFooter({ onClose }: { onClose: () => any }) {
return (
<DeltaDialogFooter>
<DeltaDialogFooterActions>
<p className={'delta-button bold primary'} onClick={onClose}>
<Button type='primary' onClick={onClose}>
{tx('close')}
</p>
</Button>
</DeltaDialogFooterActions>
</DeltaDialogFooter>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react'
import { runtime } from '../../../runtime'
import { avatarInitial } from '../../Avatar'
import useTranslationFunction from '../../../hooks/useTranslationFunction'
import Button from '../../ui/Button'

export default function ProfileImageSelector({
displayName,
Expand Down Expand Up @@ -48,21 +49,21 @@ export default function ProfileImageSelector({
<span style={{ backgroundColor: color }}>{initial}</span>
)}
<>
<button
<Button
aria-label={tx('profile_image_select')}
onClick={onClickSelectPicture}
className={'delta-button-round'}
round
>
{tx('profile_image_select')}
</button>
<button
</Button>
<Button
aria-label={tx('profile_image_delete')}
onClick={onClickRemovePicture}
className={'delta-button-round'}
round
disabled={!profilePicture}
>
{tx('profile_image_delete')}
</button>
</Button>
</>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React, { useState } from 'react'

import { DeltaInput } from '../Login-Styles'
import { SettingsStoreState } from '../../stores/settings'
import RadioGroup from '../RadioGroup'
import Radio from '../Radio'
import RadioGroup from '../ui/RadioGroup'
import Radio from '../ui/Radio'
import {
VIDEO_CHAT_INSTANCE_AUTISTICI,
VIDEO_CHAT_INSTANCE_SYSTEMLI,
Expand Down
30 changes: 26 additions & 4 deletions src/renderer/components/dialogs/ForwardMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ import styles from './styles.module.scss'
const LIST_FLAGS = C.DC_GCL_FOR_FORWARDING | C.DC_GCL_NO_SPECIALS

export default function ForwardMessage(props: {
message: T.Message
message: T.Message | number[]
farooqkz marked this conversation as resolved.
Show resolved Hide resolved
onClose: DialogProps['onClose']
onForward?: () => void
}) {
const accountId = selectedAccountId()
const tx = useTranslationFunction()
const { openDialog } = useDialog()

const { message, onClose } = props
const { message, onClose, onForward } = props
const { chatListIds, queryStr, setQueryStr } = useChatList(LIST_FLAGS)
const { isChatLoaded, loadChats, chatCache } = useLogicVirtualChatList(
chatListIds,
Expand All @@ -38,6 +39,7 @@ export default function ForwardMessage(props: {

const onChatClick = async (chatId: number) => {
const chat = await BackendRemote.rpc.getFullChatById(accountId, chatId)
const isMany = Array.isArray(message)
onClose()
if (!chat.isSelfTalk) {
selectChat(chat.id)
Expand All @@ -48,10 +50,30 @@ export default function ForwardMessage(props: {
chat
)
if (!yes) {
selectChat(message.chatId)
if (isMany) {
const message_ = await BackendRemote.rpc.getMessage(
accountId,
message[0]
)
selectChat(message_.chatId)
} else {
selectChat(message.chatId)
}
}
} else {
await forwardMessage(accountId, message.id, chat.id)
if (isMany) {
const messageObjects: T.Message[] = await Promise.all(
message.map(id => BackendRemote.rpc.getMessage(accountId, id))
)
messageObjects.sort((msgA, msgB) => msgA.timestamp - msgB.timestamp)
const messageIds = messageObjects.map(msg => msg.id)
for (const messageId of messageIds) {
await forwardMessage(accountId, messageId, chat.id)
}
} else {
await forwardMessage(accountId, message.id, chat.id)
}
onForward && onForward()
}
}
const onSearchChange = (e: React.ChangeEvent<HTMLInputElement>) =>
Expand Down
Loading