Add options to settings backup.

This commit is contained in:
stonega 2021-01-24 22:49:58 +08:00
parent 65769a2ec7
commit 566ae0914f
2 changed files with 18 additions and 4 deletions

View File

@ -558,6 +558,8 @@ class SettingState extends ChangeNotifier {
.getBool(defaultValue: false); .getBool(defaultValue: false);
final deleteAfterPlayed = await KeyValueStorage(deleteAfterPlayedKey) final deleteAfterPlayed = await KeyValueStorage(deleteAfterPlayedKey)
.getBool(defaultValue: false); .getBool(defaultValue: false);
final openPlaylistDefault = await _openPlaylistDefaultStorage.getBool(defaultValue: false);
final openAllPodcastDefault = await _openAllPodcastDefaultStorage.getBool(defaultValue: false);
return SettingsBackup( return SettingsBackup(
theme: theme, theme: theme,
@ -591,7 +593,9 @@ class SettingState extends ChangeNotifier {
speedList: speedList, speedList: speedList,
hidePodcastDiscovery: hidePodcastDiscovery, hidePodcastDiscovery: hidePodcastDiscovery,
markListenedAfterSkip: markListenedAfterSKip, markListenedAfterSkip: markListenedAfterSKip,
deleteAfterPlayed: deleteAfterPlayed); deleteAfterPlayed: deleteAfterPlayed,
openPlaylistDefault: openPlaylistDefault,
openAllPodcastDefault: openAllPodcastDefault);
} }
Future<void> restore(SettingsBackup backup) async { Future<void> restore(SettingsBackup backup) async {
@ -631,6 +635,8 @@ class SettingState extends ChangeNotifier {
.saveBool(backup.markListenedAfterSkip); .saveBool(backup.markListenedAfterSkip);
await KeyValueStorage(deleteAfterPlayedKey) await KeyValueStorage(deleteAfterPlayedKey)
.saveBool(backup.deleteAfterPlayed); .saveBool(backup.deleteAfterPlayed);
await _openPlaylistDefaultStorage.saveBool(backup.openPlaylistDefault);
await _openAllPodcastDefaultStorage.saveBool(backup.openAllPodcastDefault);
if (backup.locale == '') { if (backup.locale == '') {
await _localeStorage.saveStringList([]); await _localeStorage.saveStringList([]);

View File

@ -31,6 +31,8 @@ class SettingsBackup {
final bool hidePodcastDiscovery; final bool hidePodcastDiscovery;
final bool markListenedAfterSkip; final bool markListenedAfterSkip;
final bool deleteAfterPlayed; final bool deleteAfterPlayed;
final bool openPlaylistDefault;
final bool openAllPodcastDefault;
SettingsBackup( SettingsBackup(
{this.theme, {this.theme,
@ -64,7 +66,9 @@ class SettingsBackup {
this.speedList, this.speedList,
this.hidePodcastDiscovery, this.hidePodcastDiscovery,
this.markListenedAfterSkip, this.markListenedAfterSkip,
this.deleteAfterPlayed}); this.deleteAfterPlayed,
this.openPlaylistDefault,
this.openAllPodcastDefault});
Map<String, Object> toJson() { Map<String, Object> toJson() {
return { return {
@ -98,7 +102,9 @@ class SettingsBackup {
'speedList': speedList, 'speedList': speedList,
'hidePodcastDiscovery': hidePodcastDiscovery, 'hidePodcastDiscovery': hidePodcastDiscovery,
'markListenedAfterSkip': markListenedAfterSkip, 'markListenedAfterSkip': markListenedAfterSkip,
'deleteAfterPlayed': deleteAfterPlayed 'deleteAfterPlayed': deleteAfterPlayed,
'openPlaylistDefault': openPlaylistDefault,
'openAllPodcastDefault': openAllPodcastDefault
}; };
} }
@ -136,6 +142,8 @@ class SettingsBackup {
speedList: speedList, speedList: speedList,
hidePodcastDiscovery: json['hidePodcastDiscovery'] as bool, hidePodcastDiscovery: json['hidePodcastDiscovery'] as bool,
markListenedAfterSkip: json['markListenedAfterSkip'] as bool, markListenedAfterSkip: json['markListenedAfterSkip'] as bool,
deleteAfterPlayed: json['deleteAfterPlayed'] as bool); deleteAfterPlayed: json['deleteAfterPlayed'] as bool,
openPlaylistDefault: json['openPlaylistDefaullt'] as bool,
openAllPodcastDefault: json['openAllPodcastDefault'] as bool);
} }
} }