From 38878a75f57b75e53879637cf3582706c138e881 Mon Sep 17 00:00:00 2001 From: CodeDoctorDE Date: Fri, 13 Dec 2024 15:31:40 +0100 Subject: [PATCH] Fix asset importing --- api/lib/src/models/data.dart | 4 +- api/pubspec.lock | 4 +- app/lib/handlers/import.dart | 8 +-- docs/package.json | 2 +- docs/pnpm-lock.yaml | 93 +++++++++++++++---------------- metadata/en-US/changelogs/124.txt | 3 + 6 files changed, 55 insertions(+), 59 deletions(-) diff --git a/api/lib/src/models/data.dart b/api/lib/src/models/data.dart index acf282a17bed..4509dd10c6fc 100644 --- a/api/lib/src/models/data.dart +++ b/api/lib/src/models/data.dart @@ -62,8 +62,8 @@ final class NoteData extends ArchiveData { (NoteData, String) importAsset( String path, Uint8List data, String fileExtension) { final hash = sha512256.convert(data); - final name = base64Encode(hash.bytes); - final newPath = '$path/${findUniqueName(path, fileExtension, name)}'; + final name = hash.toString(); + final newPath = '$path/$name.$fileExtension'; return (setAsset(newPath, data), newPath); } diff --git a/api/pubspec.lock b/api/pubspec.lock index 98d7fd86b667..1bcadc1e467c 100644 --- a/api/pubspec.lock +++ b/api/pubspec.lock @@ -587,10 +587,10 @@ packages: dependency: transitive description: name: timing - sha256: "70a3b636575d4163c477e6de42f247a23b315ae20e86442bebe32d3cabf61c32" + sha256: "62ee18aca144e4a9f29d212f5a4c6a053be252b895ab14b5821996cff4ed90fe" url: "https://pub.dev" source: hosted - version: "1.0.1" + version: "1.0.2" type_plus: dependency: transitive description: diff --git a/app/lib/handlers/import.dart b/app/lib/handlers/import.dart index 6d4383f7048b..a925e12c535f 100644 --- a/app/lib/handlers/import.dart +++ b/app/lib/handlers/import.dart @@ -41,9 +41,6 @@ class ImportHandler extends Handler { context.refresh(); } - @override - bool canChange(PointerDownEvent event, EventContext context) => false; - @override Future onPointerUp(PointerUpEvent event, EventContext context) async { final state = context.getState(); @@ -58,12 +55,9 @@ class ImportHandler extends Handler { state.assetService, state.page, )) - .map((e) => e.transform(position: _offset, relative: true)?.element) + .map((e) => e.transform(position: _offset, relative: true)?.element.copyWith(id: createUniqueId())) .nonNulls .toList())); - context - .getCurrentIndexCubit() - .resetTemporaryHandler(context.getDocumentBloc()); context.refresh(); context.bake(); } diff --git a/docs/package.json b/docs/package.json index 6c06f57ad551..797ea66a75f1 100644 --- a/docs/package.json +++ b/docs/package.json @@ -26,6 +26,6 @@ }, "packageManager": "pnpm@9.14.4", "devDependencies": { - "sass": "^1.82.0" + "sass": "^1.83.0" } } diff --git a/docs/pnpm-lock.yaml b/docs/pnpm-lock.yaml index 8a4548ed0b53..9107dc2c9272 100644 --- a/docs/pnpm-lock.yaml +++ b/docs/pnpm-lock.yaml @@ -13,10 +13,10 @@ importers: version: 0.9.4(typescript@5.7.2) '@astrojs/react': specifier: ^3.6.3 - version: 3.6.3(@types/react-dom@18.3.5(@types/react@18.3.16))(@types/react@18.3.16)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.82.0)(terser@5.36.0) + version: 3.6.3(@types/react-dom@18.3.5(@types/react@18.3.16))(@types/react@18.3.16)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.83.0)(terser@5.36.0) '@astrojs/starlight': specifier: ^0.29.3 - version: 0.29.3(astro@4.16.17(rollup@4.28.1)(sass@1.82.0)(terser@5.36.0)(typescript@5.7.2)) + version: 0.29.3(astro@4.16.17(rollup@4.28.1)(sass@1.83.0)(terser@5.36.0)(typescript@5.7.2)) '@phosphor-icons/react': specifier: ^2.1.7 version: 2.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -28,7 +28,7 @@ importers: version: 18.3.5(@types/react@18.3.16) astro: specifier: ^4.16.17 - version: 4.16.17(rollup@4.28.1)(sass@1.82.0)(terser@5.36.0)(typescript@5.7.2) + version: 4.16.17(rollup@4.28.1)(sass@1.83.0)(terser@5.36.0)(typescript@5.7.2) react: specifier: ^18.3.1 version: 18.3.1 @@ -49,8 +49,8 @@ importers: version: 5.7.2 devDependencies: sass: - specifier: ^1.82.0 - version: 1.82.0 + specifier: ^1.83.0 + version: 1.83.0 packages: @@ -980,8 +980,8 @@ packages: resolution: {integrity: sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA==} engines: {node: '>=16'} - caniuse-lite@1.0.30001687: - resolution: {integrity: sha512-0S/FDhf4ZiqrTUiQ39dKeUjYRjkv7lOZU1Dgif2rIqrTzX/1wV2hfKu9TOm1IHkdSijfLswxTFzl/cvir+SLSQ==} + caniuse-lite@1.0.30001688: + resolution: {integrity: sha512-Nmqpru91cuABu/DTCXbM2NSRHzM2uVHfPnhJ/1zEAJx/ILBRVmz3pzH4N7DZqbdG0gWClsCC05Oj0mJ/1AWMbA==} ccount@2.0.1: resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==} @@ -1124,8 +1124,8 @@ packages: resolution: {integrity: sha512-2QF/g9/zTaPDc3BjNcVTGoBbXBgYfMTTceLaYcFJ/W9kggFUkhxD/hMEeuLKbugyef9SqAx8cpgwlIP/jinUTA==} engines: {node: '>=4'} - electron-to-chromium@1.5.72: - resolution: {integrity: sha512-ZpSAUOZ2Izby7qnZluSrAlGgGQzucmFbN0n64dYzocYxnxV5ufurpj3VgEe4cUp7ir9LmeLxNYo8bVnlM8bQHw==} + electron-to-chromium@1.5.73: + resolution: {integrity: sha512-8wGNxG9tAG5KhGd3eeA0o6ixhiNdgr0DcHWm85XPCphwZgD1lIEoi6t3VERayWao7SF7AAZTw6oARGJeVjH8Kg==} emmet@2.4.11: resolution: {integrity: sha512-23QPJB3moh/U9sT4rQzGgeyyGIrcM+GH5uVYg2C6wZIxAIJq7Ng3QLT79tl8FUwDXhyq9SusfknOrofAKqvgyQ==} @@ -1753,8 +1753,8 @@ packages: resolution: {integrity: sha512-sFVv5/x73qCp9KlLHv8/uWDv7rG1tsWcG9MuXc5YTrXIrb8c1Gshm9oc5rMLXNZILXUWai8WczqaK4jjroEzng==} hasBin: true - parse-entities@4.0.1: - resolution: {integrity: sha512-SWzvYcSJh4d/SGLIOQfZ/CoNv6BTlI6YEQ7Nj82oDVnRpwe/Z/F1EMx42x3JAOwGBlCjeCH0BRJQbQ/opHL17w==} + parse-entities@4.0.2: + resolution: {integrity: sha512-GG2AQYWoLgL877gQIKeRPGO1xF9+eG1ujIb5soS5gPvLQ1y2o8FL90w2QWNdf9I361Mpp7726c+lj3U0qK1uGw==} parse-latin@7.0.0: resolution: {integrity: sha512-mhHgobPPua5kZ98EF4HWiH167JWBfl4pvAIXXdbaVohtK7a6YBOy56kvhCqduqyo/f3yrHFWmqmiMg/BkBkYYQ==} @@ -1958,8 +1958,8 @@ packages: run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} - sass@1.82.0: - resolution: {integrity: sha512-j4GMCTa8elGyN9A7x7bEglx0VgSpNUG4W4wNedQ33wSMdnkqQCT8HTwOaVSV4e6yQovcu/3Oc4coJP/l0xhL2Q==} + sass@1.83.0: + resolution: {integrity: sha512-qsSxlayzoOjdvXMVLkzF84DJFc2HZEL/rFyGIKbbilYtAvlCxyuzUeff9LawTn4btVnLKg75Z8MMr1lxU1lfGw==} engines: {node: '>=14.0.0'} hasBin: true @@ -2096,8 +2096,8 @@ packages: tslib@2.8.1: resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} - type-fest@4.30.0: - resolution: {integrity: sha512-G6zXWS1dLj6eagy6sVhOMQiLtJdxQBHIA9Z6HFUNLOlr6MFOgzV8wvmidtPONfPtEUv0uZsy77XJNzTAfwPDaA==} + type-fest@4.30.1: + resolution: {integrity: sha512-ojFL7eDMX2NF0xMbDwPZJ8sb7ckqtlAi1GsmgsFXvErT9kFTk1r0DuQKvrCh73M6D4nngeHJmvogF9OluXs7Hw==} engines: {node: '>=16'} typesafe-path@0.2.2: @@ -2462,12 +2462,12 @@ snapshots: transitivePeerDependencies: - supports-color - '@astrojs/mdx@3.1.9(astro@4.16.17(rollup@4.28.1)(sass@1.82.0)(terser@5.36.0)(typescript@5.7.2))': + '@astrojs/mdx@3.1.9(astro@4.16.17(rollup@4.28.1)(sass@1.83.0)(terser@5.36.0)(typescript@5.7.2))': dependencies: '@astrojs/markdown-remark': 5.3.0 '@mdx-js/mdx': 3.1.0(acorn@8.14.0) acorn: 8.14.0 - astro: 4.16.17(rollup@4.28.1)(sass@1.82.0)(terser@5.36.0)(typescript@5.7.2) + astro: 4.16.17(rollup@4.28.1)(sass@1.83.0)(terser@5.36.0)(typescript@5.7.2) es-module-lexer: 1.5.4 estree-util-visit: 2.0.0 gray-matter: 4.0.3 @@ -2486,15 +2486,15 @@ snapshots: dependencies: prismjs: 1.29.0 - '@astrojs/react@3.6.3(@types/react-dom@18.3.5(@types/react@18.3.16))(@types/react@18.3.16)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.82.0)(terser@5.36.0)': + '@astrojs/react@3.6.3(@types/react-dom@18.3.5(@types/react@18.3.16))(@types/react@18.3.16)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.83.0)(terser@5.36.0)': dependencies: '@types/react': 18.3.16 '@types/react-dom': 18.3.5(@types/react@18.3.16) - '@vitejs/plugin-react': 4.3.4(vite@5.4.11(sass@1.82.0)(terser@5.36.0)) + '@vitejs/plugin-react': 4.3.4(vite@5.4.11(sass@1.83.0)(terser@5.36.0)) react: 18.3.1 react-dom: 18.3.1(react@18.3.1) ultrahtml: 1.5.3 - vite: 5.4.11(sass@1.82.0)(terser@5.36.0) + vite: 5.4.11(sass@1.83.0)(terser@5.36.0) transitivePeerDependencies: - '@types/node' - less @@ -2512,16 +2512,16 @@ snapshots: stream-replace-string: 2.0.0 zod: 3.24.1 - '@astrojs/starlight@0.29.3(astro@4.16.17(rollup@4.28.1)(sass@1.82.0)(terser@5.36.0)(typescript@5.7.2))': + '@astrojs/starlight@0.29.3(astro@4.16.17(rollup@4.28.1)(sass@1.83.0)(terser@5.36.0)(typescript@5.7.2))': dependencies: - '@astrojs/mdx': 3.1.9(astro@4.16.17(rollup@4.28.1)(sass@1.82.0)(terser@5.36.0)(typescript@5.7.2)) + '@astrojs/mdx': 3.1.9(astro@4.16.17(rollup@4.28.1)(sass@1.83.0)(terser@5.36.0)(typescript@5.7.2)) '@astrojs/sitemap': 3.2.1 '@pagefind/default-ui': 1.2.0 '@types/hast': 3.0.4 '@types/js-yaml': 4.0.9 '@types/mdast': 4.0.4 - astro: 4.16.17(rollup@4.28.1)(sass@1.82.0)(terser@5.36.0)(typescript@5.7.2) - astro-expressive-code: 0.38.3(astro@4.16.17(rollup@4.28.1)(sass@1.82.0)(terser@5.36.0)(typescript@5.7.2)) + astro: 4.16.17(rollup@4.28.1)(sass@1.83.0)(terser@5.36.0)(typescript@5.7.2) + astro-expressive-code: 0.38.3(astro@4.16.17(rollup@4.28.1)(sass@1.83.0)(terser@5.36.0)(typescript@5.7.2)) bcp-47: 2.1.0 hast-util-from-html: 2.0.3 hast-util-select: 6.0.3 @@ -3211,14 +3211,14 @@ snapshots: '@ungap/structured-clone@1.2.1': {} - '@vitejs/plugin-react@4.3.4(vite@5.4.11(sass@1.82.0)(terser@5.36.0))': + '@vitejs/plugin-react@4.3.4(vite@5.4.11(sass@1.83.0)(terser@5.36.0))': dependencies: '@babel/core': 7.26.0 '@babel/plugin-transform-react-jsx-self': 7.25.9(@babel/core@7.26.0) '@babel/plugin-transform-react-jsx-source': 7.25.9(@babel/core@7.26.0) '@types/babel__core': 7.20.5 react-refresh: 0.14.2 - vite: 5.4.11(sass@1.82.0)(terser@5.36.0) + vite: 5.4.11(sass@1.83.0)(terser@5.36.0) transitivePeerDependencies: - supports-color @@ -3313,12 +3313,12 @@ snapshots: astring@1.9.0: {} - astro-expressive-code@0.38.3(astro@4.16.17(rollup@4.28.1)(sass@1.82.0)(terser@5.36.0)(typescript@5.7.2)): + astro-expressive-code@0.38.3(astro@4.16.17(rollup@4.28.1)(sass@1.83.0)(terser@5.36.0)(typescript@5.7.2)): dependencies: - astro: 4.16.17(rollup@4.28.1)(sass@1.82.0)(terser@5.36.0)(typescript@5.7.2) + astro: 4.16.17(rollup@4.28.1)(sass@1.83.0)(terser@5.36.0)(typescript@5.7.2) rehype-expressive-code: 0.38.3 - astro@4.16.17(rollup@4.28.1)(sass@1.82.0)(terser@5.36.0)(typescript@5.7.2): + astro@4.16.17(rollup@4.28.1)(sass@1.83.0)(terser@5.36.0)(typescript@5.7.2): dependencies: '@astrojs/compiler': 2.10.3 '@astrojs/internal-helpers': 0.4.1 @@ -3374,8 +3374,8 @@ snapshots: tsconfck: 3.1.4(typescript@5.7.2) unist-util-visit: 5.0.0 vfile: 6.0.3 - vite: 5.4.11(sass@1.82.0)(terser@5.36.0) - vitefu: 1.0.4(vite@5.4.11(sass@1.82.0)(terser@5.36.0)) + vite: 5.4.11(sass@1.83.0)(terser@5.36.0) + vitefu: 1.0.4(vite@5.4.11(sass@1.83.0)(terser@5.36.0)) which-pm: 3.0.0 xxhash-wasm: 1.1.0 yargs-parser: 21.1.1 @@ -3420,7 +3420,7 @@ snapshots: chalk: 5.3.0 cli-boxes: 3.0.0 string-width: 7.2.0 - type-fest: 4.30.0 + type-fest: 4.30.1 widest-line: 5.0.0 wrap-ansi: 9.0.0 @@ -3430,8 +3430,8 @@ snapshots: browserslist@4.24.2: dependencies: - caniuse-lite: 1.0.30001687 - electron-to-chromium: 1.5.72 + caniuse-lite: 1.0.30001688 + electron-to-chromium: 1.5.73 node-releases: 2.0.19 update-browserslist-db: 1.1.1(browserslist@4.24.2) @@ -3440,7 +3440,7 @@ snapshots: camelcase@8.0.0: {} - caniuse-lite@1.0.30001687: {} + caniuse-lite@1.0.30001688: {} ccount@2.0.1: {} @@ -3544,7 +3544,7 @@ snapshots: dset@3.1.4: {} - electron-to-chromium@1.5.72: {} + electron-to-chromium@1.5.73: {} emmet@2.4.11: dependencies: @@ -4053,7 +4053,7 @@ snapshots: devlop: 1.1.0 mdast-util-from-markdown: 2.0.2 mdast-util-to-markdown: 2.1.2 - parse-entities: 4.0.1 + parse-entities: 4.0.2 stringify-entities: 4.0.4 unist-util-visit-parents: 6.0.1 transitivePeerDependencies: @@ -4161,7 +4161,7 @@ snapshots: devlop: 1.1.0 mdast-util-from-markdown: 2.0.2 mdast-util-to-markdown: 2.1.2 - parse-entities: 4.0.1 + parse-entities: 4.0.2 stringify-entities: 4.0.4 unist-util-stringify-position: 4.0.0 vfile-message: 4.0.2 @@ -4251,7 +4251,7 @@ snapshots: micromark-util-character: 2.1.1 micromark-util-symbol: 2.0.1 micromark-util-types: 2.0.1 - parse-entities: 4.0.1 + parse-entities: 4.0.2 micromark-extension-gfm-autolink-literal@2.1.0: dependencies: @@ -4581,10 +4581,9 @@ snapshots: '@pagefind/linux-x64': 1.2.0 '@pagefind/windows-x64': 1.2.0 - parse-entities@4.0.1: + parse-entities@4.0.2: dependencies: '@types/unist': 2.0.11 - character-entities: 2.0.2 character-entities-legacy: 3.0.0 character-reference-invalid: 2.0.1 decode-named-character-reference: 1.0.2 @@ -4892,7 +4891,7 @@ snapshots: dependencies: queue-microtask: 1.2.3 - sass@1.82.0: + sass@1.83.0: dependencies: chokidar: 4.0.1 immutable: 5.0.3 @@ -5048,7 +5047,7 @@ snapshots: tslib@2.8.1: optional: true - type-fest@4.30.0: {} + type-fest@4.30.1: {} typesafe-path@0.2.2: {} @@ -5149,19 +5148,19 @@ snapshots: '@types/unist': 3.0.3 vfile-message: 4.0.2 - vite@5.4.11(sass@1.82.0)(terser@5.36.0): + vite@5.4.11(sass@1.83.0)(terser@5.36.0): dependencies: esbuild: 0.21.5 postcss: 8.4.49 rollup: 4.28.1 optionalDependencies: fsevents: 2.3.3 - sass: 1.82.0 + sass: 1.83.0 terser: 5.36.0 - vitefu@1.0.4(vite@5.4.11(sass@1.82.0)(terser@5.36.0)): + vitefu@1.0.4(vite@5.4.11(sass@1.83.0)(terser@5.36.0)): optionalDependencies: - vite: 5.4.11(sass@1.82.0)(terser@5.36.0) + vite: 5.4.11(sass@1.83.0)(terser@5.36.0) volar-service-css@0.0.62(@volar/language-service@2.4.10): dependencies: diff --git a/metadata/en-US/changelogs/124.txt b/metadata/en-US/changelogs/124.txt index da91336b945e..b5389bf73ef4 100644 --- a/metadata/en-US/changelogs/124.txt +++ b/metadata/en-US/changelogs/124.txt @@ -12,6 +12,9 @@ * Fix ruler not working correctly in pen tool * Fix ruler position is wrong when moving on the canvas * Fix zoom dependent not working correctly with the label tool ([#765](https://github.com/LinwoodDev/Butterfly/issues/765)) +* Fix temporary import handler does not get removed after clicking +* Fix asset hash not correctly working with filenames +* Fix duplicated asset importing * Upgrade to flutter 3.27 Read more here: https://linwood.dev/butterfly/2.2.3-rc.1 \ No newline at end of file