mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-28 16:06:47 +01:00
web: preserve note edited time when exporting
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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) =>
|
||||
|
||||
Reference in New Issue
Block a user