Skip to content

Commit

Permalink
fix: disable notification auto sync temporarily
Browse files Browse the repository at this point in the history
Disable the current problematic implementation and enable it when fixed
one day.

Fixes: #149
  • Loading branch information
realth000 committed Dec 25, 2024
1 parent 1944784 commit 16918d6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 46 deletions.
6 changes: 3 additions & 3 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ class _AppState extends State<App> with WindowListener {
notificationRepository: context.repo(),
storageProvider: getIt(),
);
if (widget.autoSyncNoticeSeconds > 0) {
bloc.start(Duration(seconds: widget.autoSyncNoticeSeconds));
}
// if (widget.autoSyncNoticeSeconds > 0) {
// bloc.start(Duration(seconds: widget.autoSyncNoticeSeconds));
// }
return bloc;
},
),
Expand Down
84 changes: 41 additions & 43 deletions lib/features/settings/view/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ import 'package:system_theme/system_theme.dart';
import 'package:tsdm_client/constants/constants.dart';
import 'package:tsdm_client/constants/layout.dart';
import 'package:tsdm_client/extensions/color.dart';
import 'package:tsdm_client/extensions/duration.dart';
import 'package:tsdm_client/features/checkin/models/models.dart';
import 'package:tsdm_client/features/notification/bloc/auto_notification_cubit.dart';
import 'package:tsdm_client/features/settings/bloc/settings_bloc.dart';
import 'package:tsdm_client/features/settings/repositories/settings_repository.dart';
import 'package:tsdm_client/features/settings/view/debug_showcase_page.dart';
import 'package:tsdm_client/features/settings/widgets/auto_sync_notice_dialog.dart';
import 'package:tsdm_client/features/settings/widgets/check_in_dialog.dart';
import 'package:tsdm_client/features/settings/widgets/clear_cache_bottom_sheet.dart';
import 'package:tsdm_client/features/settings/widgets/color_picker_dialog.dart';
Expand Down Expand Up @@ -433,12 +430,12 @@ class _SettingsPageState extends State<SettingsPage> {
final tr = context.t.settingsPage.behaviorSection;
final doublePressExit = state.settingsMap.doublePressExit;
final threadReverseOrder = state.settingsMap.threadReverseOrder;
// Duration in seconds.
final autoSyncNoticeSeconds = state.settingsMap.autoSyncNoticeSeconds;
Duration? autoSyncNoticeDuration;
if (autoSyncNoticeSeconds > 0) {
autoSyncNoticeDuration = Duration(seconds: autoSyncNoticeSeconds);
}
// // Duration in seconds.
// final autoSyncNoticeSeconds = state.settingsMap.autoSyncNoticeSeconds;
// Duration? autoSyncNoticeDuration;
// if (autoSyncNoticeSeconds > 0) {
// autoSyncNoticeDuration = Duration(seconds: autoSyncNoticeSeconds);
// }

return [
SectionTitleText(tr.title),
Expand All @@ -463,40 +460,41 @@ class _SettingsPageState extends State<SettingsPage> {
.read<SettingsBloc>()
.add(SettingsValueChanged(SettingsKeys.threadReverseOrder, v)),
),
SectionListTile(
leading: const Icon(Icons.sync_outlined),
title: Text(tr.autoSyncNotice.title),
subtitle: Text(tr.autoSyncNotice.detail),
trailing: Text(
autoSyncNoticeDuration?.readable(context) ?? context.t.general.never,
style: Theme.of(context)
.textTheme
.labelMedium
?.copyWith(color: Theme.of(context).colorScheme.secondary),
),
onTap: () async {
final seconds = await showDialog<int>(
context: context,
builder: (_) => AutoSyncNoticeDialog(autoSyncNoticeSeconds),
);
if (seconds == null || !context.mounted) {
return;
}
if (seconds > 0) {
context
.read<AutoNotificationCubit>()
.start(Duration(seconds: seconds));
} else {
context.read<AutoNotificationCubit>().stop();
}
context.read<SettingsBloc>().add(
SettingsValueChanged(
SettingsKeys.autoSyncNoticeSeconds,
seconds,
),
);
},
),
// SectionListTile(
// leading: const Icon(Icons.sync_outlined),
// title: Text(tr.autoSyncNotice.title),
// subtitle: Text(tr.autoSyncNotice.detail),
// trailing: Text(
// autoSyncNoticeDuration?.readable(context) ??
// context.t.general.never,
// style: Theme.of(context)
// .textTheme
// .labelMedium
// ?.copyWith(color: Theme.of(context).colorScheme.secondary),
// ),
// onTap: () async {
// final seconds = await showDialog<int>(
// context: context,
// builder: (_) => AutoSyncNoticeDialog(autoSyncNoticeSeconds),
// );
// if (seconds == null || !context.mounted) {
// return;
// }
// if (seconds > 0) {
// context
// .read<AutoNotificationCubit>()
// .start(Duration(seconds: seconds));
// } else {
// context.read<AutoNotificationCubit>().stop();
// }
// context.read<SettingsBloc>().add(
// SettingsValueChanged(
// SettingsKeys.autoSyncNoticeSeconds,
// seconds,
// ),
// );
// },
// ),
];
}

Expand Down

0 comments on commit 16918d6

Please sign in to comment.