Skip to content

Commit

Permalink
Save deleted images in cache, closes #465
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Jul 28, 2023
1 parent a77f82b commit a36a886
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 9 additions & 4 deletions app/lib/services/asset.dart
Expand Up @@ -7,6 +7,7 @@ import '../helpers/element_helper.dart';

class AssetService {
final NoteData document;
final Map<String, Uint8List> _cached = {};
final Map<String, ui.Image> _images = {};

AssetService(this.document);
Expand All @@ -15,11 +16,15 @@ class AssetService {
if (_images.containsKey(path)) {
return _images[path]!.clone();
}
final data = await getDataFromSource(document, path);
if (data == null) {
return null;
var listData = await getDataFromSource(document, path);
if (listData == null) {
listData = _cached[path];
if (listData == null) return null;
document.setAsset(Uri.parse(path).path, listData);
}
final codec = await ui.instantiateImageCodec(Uint8List.fromList(data));
final data = Uint8List.fromList(listData);
_cached[path] = data;
final codec = await ui.instantiateImageCodec(data);
final frameInfo = await codec.getNextFrame();
final image = frameInfo.image;
_images[path] = image;
Expand Down
6 changes: 4 additions & 2 deletions fastlane/metadata/android/en-US/changelogs/70.txt
@@ -1,11 +1,13 @@
* Add sort order ([#469](https://github.com/LinwoodDev/Butterfly/issues/469))
* Save sort state ([#469](https://github.com/LinwoodDev/Butterfly/issues/469))
* Save deleted images in cache
* Fix pasting images not working ([#465](https://github.com/LinwoodDev/Butterfly/issues/465))
* Improve save state icons
* Improve import painter position
* Improve hit calculation on single point pen elements
* Improve performance of quick start view in home page ([#459](https://github.com/LinwoodDev/Butterfly/issues/459))
* Set position to clicked when pasting ([#465](https://github.com/LinwoodDev/Butterfly/issues/465))
* Set position to clicked when pasting ([#468](https://github.com/LinwoodDev/Butterfly/issues/468))
* Fix native title bar error on mobile devices
* Fix internet problems on android ([#457](https://github.com/LinwoodDev/Butterfly/issues/457))
* Fix position when pasting elements ([#465](https://github.com/LinwoodDev/Butterfly/issues/465))
* Fix position when pasting elements ([#468](https://github.com/LinwoodDev/Butterfly/issues/468))
* Fix corner hit detection on hand tool when zoomed

0 comments on commit a36a886

Please sign in to comment.