From 4961ef6d02128891afb2abb4ba5709d3e314cb30 Mon Sep 17 00:00:00 2001 From: erikaperugachi Date: Tue, 2 Oct 2018 12:26:32 -0500 Subject: [PATCH 1/3] Fix scroll. Fix #436 --- electron_app/src/DBManager.js | 20 ++++++++----- .../src/__integrations__/Email.integration.js | 28 +++++++++++++++++++ .../src/components/ThreadsWrapper.js | 4 ++- email_mailbox/src/components/email.scss | 4 +++ email_mailbox/src/containers/Threads.js | 8 ++++-- 5 files changed, 53 insertions(+), 11 deletions(-) diff --git a/electron_app/src/DBManager.js b/electron_app/src/DBManager.js index 69277db60..f92a19896 100644 --- a/electron_app/src/DBManager.js +++ b/electron_app/src/DBManager.js @@ -545,7 +545,8 @@ const getEmailsGroupByThreadByParams = (params = {}) => { limit, contactTypes = ['from'], contactFilter, - rejectedLabelIds + rejectedLabelIds, + threadIdRejected } = params; let queryDb = baseThreadQuery({ @@ -554,13 +555,13 @@ const getEmailsGroupByThreadByParams = (params = {}) => { limit, contactTypes, contactFilter, - rejectedLabelIds + rejectedLabelIds, + threadIdRejected }); if (plain) { return partThreadQueryByMatchText(queryDb, text); } - if (text) { queryDb = queryDb .andWhere('preview', 'like', `%${text}%`) @@ -624,7 +625,8 @@ const baseThreadQuery = ({ limit, contactTypes, contactFilter, - rejectedLabelIds + rejectedLabelIds, + threadIdRejected }) => { const { labelsQuery, @@ -633,7 +635,7 @@ const baseThreadQuery = ({ whereRawParams } = getQueryParamsIfOrNotRejectedLabel({ labelId, rejectedLabelIds }); - return db + let query = db .select( `${Table.EMAIL}.*`, db.raw(`IFNULL(${Table.EMAIL}.threadId ,${Table.EMAIL}.id) as uniqueId`), @@ -683,8 +685,12 @@ const baseThreadQuery = ({ `${Table.EMAIL_CONTACT}.contactId`, `${Table.CONTACT}.id` ) - .whereRaw(whereRawQuery, whereRawParams) - .where(`${Table.EMAIL}.date`, '<', date || 'now') + .whereRaw(whereRawQuery, whereRawParams); + if (threadIdRejected !== undefined) { + query = query.whereNot('uniqueId', threadIdRejected); + } + return query + .andWhere(`${Table.EMAIL}.date`, '<', date || 'now') .groupBy('uniqueId') .orderBy(`${Table.EMAIL}.date`, 'DESC') .limit(limit || 20); diff --git a/electron_app/src/__integrations__/Email.integration.js b/electron_app/src/__integrations__/Email.integration.js index fa6b16ec3..caa7c3705 100644 --- a/electron_app/src/__integrations__/Email.integration.js +++ b/electron_app/src/__integrations__/Email.integration.js @@ -315,6 +315,34 @@ describe('Load data thread from Email Table:', () => { const threads = await DBManager.getEmailsGroupByThreadByParams(params); expect(threads).toMatchSnapshot(); }); + + it('should load threads from DB with the correct shape: inbox. Scroll action', async () => { + const params = { + labelId: 1, + rejectedLabelIds: [2, 6], + limit: 1 + }; + const [lastThread] = await DBManager.getEmailsGroupByThreadByParams(params); + const maxDate = lastThread.maxDate; + const threadIdRejected = lastThread.threadId; + expect(lastThread).toMatchObject( + expect.objectContaining({ + threadId: 'threadC', + emailIds: '3,4' + }) + ); + const moreParams = { + labelId: 1, + rejectedLabelIds: [2, 6], + limit: 1, + date: maxDate, + threadIdRejected + }; + const moreLastThreads = await DBManager.getEmailsGroupByThreadByParams( + moreParams + ); + expect(moreLastThreads).toEqual([]); + }); }); describe('Store relation data to EmailLabel Table: ', () => { diff --git a/email_mailbox/src/components/ThreadsWrapper.js b/email_mailbox/src/components/ThreadsWrapper.js index fe7025fcc..eb8b2d162 100644 --- a/email_mailbox/src/components/ThreadsWrapper.js +++ b/email_mailbox/src/components/ThreadsWrapper.js @@ -95,13 +95,15 @@ class ThreadsWrapper extends Component { if (scrollTop + height > scrollHeight - SCROLL_BOTTOM_LIMIT && lastThread) { const date = lastThread.get('maxDate'); + const threadIdRejected = lastThread.get('threadId'); if (this.state.lastMinDate !== date) { this.setState({ lastMinDate: date }, () => { this.props.onLoadThreads( this.props.mailboxSelected, false, this.props.searchParams, - date + date, + threadIdRejected ); }); } diff --git a/email_mailbox/src/components/email.scss b/email_mailbox/src/components/email.scss index 92036d925..f0c885b6e 100644 --- a/email_mailbox/src/components/email.scss +++ b/email_mailbox/src/components/email.scss @@ -221,6 +221,10 @@ >div{ margin: 10px 0; } + + p{ + font-family: 'NunitoSans'; + } } .email-files{ diff --git a/email_mailbox/src/containers/Threads.js b/email_mailbox/src/containers/Threads.js index 9f3e15b4b..c57b2e014 100644 --- a/email_mailbox/src/containers/Threads.js +++ b/email_mailbox/src/containers/Threads.js @@ -48,7 +48,7 @@ const mapStateToProps = (state, ownProps) => { const mapDispatchToProps = dispatch => { return { - onLoadThreads: (mailbox, clear, searchParams, date) => { + onLoadThreads: (mailbox, clear, searchParams, date, threadIdRejected) => { const labelId = LabelType[mailbox].id; const contactTypes = defineContactType( labelId, @@ -69,14 +69,16 @@ const mapDispatchToProps = dispatch => { contactFilter, plain: true, text: searchParams.text, - rejectedLabelIds + rejectedLabelIds, + threadIdRejected } : { labelId, clear, date, contactTypes, - rejectedLabelIds + rejectedLabelIds, + threadIdRejected }; dispatch(loadThreads(params)); }, From 47c76ed87e2303f4a6676abb58f1e50c1a4a6d96 Mon Sep 17 00:00:00 2001 From: erikaperugachi Date: Wed, 3 Oct 2018 10:33:19 -0500 Subject: [PATCH 2/3] Add email footer. Close #452 --- electron_app/src/utils/EmailUtils.js | 8 ++++++-- .../src/utils/__tests__/__snapshots__/EmailUtils.js.snap | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/electron_app/src/utils/EmailUtils.js b/electron_app/src/utils/EmailUtils.js index c31627761..5b233b433 100644 --- a/electron_app/src/utils/EmailUtils.js +++ b/electron_app/src/utils/EmailUtils.js @@ -17,6 +17,10 @@ const formRecipients = recipientString => { }); }; +const formAppSign = () => { + return '
Sent with Criptext'; +}; + const getEmailAddressesFromEmailObject = emails => { return emails.map(item => item.email || item); }; @@ -238,7 +242,7 @@ const formOutgoingEmailFromData = ({ const email = { key: Date.now(), subject: textSubject, - content: body, + content: `${body}${formAppSign()}`, preview: cleanHTML(body).slice(0, 100), date: Date.now(), status: EmailStatus.SENDING, @@ -269,7 +273,7 @@ const formOutgoingEmailFromData = ({ emailData, criptextRecipients, externalRecipients, - body + body: email.content }; }; diff --git a/electron_app/src/utils/__tests__/__snapshots__/EmailUtils.js.snap b/electron_app/src/utils/__tests__/__snapshots__/EmailUtils.js.snap index 5799cbbe2..af9891bb9 100644 --- a/electron_app/src/utils/__tests__/__snapshots__/EmailUtils.js.snap +++ b/electron_app/src/utils/__tests__/__snapshots__/EmailUtils.js.snap @@ -2,7 +2,7 @@ exports[`[Form outgoing email] Should form outgoing email from data 1`] = ` Object { - "body": "

