Skip to content

Commit

Permalink
Merge branch 'master' into issue-5666-5667-add-thunderbird-support
Browse files Browse the repository at this point in the history
  • Loading branch information
martgil authored May 21, 2024
2 parents 96ad572 + d4b2b95 commit d01ea80
Show file tree
Hide file tree
Showing 12 changed files with 270 additions and 76 deletions.
2 changes: 2 additions & 0 deletions extension/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<div class="lightboxed">

version 8.5.5 on May 20, 2024: <a href="https://github.com/FlowCrypt/flowcrypt-browser/milestone/478?closed=1" target="_blank">Manifest V3</a>

version 8.5.4 on March 7, 2024: <a href="https://github.com/FlowCrypt/flowcrypt-browser/milestone/476?closed=1" target="_blank">Improved compatibility with firewalls</a>

version 8.5.3 on February 7, 2024: <a href="https://github.com/FlowCrypt/flowcrypt-browser/milestone/468?closed=1" target="_blank">Improvements for encrypted content detection and PGP/MIME messages parsing</a>
Expand Down
59 changes: 38 additions & 21 deletions extension/chrome/elements/compose-modules/compose-input-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export class ComposeInputModule extends ViewModule<ComposeView> {
this.squire = new window.Squire(el, { addLinks });
this.initShortcuts();
this.handlePaste();
this.handleDragImages();
this.handlePasteImages();
this.resizeReplyBox();
this.scrollIntoView();
Expand All @@ -136,35 +137,51 @@ export class ComposeInputModule extends ViewModule<ComposeView> {
});
};

private handlePasteImages = () => {
private loadImageFromFile = (file: File, callback: (result: string) => void) => {
const reader = new FileReader();
reader.onload = () => callback(reader.result as string);
reader.readAsDataURL(file);
};

private insertImageIntoSquire = (imageData: string, name: string) => {
try {
this.squire.insertImage(imageData, { name, title: name });
this.view.draftModule.draftSave().catch(Catch.reportErr);
} catch (e) {
Catch.reportErr(e);
}
};

private handleDragImages = () => {
this.squire.addEventListener('drop', (ev: DragEvent) => {
try {
if (!this.isRichText()) {
return;
}
if (!ev.dataTransfer?.files.length) {
return;
}
const file = ev.dataTransfer.files[0];
const reader = new FileReader();
reader.onload = () => {
try {
this.squire.insertImage(reader.result?.toString() ?? '', { name: file.name, title: file.name });
this.view.draftModule.draftSave().catch(Catch.reportErr);
} catch (e) {
Catch.reportErr(e);
}
};
reader.readAsDataURL(file);
} catch (e) {
Catch.reportErr(e);
if (!this.isRichText() || !ev.dataTransfer?.files.length) {
return;
}
const file = ev.dataTransfer.files[0];
this.loadImageFromFile(file, imageData => {
this.insertImageIntoSquire(imageData, file.name);
});
});
this.squire.addEventListener('dragover', (e: DragEvent) => {
e.preventDefault(); // this is needed for 'drop' event to fire
});
};

private handlePasteImages = () => {
this.squire.addEventListener('pasteImage', (ev: Event & { detail: { clipboardData: DataTransfer } }) => {
if (!this.isRichText()) return;
const items = Array.from(ev.detail.clipboardData?.items ?? []);
const imageItem = items.find(item => /image/.test(item.type));

const imageFile = imageItem?.getAsFile();
if (imageItem && imageFile) {
this.loadImageFromFile(imageFile, imageData => {
this.insertImageIntoSquire(imageData, 'Pasted Image');
});
}
});
};

private handleRTL = () => {
const checkRTL = () => {
let container = $(this.squire.getSelection().commonAncestorContainer);
Expand Down
2 changes: 1 addition & 1 deletion extension/chrome/settings/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ export class SetupView extends View {
return;
}
if (!armoredPubkey) {
await Ui.modal.warning('Public key not usable - not sumbitting to Attester');
await Ui.modal.warning('Public key not usable - not submitting to Attester');
return;
}
const pub = await KeyUtil.parse(armoredPubkey);
Expand Down
7 changes: 5 additions & 2 deletions extension/js/common/message-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,10 @@ export class MessageRenderer {

private getMessageInfo = async (fullMsg: GmailRes.GmailMsg): Promise<MessageInfo> => {
const sentDate = GmailParser.findHeader(fullMsg, 'date');
const sentDateStr = sentDate ? Str.fromDate(new Date(sentDate)).replace(' ', ' at ') : '';
let sentDateStr = $('div.gK span[title]').attr('title');
if (!sentDateStr || isNaN(Date.parse(sentDateStr))) {
sentDateStr = sentDate ? new Date(sentDate).toLocaleString() : '';
}
const fromString = GmailParser.findHeader(fullMsg, 'from');
const from = fromString ? Str.parseEmail(fromString) : undefined;
const fromEmail = from?.email ?? '';
Expand All @@ -483,7 +486,7 @@ export class MessageRenderer {
<span data-test="print-from">From: ${fromHtml}</span>
</div>
<div class="float-right">
<span>${sentDateStr}</span>
<span data-test="print-date">${sentDateStr}</span>
</div>
</div>
<span data-test="print-to">To: ${Xss.escape(GmailParser.findHeader(fullMsg, 'to') ?? '')}</span><br/>
Expand Down
15 changes: 8 additions & 7 deletions extension/js/common/platform/catch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import { Url } from '../core/common.js';
import { FLAVOR, InMemoryStoreKeys, SHARED_TENANT_API_HOST, VERSION } from '../core/const.js';
import { GlobalStore } from './store/global-store.js';
import { InMemoryStore } from './store/in-memory-store.js';

export class UnreportableError extends Error {}
Expand Down Expand Up @@ -285,8 +286,8 @@ export class Catch {
private static formatExceptionForReport(thrown: unknown, line?: number, col?: number): ErrorReport {
if (!line || !col) {
const { line: parsedLine, col: parsedCol } = Catch.getErrorLineAndCol(thrown);
line = parsedLine;
col = parsedCol;
line = parsedLine > 0 ? parsedLine : 1;
col = parsedCol > 0 ? parsedCol : 1;
}
if (thrown instanceof Error) {
// reporting stack may differ from the stack of the actual error, both may be interesting
Expand All @@ -301,8 +302,8 @@ export class Catch {
name: exception.name.substring(0, 50),
message: exception.message.substring(0, 200),
url: location.href.split('?')[0],
line: line || 0,
col: col || 0,
line: line || 1,
col: col || 1,
trace: exception.stack || '',
version: VERSION,
environment: Catch.RUNTIME_ENVIRONMENT,
Expand All @@ -313,8 +314,8 @@ export class Catch {

private static async doSendErrorToSharedTenantFes(errorReport: ErrorReport) {
try {
const uncheckedUrlParams = Url.parse(['acctEmail']);
const acctEmail = String(uncheckedUrlParams.acctEmail);
const { acctEmail: parsedEmail } = Url.parse(['acctEmail']);
const acctEmail = parsedEmail ? String(parsedEmail) : (await GlobalStore.acctEmailsGet())?.[0];
if (!acctEmail) {
console.error('Not reporting error because user is not logged in');
return;
Expand Down Expand Up @@ -378,7 +379,7 @@ export class Catch {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return { line: Number(matched![1]), col: Number(matched![2]) };
} catch (lineErr) {
return { line: 0, col: 0 };
return { line: 1, col: 1 };
}
}

Expand Down
Loading

0 comments on commit d01ea80

Please sign in to comment.