forked from signalapp/Signal-Desktop
-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a modal dialogue to allow confirmation when marking all convos read.
- Loading branch information
Showing
5 changed files
with
74 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React, { useState } from 'react'; | ||
import { SpacerLG } from '../basic/Text'; | ||
import { getConversationController } from '../../session/conversations'; | ||
import { markAllAsReadModal } from '../../state/ducks/modalDialog'; | ||
import { SessionButton, SessionButtonType } from '../basic/SessionButton'; | ||
import { SessionWrapperModal } from '../SessionWrapperModal'; | ||
import { ToastUtils } from '../../session/utils'; | ||
|
||
export const MarkAllAsReadDialog = () => { | ||
const titleText = window.i18n('markAllAsRead'); | ||
const okText = window.i18n('markAllAsRead'); | ||
const cancelText = window.i18n('cancel'); | ||
const [_isLoading, setIsLoading] = useState(false); | ||
|
||
const onClickOK = async () => { | ||
setIsLoading(true); | ||
|
||
const controller = getConversationController(); | ||
const convos = controller.getConversations().filter(conversation => { | ||
return conversation.isApproved(); | ||
}); | ||
for (const convo of convos) { | ||
await controller.get(convo.id).markAllAsRead(); | ||
} | ||
ToastUtils.pushToastSuccess( 'allMarkedRead', window.i18n('allMarkedAsRead')); | ||
|
||
setIsLoading(false); | ||
closeDialog(); | ||
}; | ||
|
||
const closeDialog = () => { | ||
window.inboxStore?.dispatch(markAllAsReadModal(null)); | ||
}; | ||
|
||
return ( | ||
<SessionWrapperModal title={titleText} onClose={closeDialog}> | ||
<SpacerLG /> | ||
|
||
<div className="session-modal__button-group"> | ||
<SessionButton | ||
text={okText} | ||
buttonType={SessionButtonType.Simple} | ||
onClick={onClickOK} | ||
/> | ||
<SessionButton | ||
text={cancelText} | ||
buttonType={SessionButtonType.Simple} | ||
onClick={closeDialog} | ||
/> | ||
</div> | ||
</SessionWrapperModal> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters