mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor(mobile): log asyncvalue errors (#5327)
* refactor: scaffoldwhen to log errors during scaffold body render * refactor: onError and onLoading scaffoldbody * refactor: more scaffold body to custom extension * refactor: add skiploadingonrefresh * Snackbar color --------- Co-authored-by: shalong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
parent
0fe704c6f9
commit
513f252a0c
26 changed files with 203 additions and 215 deletions
|
|
@ -46,9 +46,11 @@ class SharedLinkItem extends ConsumerWidget {
|
|||
} else if (difference.inHours > 0) {
|
||||
expiresText = "shared_link_expires_hours".plural(difference.inHours);
|
||||
} else if (difference.inMinutes > 0) {
|
||||
expiresText = "shared_link_expires_minutes".plural(difference.inMinutes);
|
||||
expiresText =
|
||||
"shared_link_expires_minutes".plural(difference.inMinutes);
|
||||
} else if (difference.inSeconds > 0) {
|
||||
expiresText = "shared_link_expires_seconds".plural(difference.inSeconds);
|
||||
expiresText =
|
||||
"shared_link_expires_seconds".plural(difference.inSeconds);
|
||||
}
|
||||
}
|
||||
return Text(
|
||||
|
|
@ -85,7 +87,12 @@ class SharedLinkItem extends ConsumerWidget {
|
|||
).then((_) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: const Text("shared_link_clipboard_copied_massage").tr(),
|
||||
content: Text(
|
||||
"shared_link_clipboard_copied_massage",
|
||||
style: context.textTheme.bodyLarge?.copyWith(
|
||||
color: context.primaryColor,
|
||||
),
|
||||
).tr(),
|
||||
duration: const Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
|
|
@ -162,9 +169,12 @@ class SharedLinkItem extends ConsumerWidget {
|
|||
Widget buildBottomInfo() {
|
||||
return Row(
|
||||
children: [
|
||||
if (sharedLink.allowUpload) buildInfoChip("shared_link_info_chip_upload".tr()),
|
||||
if (sharedLink.allowDownload) buildInfoChip("shared_link_info_chip_download".tr()),
|
||||
if (sharedLink.showMetadata) buildInfoChip("shared_link_info_chip_metadata".tr()),
|
||||
if (sharedLink.allowUpload)
|
||||
buildInfoChip("shared_link_info_chip_upload".tr()),
|
||||
if (sharedLink.allowDownload)
|
||||
buildInfoChip("shared_link_info_chip_download".tr()),
|
||||
if (sharedLink.showMetadata)
|
||||
buildInfoChip("shared_link_info_chip_metadata".tr()),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -275,7 +275,12 @@ class SharedLinkEditPage extends HookConsumerWidget {
|
|||
).then((_) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: const Text("shared_link_clipboard_copied_massage").tr(),
|
||||
content: Text(
|
||||
"shared_link_clipboard_copied_massage",
|
||||
style: context.textTheme.bodyLarge?.copyWith(
|
||||
color: context.primaryColor,
|
||||
),
|
||||
).tr(),
|
||||
duration: const Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ import 'package:easy_localization/easy_localization.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/extensions/asyncvalue_extensions.dart';
|
||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||
import 'package:immich_mobile/modules/shared_link/models/shared_link.dart';
|
||||
import 'package:immich_mobile/modules/shared_link/providers/shared_link.provider.dart';
|
||||
import 'package:immich_mobile/modules/shared_link/ui/shared_link_item.dart';
|
||||
import 'package:immich_mobile/shared/ui/immich_loading_indicator.dart';
|
||||
|
||||
class SharedLinkPage extends HookConsumerWidget {
|
||||
const SharedLinkPage({Key? key}) : super(key: key);
|
||||
|
|
@ -18,7 +18,10 @@ class SharedLinkPage extends HookConsumerWidget {
|
|||
useEffect(
|
||||
() {
|
||||
ref.read(sharedLinksStateProvider.notifier).fetchLinks();
|
||||
return () => ref.invalidate(sharedLinksStateProvider);
|
||||
return () {
|
||||
if (!context.mounted) return;
|
||||
ref.invalidate(sharedLinksStateProvider);
|
||||
};
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
|
@ -113,11 +116,10 @@ class SharedLinkPage extends HookConsumerWidget {
|
|||
centerTitle: false,
|
||||
),
|
||||
body: SafeArea(
|
||||
child: sharedLinks.when(
|
||||
data: (links) =>
|
||||
child: sharedLinks.widgetWhen(
|
||||
onError: (error, stackTrace) => buildNoShares(),
|
||||
onData: (links) =>
|
||||
links.isNotEmpty ? buildSharesList(links) : buildNoShares(),
|
||||
error: (error, stackTrace) => buildNoShares(),
|
||||
loading: () => const Center(child: ImmichLoadingIndicator()),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue