Skip to content

Commit

Permalink
New Features
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
reconka committed Jul 12, 2024
2 parents ea276a3 + 852e4d6 commit a03191a
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 20 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.10-green.svg?style=flat-square)](https://github.com/Zoltan.Birner/postie)
[![Version](https://img.shields.io/badge/version-0.6.12-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)

Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -22,7 +27,7 @@
"sponsor": {
"url": "https://github.com/sponsors/reconka/"
},
"version": "0.6.10",
"version": "0.6.12",
"icon": "out/postie-profile.jpg",
"activationEvents": [
"onStartupFinished"
Expand Down
5 changes: 4 additions & 1 deletion src/EmailStorageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<EmailSummary> = JSON.parse(data)
return emails
}
Expand Down
4 changes: 4 additions & 0 deletions src/media/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ iframe {
justify-content: center;
}

.background--light {
background-color: #f5f5f5;
}

/* Simulate Mobile View */
.container--mobile {
width: 320px; /* Typical mobile screen width */
Expand Down
14 changes: 7 additions & 7 deletions src/panels/EmailView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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'])

Expand Down Expand Up @@ -143,22 +143,22 @@ export class EmailView {
<vscode-panel-tab id="desktop">Desktop View</vscode-panel-tab>
<vscode-panel-tab id="textOnly">Text Only</vscode-panel-tab>
<vscode-panel-view id="view-mobile">
<div class="container--mobile">
<div class="container--mobile background--light">
<iframe class="full-width full-height" src="${emailDataUrl}"></iframe>
</div>
</vscode-panel-view>
<vscode-panel-view id="view-tablet">
<div class="container--tablet ">
<div class="container--tablet background--light">
<iframe class="full-width full-height" src="${emailDataUrl}" sandbox></iframe>
</div>
</vscode-panel-view>
<vscode-panel-view id="view-desktop">
<div class="container--desktop">
<div class="container--desktop background--light">
<iframe class="full-width full-height" src="${emailDataUrl}"></iframe>
</div>
</vscode-panel-view>
<vscode-panel-view id="text-only-view">
<div class="container--desktop">
<div class>
${email.text}
</div>
</vscode-panel-view>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
}
8 changes: 8 additions & 0 deletions src/utilities/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
}

0 comments on commit a03191a

Please sign in to comment.