Skip to content

Commit

Permalink
Merge pull request #70 from Telios-org/beta
Browse files Browse the repository at this point in the history
Merging beta into master
  • Loading branch information
hexadecible authored Jul 8, 2022
2 parents c328e9b + 42836bc commit d8d9a8e
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 37 deletions.
20 changes: 14 additions & 6 deletions app/composer_window/Composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ const Composer = (props: Props) => {
// Getting the plain text off the htmlBody
const plaintext = htmlToText.fromString(htmlBody);

console.log(draft);

const from = draft?.from ?? [
{
address: owner.address,
Expand Down Expand Up @@ -194,15 +196,15 @@ const Composer = (props: Props) => {
draft.to = rcp.data.to;
draft.cc = rcp.data.cc;
draft.bcc = rcp.data.bcc;
draft.from = rcp.data.from;
draft.from = JSON.parse(email.fromJSON);
handleEmailUpdate(draft, draft.bodyAsHtml || '', mb);
setMailbox(mb);
const data = assembleFromDataSet(mb, namespaces, aliases);
setFromDataSet(data);
if (draft.from.length === 1) {
setFromAddress(draft.from);
} else {
setFromAddress([data[0]]);
setFromAddress([draft.from[0]]);
}

setPrefillRecipients(rcp.ui);
Expand Down Expand Up @@ -243,10 +245,13 @@ const Composer = (props: Props) => {
draft.to = rcp.data.to;
draft.cc = rcp.data.cc;
draft.bcc = rcp.data.bcc;
draft.from = rcp.data.from;
draft.from =
windowID === 'mainWindow'
? rcp.data.from
: JSON.parse(draft.fromJSON);

console.log(draft);

handleEmailUpdate(draft, draft.bodyAsHtml, content.mailbox);
setMailbox(content.mailbox);
const data = assembleFromDataSet(
content.mailbox,
content.namespaces,
Expand All @@ -258,6 +263,9 @@ const Composer = (props: Props) => {
} else {
setFromAddress([data[0]]);
}

handleEmailUpdate(draft, draft.bodyAsHtml, content.mailbox);
setMailbox(content.mailbox);
setPrefillRecipients(rcp.ui);
setWindowId(windowID);

Expand Down Expand Up @@ -366,7 +374,7 @@ const Composer = (props: Props) => {
to: toArr,
cc: ccArr,
bcc: bccArr,
from: [fromAddress]
from: Array.isArray(fromAddress) ? fromAddress : [fromAddress]
};

console.log('DRAFT', draft);
Expand Down
6 changes: 3 additions & 3 deletions app/ipc/Window.ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,16 @@ module.exports = (windowManager, createMainWindow, createLoginWindow) => {
async (event, content) => {
const { message, mailbox, namespaces, aliases, editorAction } = content;

console.log(content);
// console.log(content);

const newDraft = emailTransform(message, editorAction, true);

console.log(newDraft);
// console.log(newDraft);


const data = assembleFromDataSet(mailbox, namespaces, aliases);

console.log(data);
// console.log(data);

let filteredArray = [];
if (message['toJSON']) {
Expand Down
49 changes: 31 additions & 18 deletions app/main_window/components/Mail/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable jsx-a11y/click-events-have-key-events */
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { ipcRenderer } from 'electron';

Expand Down Expand Up @@ -96,28 +96,41 @@ export default function Navigation(props: Props) {
(state: StateType) => state.mail.folders.allIds
);

// Show total unread count as badge for Mac OS only
if (dock) {
let totalUnreadCount = 0;


for (const id of foldersArray) {
const folder = allFolders[id];
useEffect(() => {
// Show total unread count as badge for Mac OS only
if (dock) {
let totalUnreadCount = 0;

if (
folder.name !== 'Trash' ||
folder.name !== 'Sent' ||
(folder.name !== 'Drafts' && folder.count)
) {
totalUnreadCount += folder.count;
for (const id of foldersArray) {
const folder = allFolders[id];

if (
(folder.name !== 'Trash' ||
folder.name !== 'Sent' ||
(folder.name !== 'Drafts' && folder.count)) && folder.type !== 'hidden'
) {
console.log(folder.count, folder.name);
totalUnreadCount += folder.count;
}
}
}

if (totalUnreadCount > 0) {
dock.setBadge(`${ totalUnreadCount}`);
} else {
dock.setBadge('');
for (const id of aliases.allIds) {
const alias = aliases.byId[id];
totalUnreadCount += alias.count;
}


if (totalUnreadCount > 0) {
dock.setBadge(`${totalUnreadCount}`);
} else {
dock.setBadge('');
}
}
}

}, [foldersArray, aliases.byId])


const selectFolder = async (index: string, isAlias, e) => {
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const SyncNotification = (props: Props) => {
setLoaded(data.index);
setTotal(data.total);

if(win) {
if(win && data.total > 0) {
win.setProgressBar(data.index / data.total);
}

Expand Down
6 changes: 6 additions & 0 deletions app/main_window/containers/Layout/MainWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ import { StateType } from '../../reducers/types';
const account = new Account();
const notifier = new Notifier();

const { app } = require('electron').remote;
const themeUtils = require('../../../utils/themes.util');

const { dock } = app;

export default function MainWindow() {
const dispatch = useDispatch();

Expand All @@ -47,6 +50,9 @@ export default function MainWindow() {
});

return () => {
if (dock) {
dock.setBadge('');
}
account.removeAllListeners('ACCOUNT_SERVICE::accountData');
account.removeAllListeners('ACCOUNT_SERVICE::refreshToken');
ipcRenderer.removeAllListeners('dark-mode');
Expand Down
16 changes: 8 additions & 8 deletions app/services/messageIngress.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,36 @@ class MessageIngressService extends EventEmitter {
messages: [email],
type: 'Incoming',
async: false
})
});
}
});

channel.on('email:saveMessageToDB:callback', async m => {
const { error, data } = m;

if(error) {
if (error) {
this.finished += 1;
this.handleDone();
return;
}

data.msgArr.forEach(msg => {
if(!this.incomingMsgBatch.some(item => item.emailId === msg.emailId)) {
if (!this.incomingMsgBatch.some(item => item.emailId === msg.emailId)) {
this.incomingMsgBatch.push(msg);
}
})
});

if (data.newAliases.length > 0) {
data.newAliases.forEach(alias => {
if(!this.newAliases.some(a => a.name === alias.name)) {
this.newAliases.push(alias)
if (!this.newAliases.some(a => a.name === alias.name)) {
this.newAliases.push(alias);
}
})
});
}

this.finished += 1;
this.handleDone();
})
});

channel.on('messageHandler:fetchError', async m => {
const { data } = m;
Expand Down
2 changes: 1 addition & 1 deletion app/utils/draft.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const recipientTransform = (
to,
cc,
bcc,
from: email?.from ?? [
from: [
{
address: ownerMailbox.address,
name: ownerMailbox.name ? ownerMailbox.name : ownerMailbox.address
Expand Down

0 comments on commit d8d9a8e

Please sign in to comment.