Skip to content

Commit

Permalink
fix: track tile items not being updated properly
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Dec 24, 2023
1 parent 071d810 commit 7154054
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/controller/indexer_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:just_audio/just_audio.dart';
import 'package:namida/ui/widgets/library/track_tile.dart';
import 'package:on_audio_query/on_audio_query.dart';
import 'package:path/path.dart' as p;
import 'package:system_info2/system_info2.dart';
Expand Down Expand Up @@ -1003,6 +1004,7 @@ class Indexer {
}

Future<void> _saveTrackFileToStorage() async {
TrackTileManager.onTrackItemPropChange();
await File(AppPaths.TRACKS).writeAsJson(tracksInfoList.map((key) => allTracksMappedByPath[key]?.toJson()).toList());
}

Expand All @@ -1026,6 +1028,7 @@ class Indexer {
}

Future<void> _saveTrackStatsFileToStorage() async {
TrackTileManager.onTrackItemPropChange();
await File(AppPaths.TRACKS_STATS).writeAsJson(trackStatsMap.values.map((e) => e.toJson()).toList());
}

Expand Down
10 changes: 8 additions & 2 deletions lib/ui/dialogs/setting_dialog_with_text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:namida/core/extensions.dart';
import 'package:namida/core/icon_fonts/broken_icons.dart';
import 'package:namida/core/translations/language.dart';
import 'package:namida/ui/widgets/custom_widgets.dart';
import 'package:namida/ui/widgets/library/track_tile.dart';

Future<void> showSettingDialogWithTextField({
Widget? topWidget,
Expand All @@ -26,7 +27,6 @@ Future<void> showSettingDialogWithTextField({
bool dateTimeFormat = false,
bool trackTileSeparator = false,
bool addNewPlaylist = false,
void Function()? onTrackTileSettingsChanged,
}) async {
final controller = TextEditingController();
final formKey = GlobalKey<FormState>();
Expand All @@ -49,7 +49,8 @@ Future<void> showSettingDialogWithTextField({
);
}

void onTTSetChange() => onTrackTileSettingsChanged?.call();
void onTTSetChange() {}
void onTIPropChange() => TrackTileManager.onTrackItemPropChange();

await NamidaNavigator.inst.navigateDialog(
onDisposing: () {
Expand Down Expand Up @@ -96,11 +97,13 @@ Future<void> showSettingDialogWithTextField({
if (dateTimeFormat) {
settings.save(dateTimeFormat: 'MMM yyyy');
showResetToDefaultSnackBar("${settings.dateTimeFormat}", title: title);
onTIPropChange();
}
if (trackTileSeparator) {
settings.save(trackTileSeparator: '•');
showResetToDefaultSnackBar("${settings.trackTileSeparator}", title: title);
onTTSetChange();
onTIPropChange();
}

NamidaNavigator.inst.closeDialog();
Expand Down Expand Up @@ -138,10 +141,13 @@ Future<void> showSettingDialogWithTextField({
}
if (dateTimeFormat) {
settings.save(dateTimeFormat: controller.text);
onTTSetChange();
onTIPropChange();
}
if (trackTileSeparator) {
settings.save(trackTileSeparator: controller.text);
onTTSetChange();
onTIPropChange();
}
if (addNewPlaylist) {
PlaylistController.inst.addNewPlaylist(controller.text);
Expand Down

0 comments on commit 7154054

Please sign in to comment.