Hello

", + "body": "

Hello


Sent with Criptext", "criptextRecipients": Array [ Object { "recipientId": "toUser", @@ -19,7 +19,7 @@ Object { ], "emailData": Object { "email": Object { - "content": "

Hello

", + "content": "

Hello


Sent with Criptext", "date": 1524861748481, "isMuted": false, "key": 1524861748481, From 271ffab5d25310e5eeeeee9a73d4d05f975064f1 Mon Sep 17 00:00:00 2001 From: erikaperugachi Date: Wed, 3 Oct 2018 10:33:43 -0500 Subject: [PATCH 3/3] Add invite friend button. Close #453 --- email_composer/src/utils/EmailUtils.js | 2 +- email_mailbox/src/app.scss | 3 ++ email_mailbox/src/components/SideBar.js | 7 +++++ email_mailbox/src/components/sidebar.scss | 34 ++++++++++++++++++++++ email_mailbox/src/containers/SideBar.js | 27 +++++++++++++++-- email_mailbox/src/fonts/icon.eot | Bin 14420 -> 14720 bytes email_mailbox/src/fonts/icon.svg | 1 + email_mailbox/src/fonts/icon.ttf | Bin 14256 -> 14556 bytes email_mailbox/src/fonts/icon.woff | Bin 14332 -> 14632 bytes 9 files changed, 71 insertions(+), 3 deletions(-) diff --git a/email_composer/src/utils/EmailUtils.js b/email_composer/src/utils/EmailUtils.js index 8531358d3..104162201 100644 --- a/email_composer/src/utils/EmailUtils.js +++ b/email_composer/src/utils/EmailUtils.js @@ -179,7 +179,7 @@ export const formNewEmailFromData = data => { ); const htmlBody = EditorState.createWithContent(contentState); return { - toEmails: [formRecipientObject(data.recipients.to)], + toEmails: data.recipients ? [formRecipientObject(data.recipients.to)] : [], textSubject: data.email.subject, htmlBody }; diff --git a/email_mailbox/src/app.scss b/email_mailbox/src/app.scss index e04ce4685..a2be026a2 100644 --- a/email_mailbox/src/app.scss +++ b/email_mailbox/src/app.scss @@ -396,6 +396,9 @@ TABLE OF CONTENTS .icon-clock:before { content: "\e93e"; } +.icon-mood-happy:before { + content: "\e934"; +} /* 2.- CONTENT ----------------------------- */ diff --git a/email_mailbox/src/components/SideBar.js b/email_mailbox/src/components/SideBar.js index 050413dcd..ad575b38b 100644 --- a/email_mailbox/src/components/SideBar.js +++ b/email_mailbox/src/components/SideBar.js @@ -64,6 +64,12 @@ const SideBar = props => ( +
props.onClickInviteFriend()}> +
+ +
+ Invite a Friend +
); @@ -82,6 +88,7 @@ SideBar.propTypes = { items: PropTypes.array, labels: PropTypes.object, mailboxSelected: PropTypes.string, + onClickInviteFriend: PropTypes.func, onToggleShowLabelView: PropTypes.func, onToggleSideBar: PropTypes.func, showLabels: PropTypes.bool diff --git a/email_mailbox/src/components/sidebar.scss b/email_mailbox/src/components/sidebar.scss index 79001b864..5422a0073 100644 --- a/email_mailbox/src/components/sidebar.scss +++ b/email_mailbox/src/components/sidebar.scss @@ -54,6 +54,28 @@ } } } + + .option-item{ + align-items: center; + display: flex; + cursor: pointer; + flex-direction: row; + flex-grow: 0; + height: 40px; + + div i{ + color: #c1c1c2; + font-size: 14px; + margin: 0 10px 0 32px; + } + + span{ + color: black; + font-size: 13px; + font-weight: 300; + margin-left: 15px; + } + } } .navigation-partial-mail::-webkit-scrollbar-track{ @@ -202,6 +224,12 @@ .label-container{ display: none; } + + .option-item{ + span{ + display: none; + } + } } @media screen and (max-width: $_MAX_WIDTH_SCREEN) { @@ -253,4 +281,10 @@ .label-container{ display: none; } + + .option-item{ + span{ + display: none; + } + } } \ No newline at end of file diff --git a/email_mailbox/src/containers/SideBar.js b/email_mailbox/src/containers/SideBar.js index a2a60ff5f..e3da68507 100644 --- a/email_mailbox/src/containers/SideBar.js +++ b/email_mailbox/src/containers/SideBar.js @@ -1,8 +1,12 @@ import { connect } from 'react-redux'; import { loadLabels } from '../actions'; import SideBarView from '../components/SideBarWrapper'; -import { IconLabels } from './../utils/const'; +import { IconLabels, SectionType } from './../utils/const'; import { toLowerCaseWithoutSpaces } from './../utils/StringUtils'; +import { + composerEvents, + openEmailInComposer +} from '../utils/electronInterface'; const defineLabels = labels => { return labels @@ -41,8 +45,27 @@ const mapStateToProps = state => { }; }; -const mapDispatchToProps = dispatch => { +const formInviteFriendEmailContent = () => { + return 'Hey, try Criptext now!

Hey, try Criptext now!

Criptext is an encrypted email service that guarantees security, privacy and control over all your email communications. We don‘t have access to your emails nor do we store them in our servers.
You‘re in control now.

Encrypted. Private. Simple.
www.criptext.com
'; +}; + +const mapDispatchToProps = (dispatch, ownProps) => { return { + onClickInviteFriend: () => { + openEmailInComposer({ + type: composerEvents.NEW_WITH_DATA, + data: { + email: { + subject: 'Hey, try Criptext now!', + content: formInviteFriendEmailContent() + } + } + }); + }, + onClickSettings: () => { + const type = SectionType.SETTINGS; + ownProps.onClickSection(type); + }, onLoadLabels: () => { dispatch(loadLabels(dispatch)); } diff --git a/email_mailbox/src/fonts/icon.eot b/email_mailbox/src/fonts/icon.eot index ef3bb983bd7ce201d513d513a92dda623a6838b2..eb0f86abdccefcb55b9729837e500324a53a3ade 100755 GIT binary patch delta 576 zcmcao&``|QV9CI6$6_Lz8H;a+!h?wp?Tk_rPsr3C?6s|7U|?)uU@)GMk(!tyyx^K4 z1B0mq0|SFu22g-wBC8#c9{}X5WaO4qh;G$S2J%aQdPH*alM`2_Z?6Cl0Qm}eiMgpWy*PgZ`6fX1Z3X$oB@E0!83v0zAbAF6mdVMCJ&Y!kKQKx& zGHvEzny6XN%E0jd01E^20R~wHYX(n-aE1&92393?Jw|mkQxkJLMsqV`LnCoHMsYDw z5q3UCb~a^GBe1Zk30RS`p%PeFR0OQZm{|#^52OdEo=sU1g(uDiF#%${KBFR2JwsM( zT(<@gbjQVJA+tlhyz>5nyC; zalkYWVs;vufs-4!ITaYsLQI62r=UAiPgTuKfS+H$R83WfdGQ==PL&4=9lr7WHeVUI zSwKO`aQ)_qTL>B$hUb|NOg>ry5VPKl>&&UDfzX0+T@)C1XXL@n|1{wtvV{9wPFD_wV2Ffs)PXNg?FtbcfX6#`!p8SDP znvroc57R`=%|~_qbEw=o{px2tzs*+$ZWfSohU;5uKO^Y>pIFW_*G_(6s?X>$S;Fk$ tk|7TzDWF;go4BlNuaM87=hSj^FH%Ki~v@uP3iyu diff --git a/email_mailbox/src/fonts/icon.svg b/email_mailbox/src/fonts/icon.svg index b6ce86aa2..f72e0bf94 100755 --- a/email_mailbox/src/fonts/icon.svg +++ b/email_mailbox/src/fonts/icon.svg @@ -59,6 +59,7 @@ + diff --git a/email_mailbox/src/fonts/icon.ttf b/email_mailbox/src/fonts/icon.ttf index ff99985267aec4446d1145d6828ea4f918bcd71c..5dc7160fe0875b01d16eedac1f8243f7e41fc549 100755 GIT binary patch delta 526 zcmdmxf2VMQa=jD-1EUNB14B%DVsQbG769@qfHX&XPG#D`UfUWVzkz|lct%EQVv6vB zYlaLArV>DTvkagB$3#{;AU^=eSINjNsSw?&pA6)e0QHFEStOy3SP%d7(^-;MMZ^tZ?8~f_GSfLT?G(kOoOrV1!QHt^>mGlboIPtWdse{nF;Xo3z({@>M$?`~fI$mH`ytn8<3&z+j>QNC1bE-`&LInr#Q pg2)X~1JMrA7h+;!U1ER47l}WUP>|RmX#v#62*fU%rOXd80s!Y)NMQf~ diff --git a/email_mailbox/src/fonts/icon.woff b/email_mailbox/src/fonts/icon.woff index 6c4f49b975301d9ae35b8b61ec5bfb16e445bdbb..cc357b22ae2cef64849d370eb57d118384b7a882 100755 GIT binary patch delta 613 zcmey9zoJN_+~3WOfsp|SEHxOoLA1r4$q&sXChDlyOQk0k7cej|9s!DSK(Ro2PGuTU z>B^5xi13>*E zAS}97KRG8q8K}T z<^v3}4Au;u4B-qJ3=FJF>UxaoYNjUUc8um`#)d}Xa*X0)q9W{kjO=X6rbb|4QxmWv zWkV&fu&4-Fkume+C=uy;aW;rrh(Y>{icAbyv2ooRK+qi*n}y5{_43YFP*haN_x1`! zW^Y!|)l~pt#xxi!UqDvYTTj=>NLSBWRz`r4$;AQFJdoMe8X9SsCPGYSJPR=vW~hSh zOg&XKGXZ{n0aGV!Z delta 349 zcmZ2c^e11W+~3WOfsp|S%>OWOgXs;E1uexVYHQR>q$d^^FfcG40Sa?Ku|RrGWg1ZI z3!vf5_kmQ(=6W&rgI zfUw|J{p6hdWS~0J6+kszAiSb_j!JG~1<-6QGZUbI0vP)SsK^%~u9)7O>juTWUXp7!dmZCzkWfwUZ~9>NC1bK4AKA@=~*fS|T?@4MaOcUx