Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 13 additions & 7 deletions electron_app/src/DBManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,8 @@ const getEmailsGroupByThreadByParams = (params = {}) => {
limit,
contactTypes = ['from'],
contactFilter,
rejectedLabelIds
rejectedLabelIds,
threadIdRejected
} = params;

let queryDb = baseThreadQuery({
Expand All @@ -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}%`)
Expand Down Expand Up @@ -624,7 +625,8 @@ const baseThreadQuery = ({
limit,
contactTypes,
contactFilter,
rejectedLabelIds
rejectedLabelIds,
threadIdRejected
}) => {
const {
labelsQuery,
Expand All @@ -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`),
Expand Down Expand Up @@ -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);
Expand Down
28 changes: 28 additions & 0 deletions electron_app/src/__integrations__/Email.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: ', () => {
Expand Down
8 changes: 6 additions & 2 deletions electron_app/src/utils/EmailUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ const formRecipients = recipientString => {
});
};

const formAppSign = () => {
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>';
};

const getEmailAddressesFromEmailObject = emails => {
return emails.map(item => item.email || item);
};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -269,7 +273,7 @@ const formOutgoingEmailFromData = ({
emailData,
criptextRecipients,
externalRecipients,
body
body: email.content
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`[Form outgoing email] Should form outgoing email from data 1`] = `
Object {
"body": "<p>Hello</p>",
"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>",
"criptextRecipients": Array [
Object {
"recipientId": "toUser",
Expand All @@ -19,7 +19,7 @@ Object {
],
"emailData": Object {
"email": Object {
"content": "<p>Hello</p>",
"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>",
"date": 1524861748481,
"isMuted": false,
"key": 1524861748481,
Expand Down
2 changes: 1 addition & 1 deletion email_composer/src/utils/EmailUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
3 changes: 3 additions & 0 deletions email_mailbox/src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ TABLE OF CONTENTS
.icon-clock:before {
content: "\e93e";
}
.icon-mood-happy:before {
content: "\e934";
}

/* 2.- CONTENT
----------------------------- */
Expand Down
7 changes: 7 additions & 0 deletions email_mailbox/src/components/SideBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ const SideBar = props => (
</ul>
</nav>
<LabelEdit />
<div className="option-item" onClick={() => props.onClickInviteFriend()}>
<div>
<i className="icon-mood-happy" />
</div>
<span>Invite a Friend</span>
</div>
</div>
</aside>
);
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion email_mailbox/src/components/ThreadsWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
});
}
Expand Down
4 changes: 4 additions & 0 deletions email_mailbox/src/components/email.scss
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@
>div{
margin: 10px 0;
}

p{
font-family: 'NunitoSans';
}
}

.email-files{
Expand Down
34 changes: 34 additions & 0 deletions email_mailbox/src/components/sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -202,6 +224,12 @@
.label-container{
display: none;
}

.option-item{
span{
display: none;
}
}
}

@media screen and (max-width: $_MAX_WIDTH_SCREEN) {
Expand Down Expand Up @@ -253,4 +281,10 @@
.label-container{
display: none;
}

.option-item{
span{
display: none;
}
}
}
27 changes: 25 additions & 2 deletions email_mailbox/src/containers/SideBar.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -41,8 +45,27 @@ const mapStateToProps = state => {
};
};

const mapDispatchToProps = dispatch => {
const formInviteFriendEmailContent = () => {
return '<!DOCTYPE html><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Hey, try Criptext now!</title><style type="text/css">.boton_1{text-decoration: none;padding: 8px;padding-left: 15px;padding-right: 15px;font-family: Avenir Next;font-weight: 500;font-size: 15px;color: #ffffff;background-color: #0091ff;border-radius: 26px;}.boton_1:hover{opacity: 0.9;text-decoration: none;}.boton_2{color: #0091ff}#criptext-website{color: #8FD8FF;text-decoration: none;}#confirm-button{color: #ffffff;}a:active, a:visited{color: #ffffff;}</style></head><body><div style="background-color: #F0F0F0; padding: 6%; max-width: 100%"><div style="background-color:#ffffff; padding-top:60px; padding-bottom: 60px; height:auto; max-width:100%; text-align: center; margin: 0 auto; font-family: avenir next;" ><div style="width: 80%; margin: 0 auto;"><div style="margin: 0 auto;"><img src="https://s3-us-west-2.amazonaws.com/web-res/Emails/header-icon.png" height="49px" ></div><div style="margin: 0 auto; padding-top:25px "><h2 style="color:#373a45; font-weight: 600; font-size: 23px; text-align: center">Hey, try Criptext now!</h2></div><div style="width: 100%; padding-top:20px "><p style="font-size: 15px; color:#9b9b9b; text-align: center">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. <br/>You‘re in control now.</p></div><div style="margin: 0 auto; padding-top:30px" ><a id="confirm-button" href="http://www.criptext.com/dl" class="boton_1">Download</a></div></div></div><div style="max-width: 100%; margin: 5px auto; background-image: url(https://s3-us-west-2.amazonaws.com/web-res/Emails/footer-background.png); height: 110px; background-position: center top; background-repeat: no-repeat; background-size: auto 200%; font-family: avenir next; text-align: center;"><table style="width: 65%; margin: 0 auto; text-align: left; color: #ffffff; font-size: 13px; padding-top: 35px;"><tr><td style="font-weight: 600;">Encrypted. Private. Simple.<br><a href="https://criptext.com/" target="_blank" id="criptext-website" style="color: #8FD8FF; font-weight: 400;">www.criptext.com</a></td><td><a href="https://twitter.com/Criptext" target="_blank"><img src="https://s3-us-west-2.amazonaws.com/web-res/Emails/twitter.png" height="18px"></a></td><td><a href="https://medium.com/criptext" target="_blank"><img src="https://s3-us-west-2.amazonaws.com/web-res/Emails/medium.png" height="18px"></a></td><td><a href="https://www.instagram.com/criptext/" target="_blank"><img src="https://s3-us-west-2.amazonaws.com/web-res/Emails/instagram.png" height="18px"></a></td></tr></table></div></div></body></html>';
};

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));
}
Expand Down
8 changes: 5 additions & 3 deletions email_mailbox/src/containers/Threads.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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));
},
Expand Down
Binary file modified email_mailbox/src/fonts/icon.eot
Binary file not shown.
1 change: 1 addition & 0 deletions email_mailbox/src/fonts/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified email_mailbox/src/fonts/icon.ttf
Binary file not shown.
Binary file modified email_mailbox/src/fonts/icon.woff
Binary file not shown.