Skip to content

Commit d573db7

Browse files
authored
Merge pull request #1391 from Hirobreak/update-popup
update for popup when receiving large image
2 parents 289f3b3 + fda5a7e commit d573db7

File tree

10 files changed

+189
-6
lines changed

10 files changed

+189
-6
lines changed

email_mailbox/src/components/Panel.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import MigrationPopupWrapper from './MigrationPopupWrapper';
1212
import PasswordChangedPopupWrapper from './PasswordChangedPopupWrapper';
1313
import RestoreBackupPopupWrapper from './RestoreBackupPopupWrapper';
1414
import SuspendedAccountPopup from './SuspendedAccountPopup';
15+
import UpdatePopup from './UpdatePopup';
1516
import { MAILBOX_POPUP_TYPES } from './PanelWrapper';
1617
import { mySettings } from '../utils/electronInterface';
1718
import UserGuide from './UserGuide';
@@ -48,6 +49,7 @@ const Panel = props => (
4849
)}
4950
{!props.isHiddenMailboxPopup &&
5051
renderMailboxPopup({
52+
data: props.mailboxPopupData,
5153
type: props.mailboxPopupType,
5254
isHidden: props.isHiddenMailboxPopup,
5355
...props
@@ -56,7 +58,7 @@ const Panel = props => (
5658
</div>
5759
);
5860

59-
const renderMailboxPopup = ({ type, isHidden, ...props }) => {
61+
const renderMailboxPopup = ({ data, type, isHidden, ...props }) => {
6062
switch (type) {
6163
case MAILBOX_POPUP_TYPES.ACCOUNT_DELETED: {
6264
const Accountdeletedpopup = PopupHOC(AccountDeletedPopup);
@@ -67,6 +69,20 @@ const renderMailboxPopup = ({ type, isHidden, ...props }) => {
6769
/>
6870
);
6971
}
72+
case MAILBOX_POPUP_TYPES.BIG_UPDATE_AVAILABLE: {
73+
const BigUpdatePopup = PopupHOC(UpdatePopup);
74+
return (
75+
<BigUpdatePopup
76+
{...data}
77+
isHidden={isHidden}
78+
popupPosition={{ left: '50%', top: '50%' }}
79+
theme={'dark'}
80+
onUpdateNow={props.onUpdateNow}
81+
onTogglePopup={props.onCloseMailboxPopup}
82+
isClosable={true}
83+
/>
84+
);
85+
}
7086
case MAILBOX_POPUP_TYPES.CREATING_BACKUP_FILE: {
7187
const Creatingbackupfilepopup = PopupHOC(CreatingBackupFilePopup);
7288
return (
@@ -153,7 +169,9 @@ const defineWrapperClass = (isOpenSideBar, isOpenActivityPanel) => {
153169
};
154170

155171
renderMailboxPopup.propTypes = {
172+
data: PropTypes.object,
156173
onCloseMailboxPopup: PropTypes.func,
174+
onUpdateNow: PropTypes.func,
157175
isHidden: PropTypes.bool,
158176
props: PropTypes.object,
159177
type: PropTypes.string
@@ -164,6 +182,7 @@ Panel.propTypes = {
164182
isOpenActivityPanel: PropTypes.bool,
165183
isOpenSideBar: PropTypes.bool,
166184
isOpenWelcome: PropTypes.bool,
185+
mailboxPopupData: PropTypes.object,
167186
mailboxPopupType: PropTypes.string,
168187
onClickCloseWelcome: PropTypes.func,
169188
onClickThreadBack: PropTypes.func,

email_mailbox/src/components/PanelWrapper.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
Event,
88
checkUserGuideSteps
99
} from '../utils/electronEventInterface';
10-
import { processPendingEvents } from '../utils/ipc';
10+
import { checkForUpdates, processPendingEvents } from '../utils/ipc';
1111
import { LabelType, getPendingRestoreStatus } from '../utils/electronInterface';
1212
import { SectionType } from '../utils/const';
1313
import {
@@ -21,6 +21,7 @@ import { USER_GUIDE_STEPS } from './UserGuide';
2121

2222
const MAILBOX_POPUP_TYPES = {
2323
ACCOUNT_DELETED: 'account-deleted',
24+
BIG_UPDATE_AVAILABLE: 'big-update-available',
2425
CREATING_BACKUP_FILE: 'creating-backup-file',
2526
DEVICE_REMOVED: 'device-removed',
2627
MIGRATE_ALICE: 'migrate-alice',
@@ -42,6 +43,7 @@ class PanelWrapper extends Component {
4243
isOpenSideBar: true,
4344
isOpenWelcome: true,
4445
mailboxPopupType: undefined,
46+
mailboxPopupData: undefined,
4547
sectionSelected: {
4648
type: SectionType.MAILBOX,
4749
params: {
@@ -72,13 +74,15 @@ class PanelWrapper extends Component {
7274
isOpenSideBar={this.state.isOpenSideBar}
7375
isOpenWelcome={this.state.isOpenWelcome}
7476
mailboxPopupType={this.state.mailboxPopupType}
77+
mailboxPopupData={this.state.mailboxPopupData}
7578
onClickCloseWelcome={this.handleCloseWelcome}
7679
onClickSection={this.handleClickSection}
7780
onClickThreadBack={this.handleClickThreadBack}
7881
onCloseMailboxPopup={this.handleCloseMailboxPopup}
7982
onToggleActivityPanel={this.handleToggleActivityPanel}
8083
onToggleSideBar={this.handleToggleSideBar}
8184
sectionSelected={this.state.sectionSelected}
85+
onUpdateNow={this.handleUpdateNow}
8286
{...this.props}
8387
/>
8488
);
@@ -90,6 +94,11 @@ class PanelWrapper extends Component {
9094
this.handleCheckRestoreBackup();
9195
}
9296

97+
handleUpdateNow = () => {
98+
checkForUpdates(true);
99+
this.handleCloseMailboxPopup();
100+
};
101+
93102
handleClickSection = (type, params) => {
94103
switch (type) {
95104
case SectionType.MAILBOX:
@@ -189,7 +198,8 @@ class PanelWrapper extends Component {
189198
handleCloseMailboxPopup = () => {
190199
this.setState({
191200
isHiddenMailboxPopup: true,
192-
mailboxPopupType: undefined
201+
mailboxPopupType: undefined,
202+
mailboxPopupData: undefined
193203
});
194204
};
195205

@@ -210,6 +220,7 @@ class PanelWrapper extends Component {
210220
addEvent(Event.ACCOUNT_DELETED, this.accountDeletedListenerCallback);
211221
addEvent(Event.SET_SECTION_TYPE, this.setSectionTypeListenerCallback);
212222
addEvent(Event.SUSPENDED_ACCOUNT, this.suspendedAccountListenerCallback);
223+
addEvent(Event.BIG_UPDATE_AVAILABLE, this.handleBigUpdateListenerCallback);
213224
addEvent(
214225
Event.REACTIVATED_ACCOUNT,
215226
this.reactivatedAccountListenerCallback
@@ -266,7 +277,8 @@ class PanelWrapper extends Component {
266277
enableWindowListenerCallback = () => {
267278
this.setState({
268279
isHiddenMailboxPopup: true,
269-
mailboxPopupType: undefined
280+
mailboxPopupType: undefined,
281+
mailboxPopupData: undefined
270282
});
271283
};
272284

@@ -501,6 +513,14 @@ class PanelWrapper extends Component {
501513
});
502514
};
503515

516+
handleBigUpdateListenerCallback = data => {
517+
this.setState({
518+
isHiddenMailboxPopup: false,
519+
mailboxPopupType: MAILBOX_POPUP_TYPES.BIG_UPDATE_AVAILABLE,
520+
mailboxPopupData: data
521+
});
522+
};
523+
504524
reactivatedAccountListenerCallback = () => {
505525
const isShowingPopup = !this.state.isHiddenMailboxPopup;
506526
const isVisibleSuspendedAccountPopup =
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import string from '../lang';
4+
import './updatepopup.scss';
5+
6+
const { title, buttons } = string.popups.new_update;
7+
8+
const UpdatePopup = props => {
9+
return (
10+
<div className="popup-content update-popup">
11+
<div className="popup-title">
12+
<h1>{title}</h1>
13+
</div>
14+
<div className="popup-img">
15+
<img alt="update preview" src={props.largeImageUrl} />
16+
</div>
17+
<div className="popup-subtitle">
18+
<p>{props.title}</p>
19+
</div>
20+
<div className="popup-paragraph">
21+
<p>{props.body}</p>
22+
</div>
23+
<div className="popup-buttons">
24+
<button
25+
className="button-a popup-confirm-button"
26+
onClick={props.onUpdateNow}
27+
>
28+
<span>{buttons.update}</span>
29+
</button>
30+
<button
31+
className="button-a popup-cancel-button"
32+
onClick={props.onTogglePopup}
33+
>
34+
<span>{buttons.later}</span>
35+
</button>
36+
</div>
37+
</div>
38+
);
39+
};
40+
41+
UpdatePopup.propTypes = {
42+
body: PropTypes.string,
43+
largeImageUrl: PropTypes.string,
44+
title: PropTypes.string,
45+
onTogglePopup: PropTypes.func,
46+
onUpdateNow: PropTypes.func
47+
};
48+
49+
export default UpdatePopup;
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
.update-popup {
2+
3+
.popup-title {
4+
font-size: 18px;
5+
margin-top: 15px;
6+
}
7+
8+
.popup-img {
9+
margin: 20px 0px 26px 0px;
10+
11+
> img {
12+
width: 100%;
13+
}
14+
}
15+
16+
.popup-subtitle {
17+
color: #484747;
18+
font-size: 18px;
19+
height: 35px;
20+
justify-content: center;
21+
display: flex;
22+
align-items: center;
23+
24+
> p {
25+
margin: 0px;
26+
padding: 0px;
27+
}
28+
}
29+
30+
.popup-paragraph {
31+
margin-top: 0px !important;
32+
margin: 0px;
33+
34+
> p {
35+
margin: 0px;
36+
}
37+
}
38+
39+
.popup-buttons {
40+
width: 100%;
41+
align-items: center;
42+
flex-direction: column !important;
43+
44+
.popup-cancel-button {
45+
margin-top: 2px;
46+
color: #5d5b5b !important;
47+
font-size: 12px !important;
48+
font-weight: 600;
49+
}
50+
}
51+
52+
}

email_mailbox/src/lang/de.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,13 @@
477477
"cancelSyncLabel": "Synchronisation abbrechen",
478478
"continueLabel": "Fortfahren"
479479
},
480+
"new_update": {
481+
"title": "New Update",
482+
"buttons": {
483+
"update": "Update Now",
484+
"later": "Maybe Later"
485+
}
486+
},
480487
"permanently_delete": {
481488
"title": "Warnung!",
482489
"message": "Diese Elemente werden dauerhaft gelöscht und können nicht wiederhergestellt werden. Sind Sie sicher?",

email_mailbox/src/lang/en.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,13 @@
501501
"upgrade": "Unable to upgrade account!"
502502
}
503503
},
504+
"new_update": {
505+
"title": "New Update",
506+
"buttons": {
507+
"update": "Update Now",
508+
"later": "Maybe Later"
509+
}
510+
},
504511
"permanently_delete": {
505512
"title": "Warning!",
506513
"message": "This elements will be permanently deleted and you will not be able to recover them. Are you sure?",

email_mailbox/src/lang/es.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,13 @@
501501
"upgrade": "No fue posible actualizar la cuenta!"
502502
}
503503
},
504+
"new_update": {
505+
"title": "Nueva Actualización",
506+
"buttons": {
507+
"update": "Actualizar",
508+
"later": "Tal vez Después"
509+
}
510+
},
504511
"permanently_delete": {
505512
"title": "Advertencia!",
506513
"message": "Estos elementos se eliminarán permanentemente y no podrás recuperarlos. ¿Estás seguro?",

email_mailbox/src/lang/fr.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,13 @@
477477
"cancelSyncLabel": "Annuler la synchronisation",
478478
"continueLabel": "Continuer"
479479
},
480+
"new_update": {
481+
"title": "New Update",
482+
"buttons": {
483+
"update": "Update Now",
484+
"later": "Maybe Later"
485+
}
486+
},
480487
"permanently_delete": {
481488
"title": "Attention !",
482489
"message": "Ces éléments seront supprimés de façon permanente et vous ne pourrez pas les récupérer. Êtes-vous sûr ?",

email_mailbox/src/lang/ru.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,13 @@
477477
"cancelSyncLabel": "Отменить синхронизацию",
478478
"continueLabel": "Продолжить"
479479
},
480+
"new_update": {
481+
"title": "New Update",
482+
"buttons": {
483+
"update": "Update Now",
484+
"later": "Maybe Later"
485+
}
486+
},
480487
"permanently_delete": {
481488
"title": "Предупреждение!",
482489
"message": "Эти элементы будут удалены навсегда и вы не сможете восстановить их. Вы уверены?",

email_mailbox/src/utils/electronEventInterface.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,11 +1243,18 @@ const handlePeerRecoveryEmailConfirmed = () => {
12431243

12441244
const handleNewAnnouncementEvent = async ({ rowid, params }) => {
12451245
const { code } = params;
1246-
const { title } = await getNews({ code });
1246+
const updateAnnouncement = await getNews({ code });
1247+
if (!updateAnnouncement) return { rowid };
1248+
if (updateAnnouncement.largeImageUrl) {
1249+
emitter.emit(Event.BIG_UPDATE_AVAILABLE, {
1250+
...updateAnnouncement
1251+
});
1252+
return { rowid };
1253+
}
12471254
const messageData = {
12481255
...Messages.news.announcement,
12491256
type: MessageType.ANNOUNCEMENT,
1250-
description: title
1257+
description: updateAnnouncement.title
12511258
};
12521259
emitter.emit(Event.DISPLAY_MESSAGE, messageData);
12531260
return { rowid };
@@ -1832,6 +1839,7 @@ export const sendMailboxEvent = (eventName, eventData) => {
18321839

18331840
export const Event = {
18341841
ACCOUNT_DELETED: 'account-deleted',
1842+
BIG_UPDATE_AVAILABLE: 'big-update-available',
18351843
DEVICE_REMOVED: 'device-removed',
18361844
DISABLE_WINDOW: 'add-window-overlay',
18371845
DISPLAY_MESSAGE: 'display-message',

0 commit comments

Comments
 (0)