Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: preserve note edited time when exporting

Abdullah Attadbe4015655ae
diff --git a/apps/web/src/common/export.ts b/apps/web/src/common/export.ts
index 5c700ab8e..c6b9e95a7 100644
--- a/apps/web/src/common/export.ts
+++ b/apps/web/src/common/export.ts
@@ -119,7 +119,11 @@ export async function exportNotes(
return await exportToPDF(note.title, exported);
}
- files.push({ filename: note.title, content: exported });
+ files.push({
+ filename: note.title,
+ content: exported,
+ date: note.dateEdited
+ });
}
if (!files.length) return false;
diff --git a/apps/web/src/utils/zip.ts b/apps/web/src/utils/zip.ts
index 45de57c25..3b65258f0 100644
--- a/apps/web/src/utils/zip.ts
+++ b/apps/web/src/utils/zip.ts
@@ -17,19 +17,22 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import { Unzipped } from "fflate";
+import { AsyncZippable } from "fflate";
import { sanitizeFilename } from "@notesnook/common";
const textEncoder = new TextEncoder();
-type File = { filename: string; content: string };
+type File = { filename: string; content: string; date: number };
async function zip(files: File[], format: string): Promise<Uint8Array> {
- const obj: Unzipped = Object.create(null);
+ const obj: AsyncZippable = Object.create(null);
files.forEach((file) => {
const name = sanitizeFilename(file.filename, { replacement: "-" });
let counter = 0;
while (obj[makeFilename(name, format, counter)]) ++counter;
- obj[makeFilename(name, format, counter)] = textEncoder.encode(file.content);
+ obj[makeFilename(name, format, counter)] = [
+ textEncoder.encode(file.content),
+ { mtime: file.date }
+ ];
});
const { zip } = await import("fflate");
return new Promise((resolve, reject) =>