Skip to content

Commit fcf74fb

Browse files
author
Erika Perugachi
authored
Merge pull request #454 from erikaperugachi/editor
Editor
2 parents 6cf77e3 + 271ffab commit fcf74fb

File tree

16 files changed

+132
-18
lines changed

16 files changed

+132
-18
lines changed

electron_app/src/DBManager.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,8 @@ const getEmailsGroupByThreadByParams = (params = {}) => {
545545
limit,
546546
contactTypes = ['from'],
547547
contactFilter,
548-
rejectedLabelIds
548+
rejectedLabelIds,
549+
threadIdRejected
549550
} = params;
550551

551552
let queryDb = baseThreadQuery({
@@ -554,13 +555,13 @@ const getEmailsGroupByThreadByParams = (params = {}) => {
554555
limit,
555556
contactTypes,
556557
contactFilter,
557-
rejectedLabelIds
558+
rejectedLabelIds,
559+
threadIdRejected
558560
});
559561

560562
if (plain) {
561563
return partThreadQueryByMatchText(queryDb, text);
562564
}
563-
564565
if (text) {
565566
queryDb = queryDb
566567
.andWhere('preview', 'like', `%${text}%`)
@@ -624,7 +625,8 @@ const baseThreadQuery = ({
624625
limit,
625626
contactTypes,
626627
contactFilter,
627-
rejectedLabelIds
628+
rejectedLabelIds,
629+
threadIdRejected
628630
}) => {
629631
const {
630632
labelsQuery,
@@ -633,7 +635,7 @@ const baseThreadQuery = ({
633635
whereRawParams
634636
} = getQueryParamsIfOrNotRejectedLabel({ labelId, rejectedLabelIds });
635637

636-
return db
638+
let query = db
637639
.select(
638640
`${Table.EMAIL}.*`,
639641
db.raw(`IFNULL(${Table.EMAIL}.threadId ,${Table.EMAIL}.id) as uniqueId`),
@@ -683,8 +685,12 @@ const baseThreadQuery = ({
683685
`${Table.EMAIL_CONTACT}.contactId`,
684686
`${Table.CONTACT}.id`
685687
)
686-
.whereRaw(whereRawQuery, whereRawParams)
687-
.where(`${Table.EMAIL}.date`, '<', date || 'now')
688+
.whereRaw(whereRawQuery, whereRawParams);
689+
if (threadIdRejected !== undefined) {
690+
query = query.whereNot('uniqueId', threadIdRejected);
691+
}
692+
return query
693+
.andWhere(`${Table.EMAIL}.date`, '<', date || 'now')
688694
.groupBy('uniqueId')
689695
.orderBy(`${Table.EMAIL}.date`, 'DESC')
690696
.limit(limit || 20);

electron_app/src/__integrations__/Email.integration.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,34 @@ describe('Load data thread from Email Table:', () => {
315315
const threads = await DBManager.getEmailsGroupByThreadByParams(params);
316316
expect(threads).toMatchSnapshot();
317317
});
318+
319+
it('should load threads from DB with the correct shape: inbox. Scroll action', async () => {
320+
const params = {
321+
labelId: 1,
322+
rejectedLabelIds: [2, 6],
323+
limit: 1
324+
};
325+
const [lastThread] = await DBManager.getEmailsGroupByThreadByParams(params);
326+
const maxDate = lastThread.maxDate;
327+
const threadIdRejected = lastThread.threadId;
328+
expect(lastThread).toMatchObject(
329+
expect.objectContaining({
330+
threadId: 'threadC',
331+
emailIds: '3,4'
332+
})
333+
);
334+
const moreParams = {
335+
labelId: 1,
336+
rejectedLabelIds: [2, 6],
337+
limit: 1,
338+
date: maxDate,
339+
threadIdRejected
340+
};
341+
const moreLastThreads = await DBManager.getEmailsGroupByThreadByParams(
342+
moreParams
343+
);
344+
expect(moreLastThreads).toEqual([]);
345+
});
318346
});
319347

320348
describe('Store relation data to EmailLabel Table: ', () => {

electron_app/src/utils/EmailUtils.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ const formRecipients = recipientString => {
1717
});
1818
};
1919

20+
const formAppSign = () => {
21+
return '<br/><span style="font-size: 12px;">Sent with <a style="color: #0091ff; text-decoration: none;" href="https://www.criptext.com/dl">Criptext</a></span>';
22+
};
23+
2024
const getEmailAddressesFromEmailObject = emails => {
2125
return emails.map(item => item.email || item);
2226
};
@@ -238,7 +242,7 @@ const formOutgoingEmailFromData = ({
238242
const email = {
239243
key: Date.now(),
240244
subject: textSubject,
241-
content: body,
245+
content: `${body}${formAppSign()}`,
242246
preview: cleanHTML(body).slice(0, 100),
243247
date: Date.now(),
244248
status: EmailStatus.SENDING,
@@ -269,7 +273,7 @@ const formOutgoingEmailFromData = ({
269273
emailData,
270274
criptextRecipients,
271275
externalRecipients,
272-
body
276+
body: email.content
273277
};
274278
};
275279

electron_app/src/utils/__tests__/__snapshots__/EmailUtils.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports[`[Form outgoing email] Should form outgoing email from data 1`] = `
44
Object {
5-
"body": "<p>Hello</p>",
5+
"body": "<p>Hello</p><br/><span style=\\"font-size: 12px;\\">Sent with <a style=\\"color: #0091ff; text-decoration: none;\\" href=\\"https://www.criptext.com/dl\\">Criptext</a></span>",
66
"criptextRecipients": Array [
77
Object {
88
"recipientId": "toUser",
@@ -19,7 +19,7 @@ Object {
1919
],
2020
"emailData": Object {
2121
"email": Object {
22-
"content": "<p>Hello</p>",
22+
"content": "<p>Hello</p><br/><span style=\\"font-size: 12px;\\">Sent with <a style=\\"color: #0091ff; text-decoration: none;\\" href=\\"https://www.criptext.com/dl\\">Criptext</a></span>",
2323
"date": 1524861748481,
2424
"isMuted": false,
2525
"key": 1524861748481,

email_composer/src/utils/EmailUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export const formNewEmailFromData = data => {
179179
);
180180
const htmlBody = EditorState.createWithContent(contentState);
181181
return {
182-
toEmails: [formRecipientObject(data.recipients.to)],
182+
toEmails: data.recipients ? [formRecipientObject(data.recipients.to)] : [],
183183
textSubject: data.email.subject,
184184
htmlBody
185185
};

email_mailbox/src/app.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,9 @@ TABLE OF CONTENTS
396396
.icon-clock:before {
397397
content: "\e93e";
398398
}
399+
.icon-mood-happy:before {
400+
content: "\e934";
401+
}
399402

400403
/* 2.- CONTENT
401404
----------------------------- */

email_mailbox/src/components/SideBar.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ const SideBar = props => (
6464
</ul>
6565
</nav>
6666
<LabelEdit />
67+
<div className="option-item" onClick={() => props.onClickInviteFriend()}>
68+
<div>
69+
<i className="icon-mood-happy" />
70+
</div>
71+
<span>Invite a Friend</span>
72+
</div>
6773
</div>
6874
</aside>
6975
);
@@ -82,6 +88,7 @@ SideBar.propTypes = {
8288
items: PropTypes.array,
8389
labels: PropTypes.object,
8490
mailboxSelected: PropTypes.string,
91+
onClickInviteFriend: PropTypes.func,
8592
onToggleShowLabelView: PropTypes.func,
8693
onToggleSideBar: PropTypes.func,
8794
showLabels: PropTypes.bool

email_mailbox/src/components/ThreadsWrapper.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,15 @@ class ThreadsWrapper extends Component {
9595

9696
if (scrollTop + height > scrollHeight - SCROLL_BOTTOM_LIMIT && lastThread) {
9797
const date = lastThread.get('maxDate');
98+
const threadIdRejected = lastThread.get('threadId');
9899
if (this.state.lastMinDate !== date) {
99100
this.setState({ lastMinDate: date }, () => {
100101
this.props.onLoadThreads(
101102
this.props.mailboxSelected,
102103
false,
103104
this.props.searchParams,
104-
date
105+
date,
106+
threadIdRejected
105107
);
106108
});
107109
}

email_mailbox/src/components/email.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@
221221
>div{
222222
margin: 10px 0;
223223
}
224+
225+
p{
226+
font-family: 'NunitoSans';
227+
}
224228
}
225229

226230
.email-files{

email_mailbox/src/components/sidebar.scss

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,28 @@
5454
}
5555
}
5656
}
57+
58+
.option-item{
59+
align-items: center;
60+
display: flex;
61+
cursor: pointer;
62+
flex-direction: row;
63+
flex-grow: 0;
64+
height: 40px;
65+
66+
div i{
67+
color: #c1c1c2;
68+
font-size: 14px;
69+
margin: 0 10px 0 32px;
70+
}
71+
72+
span{
73+
color: black;
74+
font-size: 13px;
75+
font-weight: 300;
76+
margin-left: 15px;
77+
}
78+
}
5779
}
5880

5981
.navigation-partial-mail::-webkit-scrollbar-track{
@@ -202,6 +224,12 @@
202224
.label-container{
203225
display: none;
204226
}
227+
228+
.option-item{
229+
span{
230+
display: none;
231+
}
232+
}
205233
}
206234

207235
@media screen and (max-width: $_MAX_WIDTH_SCREEN) {
@@ -253,4 +281,10 @@
253281
.label-container{
254282
display: none;
255283
}
284+
285+
.option-item{
286+
span{
287+
display: none;
288+
}
289+
}
256290
}

0 commit comments

Comments
 (0)