Skip to content

Commit

Permalink
Fix packs dialog file system operations
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Nov 10, 2024
1 parent ff6fa96 commit 9446405
Show file tree
Hide file tree
Showing 6 changed files with 221 additions and 215 deletions.
18 changes: 9 additions & 9 deletions app/android/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ GEM
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.996.0)
aws-sdk-core (3.211.0)
aws-partitions (1.1003.0)
aws-sdk-core (3.212.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.95.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.169.0)
aws-sdk-s3 (1.170.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
Expand Down Expand Up @@ -109,7 +109,7 @@ GEM
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.73.0)
google-apis-androidpublisher_v3 (0.74.0)
google-apis-core (>= 0.15.0, < 2.a)
google-apis-core (0.15.1)
addressable (~> 2.5, >= 2.5.1)
Expand All @@ -119,7 +119,7 @@ GEM
mutex_m
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
google-apis-iamcredentials_v1 (0.21.0)
google-apis-iamcredentials_v1 (0.22.0)
google-apis-core (>= 0.15.0, < 2.a)
google-apis-playcustomapp_v1 (0.16.0)
google-apis-core (>= 0.15.0, < 2.a)
Expand Down Expand Up @@ -152,7 +152,7 @@ GEM
domain_name (~> 0.5)
httpclient (2.8.3)
jmespath (1.6.2)
json (2.7.4)
json (2.8.1)
jwt (2.9.3)
base64
mini_magick (4.13.2)
Expand All @@ -163,7 +163,7 @@ GEM
nanaimo (0.4.0)
naturally (2.2.1)
nkf (0.2.0)
optparse (0.5.0)
optparse (0.6.0)
os (1.1.4)
plist (3.7.1)
public_suffix (6.0.1)
Expand Down Expand Up @@ -199,7 +199,7 @@ GEM
uber (0.1.0)
unicode-display_width (2.6.0)
word_wrap (1.0.0)
xcodeproj (1.26.0)
xcodeproj (1.27.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
Expand All @@ -222,4 +222,4 @@ DEPENDENCIES
screengrab

BUNDLED WITH
2.5.22
2.5.23
19 changes: 12 additions & 7 deletions app/lib/dialogs/packs/dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,16 @@ class _PacksDialogState extends State<PacksDialog>
shrinkWrap: true,
itemCount: globalPacks.length,
itemBuilder: (context, index) {
final pack = globalPacks[index].data!;
final file = globalPacks[index];
final pack = file.data!;
final metadata = pack.getMetadata();
if (metadata == null) return Container();
return Dismissible(
key: ValueKey(('globalpack', metadata.name)),
onDismissed: (direction) async {
setInnerState(
() => globalPacks.removeAt(index));
await _packSystem.deleteFile(metadata.name);
await _packSystem.deleteFile(file.path);
if (mounted) setState(() {});
},
background: Container(
Expand Down Expand Up @@ -245,7 +246,7 @@ class _PacksDialogState extends State<PacksDialog>
.delete),
onPressed: () async {
await _packSystem
.deleteFile(metadata.name);
.deleteFile(file.path);
if (mounted) {
setState(() {});
}
Expand Down Expand Up @@ -297,10 +298,10 @@ class _PacksDialogState extends State<PacksDialog>
final name = newPack.name ?? '';
if (pack.name != name) {
await _packSystem
.deleteFile(metadata.name);
.deleteFile(file.path);
}
await _packSystem.updateFile(
name, newPack);
'$name.bfly', newPack);
setState(() {});
},
trailing: button,
Expand Down Expand Up @@ -418,7 +419,10 @@ class _PacksDialogState extends State<PacksDialog>
Navigator.of(ctx).pop();
final pack = await DocumentDefaults.getCorePack();
if (_isGlobal()) {
await _packSystem.deleteFile(pack.name!);
try {
await _packSystem
.deleteFile('${pack.name!}.bfly');
} catch (_) {}
} else if (mounted) {
final bloc = context.read<DocumentBloc>();
bloc.add(PackRemoved(pack.name!));
Expand All @@ -444,7 +448,8 @@ class _PacksDialogState extends State<PacksDialog>

Future<void> _addPack(NoteData pack, [bool? global]) async {
if (global ?? _isGlobal()) {
await _packSystem.createFile(pack.name ?? '', pack);
await _packSystem.createFileWithName(pack,
name: pack.name ?? '', suffix: '.bfly');
setState(() {});
} else {
context.read<DocumentBloc>().add(PackAdded(pack));
Expand Down
8 changes: 4 additions & 4 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1253,10 +1253,10 @@ packages:
dependency: "direct main"
description:
name: shared_preferences
sha256: "746e5369a43170c25816cc472ee016d3a66bc13fcf430c0bc41ad7b4b2922051"
sha256: "95f9997ca1fb9799d494d0cb2a780fd7be075818d59f00c43832ed112b158a82"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
version: "2.3.3"
shared_preferences_android:
dependency: transitive
description:
Expand Down Expand Up @@ -1562,10 +1562,10 @@ packages:
dependency: transitive
description:
name: vector_graphics_compiler
sha256: "26d520739b7c6b5d2a2b3274427874a8390831fd4cd5bb8cfbd7d913477d3a2e"
sha256: ab9ff38fc771e9ee1139320adbe3d18a60327370c218c60752068ebee4b49ab1
url: "https://pub.dev"
source: hosted
version: "1.1.14"
version: "1.1.15"
vector_math:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"@astrojs/check": "^0.9.4",
"@astrojs/react": "^3.6.2",
"@astrojs/starlight": "^0.28.6",
"@astrojs/starlight": "^0.29.0",
"@phosphor-icons/react": "^2.1.7",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
Expand Down
Loading

0 comments on commit 9446405

Please sign in to comment.