Skip to content

Importer: Supporting ZIP Imports#3328

Merged
jleandroperez merged 13 commits into
trunkfrom
lantean/zip-import-support
Jul 25, 2025
Merged

Importer: Supporting ZIP Imports#3328
jleandroperez merged 13 commits into
trunkfrom
lantean/zip-import-support

Conversation

@jleandroperez

@jleandroperez jleandroperez commented Jul 22, 2025

Copy link
Copy Markdown
Contributor

Fix

In this PR we're enhancing the Importer, so that users can import the zip files, exactly the way they've exported them.

Test

  1. Export your notes (zip) at Simplenote.com, any test account would work!
  2. Setup Simplenote Electron secrets in your system (DM me if anything!)
  3. Run npm run dev
  4. Open http://localhost:4000/
  5. Log into your account
  6. Open Settings > Tools > Import Notes
  • Verify you see a reference to Simplenote Zip files
  • Verify you can import your notes!
  • Verify the Unit Tests are green (npm test)

Release

RELEASE-NOTES.md was updated with:

Implemented support for importing ZIP files (#3328)

@jleandroperez jleandroperez self-assigned this Jul 22, 2025
}

if (endsWith(fileName, '.json')) {
this.processJsonFile(file);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON Import logic has been extracted into processJsonFile

});
};

processZipFile = (file) => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this would be the new processor!

@jleandroperez jleandroperez requested a review from dmsnell July 22, 2025 16:29
@jleandroperez jleandroperez added this to the 2.23.3 milestone Jul 22, 2025
@jleandroperez jleandroperez marked this pull request as ready for review July 22, 2025 16:30
const fileName = file.name.toLowerCase();

// Limit file size we will read to 5mb
if (file.size > 5000000) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deary me. why do we limit imports to 5 MB?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, but... perhaps just as a failsafe? (nobody ever complained about this AFAIK)

Comment thread lib/utils/import/simplenote/index.ts Outdated
Comment thread lib/utils/import/simplenote/index.ts Outdated
this.recordEvent('importer_import_completed', {
source: 'simplenote',
note_count: noteCount,
import(/* webpackChunkName: 'jszip' */ 'jszip')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice job lazy-loading this module. was this library already included in the project?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YES! there's a snippet just like this in to-zip.js

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coooool. can we verify that this lazy-loads and isn’t pulled in as soon as the app loads? I think we should be able to do that via the dev server and the local browser dev tools

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm only seeing this line after clicking Import in Settings > Tools. I believe we're good!

image

@jleandroperez jleandroperez requested a review from dmsnell July 22, 2025 19:55
Comment thread lib/utils/import/simplenote/test.ts Outdated
const mockFileReader = new FileReader();
(FileReader as any).mockImplementation(() => mockFileReader);

importer.processZipFile(zipFile);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be calling importer.importNotes() as in the previous test, but as it is, it’s reaching into an internal method making the test brittle and at risk of diverging from the actual app code

Comment thread lib/utils/import/simplenote/index.ts Outdated
.then((zip) => {
// Look for JSON files in the ZIP
const jsonFiles = Object.keys(zip.files).filter((filename) =>
filename.toLowerCase().endsWith('.json')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can look specifically for source/notes.json since that’s what the official exporter produces.

we don’t want ZIPs with random JSON destroying accounts with junk data

Comment thread lib/utils/import/simplenote/test.ts Outdated
Comment thread lib/utils/import/simplenote/test.ts Outdated

@dmsnell dmsnell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a pairing review session

@jleandroperez jleandroperez requested a review from dmsnell July 24, 2025 19:28
@jleandroperez

Copy link
Copy Markdown
Contributor Author

@dmsnell Ready for another look, thank you!

@dmsnell dmsnell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready for merge and deployment. We should be ready and reactive when we do so, however, to ensure that we don’t break things accidentally.

What testing have you performed on these changes? I have performed none.

@jleandroperez

Copy link
Copy Markdown
Contributor Author

I've tested the steps outlined in the PR (importing a ZIP!).

Let's go forwards, reverting takes a sec, if anything. Thank you Dennis!!

@jleandroperez jleandroperez merged commit a28db42 into trunk Jul 25, 2025
7 checks passed
@jleandroperez jleandroperez deleted the lantean/zip-import-support branch July 25, 2025 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants