From 852e4d6b53f98b8d8360ee9d6c765bb9389a1b5c Mon Sep 17 00:00:00 2001 From: Reconka Date: Fri, 12 Jul 2024 17:36:02 +0100 Subject: [PATCH] New Features Default White Background for Email Preview Section: The email preview section now has a default white background to ensure consistent appearance across different email clients. Bug Fixes Fixed Sync Issue: Resolved the issue where fs.writeFileSync was causing a EACCES: permission denied error on Node.js 20. Refer to the Stack Overflow discussion for more details. --- README.md | 7 ++++++- package-lock.json | 4 ++-- package.json | 7 ++++++- src/EmailStorageManager.ts | 5 ++++- src/media/main.css | 4 ++++ src/panels/EmailView.ts | 14 +++++++------- src/panels/utilities/{index.ts => uiElements.ts} | 8 -------- src/utilities/formatters.ts | 8 ++++++++ 8 files changed, 37 insertions(+), 20 deletions(-) rename src/panels/utilities/{index.ts => uiElements.ts} (77%) diff --git a/README.md b/README.md index c9a4f3a..73da44a 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,9 @@ [![VS Code Version](https://img.shields.io/badge/VS%20Code-%5E1.75.0-blue.svg?style=flat-square)](https://code.visualstudio.com/updates/v1_75) [![TypeScript Version](https://img.shields.io/badge/TypeScript-%5E4.8.4-blue.svg?style=flat-square)](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-8.html) [![jest](https://img.shields.io/badge/tested_with-jest-%23994499.svg?style=flat-square)](https://jestjs.io/) +[![VS Code Marketplace](https://img.shields.io/badge/VS%20Code%20Marketplace-Postie-brightgreen.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=Postie.postie) [![ESLint](https://img.shields.io/badge/linted_with-eslint-%234B32C3.svg?style=flat-square)](https://eslint.org/) -[![Version](https://img.shields.io/badge/version-0.6.9-orange.svg?style=flat-square)](https://github.com/Zoltan.Birner/postie) +[![Version](https://img.shields.io/badge/version-0.6.11-orange.svg?style=flat-square)](https://github.com/Zoltan.Birner/postie) [![CI](https://github.com/reconka/Postie/actions/workflows/ci.yml/badge.svg)](https://github.com/reconka/Postie/actions/workflows/ci.yml) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/e7933f74fa7e41008a8485f014fb562c)](https://app.codacy.com/gh/reconka/Postie/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) @@ -69,6 +70,10 @@ You can modify these settings to fit your needs. For example, to change the SMTP } ``` +## Gotchas + +- **_Outlook not rendering EML files correctly on Windows:_** CR LF EML Export Issue: If you encounter issues with CR LF line endings in EML exports, use the "Change File Encoding" feature in Visual Studio Code. You can find this option at the bottom of the VS Code window. Change the encoding to "Windows (CRLF)" to fix the issue. + ## Contributing We welcome contributions to Postie! Please check out our contributing guidelines for more information on how to get started. diff --git a/package-lock.json b/package-lock.json index 4d6a684..9b067e7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "postie", - "version": "0.6.9", + "version": "0.6.11", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "postie", - "version": "0.6.9", + "version": "0.6.11", "dependencies": { "@types/mailparser": "^3.4.4", "@types/smtp-server": "^3.5.10", diff --git a/package.json b/package.json index eb1a665..614d5db 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,11 @@ "type": "git", "url": "https://github.com/reconka/Postie.git" }, + "bugs": { + "url": "https://github.com/reconka/Postie/issues" + }, + "homepage": "https://github.com/reconka/Postie", + "pricing": "Free", "keywords": [ "email", "server", @@ -22,7 +27,7 @@ "sponsor": { "url": "https://github.com/sponsors/reconka/" }, - "version": "0.6.9", + "version": "0.6.11", "icon": "out/postie-profile.jpg", "activationEvents": [ "onStartupFinished" diff --git a/src/EmailStorageManager.ts b/src/EmailStorageManager.ts index b54c9d2..68104f3 100644 --- a/src/EmailStorageManager.ts +++ b/src/EmailStorageManager.ts @@ -26,7 +26,10 @@ export class EmailStorageManager { public getEmailSummaries(): EmailSummary[] { try { if (fs.existsSync(this.emailSummariesPath)) { - const data = fs.readFileSync(this.emailSummariesPath, 'utf8') + const data = fs.readFileSync(this.emailSummariesPath, { + encoding: 'utf8', + flag: 'a+', + }) let emails: Array = JSON.parse(data) return emails } diff --git a/src/media/main.css b/src/media/main.css index 2c201f3..e45a465 100644 --- a/src/media/main.css +++ b/src/media/main.css @@ -31,6 +31,10 @@ iframe { justify-content: center; } +.background--light { + background-color: #f5f5f5; +} + /* Simulate Mobile View */ .container--mobile { width: 320px; /* Typical mobile screen width */ diff --git a/src/panels/EmailView.ts b/src/panels/EmailView.ts index f2dd371..04c1bb1 100644 --- a/src/panels/EmailView.ts +++ b/src/panels/EmailView.ts @@ -10,9 +10,9 @@ import { getUri } from '../utilities/getUri' import { getNonce } from '../utilities/getNonce' import { Email } from '../types/Email' import { openInNewEditor } from './utilities/openInNewEditor' -import { createTextField, convertStringToBase64DataUrl } from './utilities' -import { createAttachmentButton } from './utilities/' +import { createTextField, createAttachmentButton } from './utilities/uiElements' import { getConfig } from '../utilities/getConfig' +import { formatStringToBase64DataUrl } from '../utilities/formatters' /** * This class manages the state and behavior of HelloWorld webview panels. @@ -99,7 +99,7 @@ export class EmailView { const attachments = createAttachmentButton(email.attachments) - const emailDataUrl = convertStringToBase64DataUrl(email.html) + const emailDataUrl = formatStringToBase64DataUrl(email.html) const codiconsUri = getUri(webview, extensionUri, ['out', 'codicon.css']) const myStylesUri = getUri(webview, extensionUri, ['out', 'main.css']) @@ -143,22 +143,22 @@ export class EmailView { Desktop View Text Only -
+
-
+
- +
-
+
${email.text}
diff --git a/src/panels/utilities/index.ts b/src/panels/utilities/uiElements.ts similarity index 77% rename from src/panels/utilities/index.ts rename to src/panels/utilities/uiElements.ts index b6c8f5a..48f53e2 100644 --- a/src/panels/utilities/index.ts +++ b/src/panels/utilities/uiElements.ts @@ -26,11 +26,3 @@ export function createAttachmentButton(attachment: Attachment[]): string { ) .join('') } - -export function convertStringToBase64DataUrl( - content: string, - mimeType: string = 'text/html' -): string { - const base64Content = Buffer.from(content).toString('base64') - return `data:${mimeType};base64,${base64Content}` -} diff --git a/src/utilities/formatters.ts b/src/utilities/formatters.ts index b377d5c..de2d336 100644 --- a/src/utilities/formatters.ts +++ b/src/utilities/formatters.ts @@ -19,3 +19,11 @@ export function formatAddresses( export function sanatize(element: string): string { return sanitizeHtml(element) } + +export function formatStringToBase64DataUrl( + content: string, + mimeType: string = 'text/html' +): string { + const base64Content = Buffer.from(content).toString('base64') + return `data:${mimeType};base64,${base64Content}` +}