Skip to content

Commit

Permalink
Fix document isn't saved when clicking home
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Dec 14, 2024
1 parent 47d9bc4 commit ac117f6
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions app/lib/bloc/document_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1116,10 +1116,10 @@ class DocumentBloc extends ReplayBloc<DocumentEvent, DocumentState> {
state.assetService?.dispose();
}

void save() {
Future<void> save() {
final current = state;
if (current is! DocumentLoadSuccess) return;
current.save();
if (current is! DocumentLoadSuccess) return Future.value();
return current.save();
}

bool isInBounds(Offset globalPosition) {
Expand Down
4 changes: 3 additions & 1 deletion app/lib/handlers/import.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ class ImportHandler extends Handler<ImportTool> {
.copyWith(id: createUniqueId()))
.nonNulls
.toList()));
context.getCurrentIndexCubit().resetTemporaryHandler(context.getDocumentBloc());
context
.getCurrentIndexCubit()
.resetTemporaryHandler(context.getDocumentBloc());
context.refresh();
context.bake();
}
Expand Down
4 changes: 3 additions & 1 deletion app/lib/views/app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,10 @@ class _MainPopupMenu extends StatelessWidget {
MenuItemButton(
leadingIcon: const PhosphorIcon(PhosphorIconsLight.house),
child: Text(AppLocalizations.of(context).home),
onPressed: () {
onPressed: () async {
final router = GoRouter.of(context);
final bloc = context.read<DocumentBloc>();
await bloc.save();
if (router.canPop()) {
router.pop();
} else {
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": "^4.1.0",
"@astrojs/starlight": "^0.30.0",
"@astrojs/starlight": "^0.30.1",
"@phosphor-icons/react": "^2.1.7",
"@types/react": "^19.0.1",
"@types/react-dom": "^19.0.2",
Expand Down
10 changes: 5 additions & 5 deletions docs/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions metadata/en-US/changelogs/124.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* Fix duplicated asset importing
* Fix aspect ratio label in area tool selection view
* Fix add dialog shows "No element" if there is only import search results
* Fix document isn't saved when clicking home
* Show git hash instead of version in web version
* Upgrade to flutter 3.27

Expand Down

0 comments on commit ac117f6

Please sign in to comment.