Skip to content
This repository was archived by the owner on Apr 3, 2025. It is now read-only.

Commit 8fe81d1

Browse files
committed
fix(database): correctly store manually ordered module list
1 parent a0eaca0 commit 8fe81d1

File tree

42 files changed

+177
-268
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+177
-268
lines changed

lib/core/models/configuration/profile.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ class ProfileHiveObject extends HiveObject {
414414
};
415415

416416
bool get anythingEnabled {
417-
for (LunaModule module in LunaModule.DASHBOARD.allModules()) {
417+
for (final module in LunaModule.active) {
418418
if (module.isEnabled) return true;
419419
}
420420
return false;

lib/core/modules.dart

+12-16
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,18 @@ enum LunaModule {
6161
@HiveField(9)
6262
TAUTULLI,
6363
@HiveField(10)
64-
WAKE_ON_LAN,
64+
WAKE_ON_LAN;
65+
66+
/// Returns a list of all system-enabled modules.
67+
///
68+
/// Internal modules (dashboard, settings, etc.) are removed by default.
69+
static List<LunaModule> get active {
70+
return LunaModule.values.filter((m) {
71+
if (m == LunaModule.DASHBOARD) return false;
72+
if (m == LunaModule.SETTINGS) return false;
73+
return m.featureFlag;
74+
}).toList();
75+
}
6576
}
6677

6778
extension LunaModuleExtension on LunaModule {
@@ -95,21 +106,6 @@ extension LunaModuleExtension on LunaModule {
95106
}
96107
}
97108

98-
/// Returns a list of all system-enabled modules.
99-
///
100-
/// Internal modules (dashboard, settings, etc.) are removed by default.
101-
List<LunaModule> allModules({
102-
bool removeInternalModules = true,
103-
}) {
104-
List<LunaModule> _modules =
105-
LunaModule.values.filter((module) => module.featureFlag).toList();
106-
if (removeInternalModules) {
107-
_modules.remove(LunaModule.DASHBOARD);
108-
_modules.remove(LunaModule.SETTINGS);
109-
}
110-
return _modules;
111-
}
112-
113109
/// Used to convert a string key back to a [LunaModule] value.
114110
///
115111
/// If the key is not found, returns null.

lib/database/database.dart

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class LunaDatabase {
2020
for (final table in LunaTable.values) table.items[0].registerAdapters();
2121
for (final box in LunaBox.values) await box.open();
2222
if (LunaBox.profiles.box.isEmpty) await bootstrap();
23+
// await bootstrap();
2324
}
2425

2526
Future<void> bootstrap() async {

lib/database/tables/lunasea.dart

+7-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import 'package:lunasea/widgets/ui.dart';
1313

1414
enum LunaSeaDatabase<T> with LunaTableMixin<T> {
1515
DRAWER_AUTOMATIC_MANAGE<bool>(true),
16-
DRAWER_MANUAL_ORDER<List<LunaModule>?>(null),
16+
DRAWER_MANUAL_ORDER<List>([]),
1717
ENABLED_PROFILE<String>('default'),
1818
NETWORKING_TLS_VALIDATION<bool>(false),
1919
THEME_AMOLED<bool>(false),
@@ -76,11 +76,12 @@ enum LunaSeaDatabase<T> with LunaTableMixin<T> {
7676
return;
7777
}
7878
if (this == LunaSeaDatabase.DRAWER_MANUAL_ORDER) {
79-
final item = (value as List)
80-
.map((module) => LunaModule.DASHBOARD.fromKey(module))
81-
.toList();
82-
item.removeWhere((i) => i == null);
83-
update(item.cast<LunaModule>() as T);
79+
List<LunaModule> item = [];
80+
(value as List).cast<String>().forEach((val) {
81+
LunaModule? module = LunaModule.DASHBOARD.fromKey(val);
82+
if (module != null) item.add(module);
83+
});
84+
update(item as T);
8485
return;
8586
}
8687
return super.import(value);

lib/database/tables/sonarr.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ enum SonarrDatabase<T> with LunaTableMixin<T> {
2121
ADD_SERIES_DEFAULT_LANGUAGE_PROFILE<int?>(null),
2222
ADD_SERIES_DEFAULT_QUALITY_PROFILE<int?>(null),
2323
ADD_SERIES_DEFAULT_ROOT_FOLDER<int?>(null),
24-
ADD_SERIES_DEFAULT_TAGS<List?>(null),
24+
ADD_SERIES_DEFAULT_TAGS<List>([]),
2525
DEFAULT_VIEW_SERIES<LunaListViewOption>(LunaListViewOption.BLOCK_VIEW),
2626
DEFAULT_FILTERING_SERIES<SonarrSeriesFilter>(SonarrSeriesFilter.ALL),
2727
DEFAULT_FILTERING_RELEASES<SonarrReleasesFilter>(SonarrReleasesFilter.ALL),

lib/main.dart

+13-15
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,19 @@ class LunaBIOS extends StatelessWidget {
6868
LunaSeaDatabase.THEME_AMOLED_BORDER.key,
6969
]),
7070
builder: (context, dynamic box, _) {
71-
return Layout(
72-
child: MaterialApp(
73-
localizationsDelegates: context.localizationDelegates,
74-
supportedLocales: context.supportedLocales,
75-
locale: context.locale,
76-
builder: DevicePreview.appBuilder,
77-
routes: router.routes,
78-
useInheritedMediaQuery: true,
79-
onGenerateRoute: LunaRouter.router.generator,
80-
navigatorKey: LunaState.navigatorKey,
81-
darkTheme: theme.activeTheme(),
82-
theme: theme.activeTheme(),
83-
scrollBehavior: LunaScrollBehavior(),
84-
title: 'LunaSea',
85-
),
71+
return MaterialApp(
72+
localizationsDelegates: context.localizationDelegates,
73+
supportedLocales: context.supportedLocales,
74+
locale: context.locale,
75+
builder: DevicePreview.appBuilder,
76+
routes: router.routes,
77+
useInheritedMediaQuery: true,
78+
onGenerateRoute: LunaRouter.router.generator,
79+
navigatorKey: LunaState.navigatorKey,
80+
darkTheme: theme.activeTheme(),
81+
theme: theme.activeTheme(),
82+
scrollBehavior: LunaScrollBehavior(),
83+
title: 'LunaSea',
8684
);
8785
},
8886
),

lib/modules/dashboard/routes/dashboard/pages/modules.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class _State extends State<ModulesPage> with AutomaticKeepAliveClientMixin {
4646
List<Widget> _buildAlphabeticalList() {
4747
List<Widget> modules = [];
4848
int index = 0;
49-
LunaModule.DASHBOARD.allModules()
49+
LunaModule.active
5050
..sort((a, b) => a.name.toLowerCase().compareTo(
5151
b.name.toLowerCase(),
5252
))

lib/modules/overseerr/routes/issues/route.dart

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class _State extends State<OverseerrIssuesRoute>
2424
return LunaScaffold(
2525
scaffoldKey: _scaffoldKey,
2626
module: LunaModule.OVERSEERR,
27-
hideDrawer: true,
2827
body: const OverseerrIssuesListView(),
2928
);
3029
}

lib/modules/overseerr/routes/requests/route.dart

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class _State extends State<OverseerrRequestsRoute>
2424
return LunaScaffold(
2525
scaffoldKey: _scaffoldKey,
2626
module: LunaModule.OVERSEERR,
27-
hideDrawer: true,
2827
body: const OverseerrRequestsListView(),
2928
);
3029
}

lib/modules/overseerr/routes/users/route.dart

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class _State extends State<OverseerrUserRoute>
2424
return LunaScaffold(
2525
scaffoldKey: _scaffoldKey,
2626
module: LunaModule.OVERSEERR,
27-
hideDrawer: true,
2827
body: const OverseerrUserListView(),
2928
);
3029
}

lib/modules/radarr/routes/catalogue/route.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@ class _State extends State<RadarrCatalogueRoute>
3939
return LunaScaffold(
4040
scaffoldKey: _scaffoldKey,
4141
body: _body(),
42-
appBar: _appBar() as PreferredSizeWidget?,
43-
hideDrawer: true,
42+
appBar: _appBar(),
4443
);
4544
}
4645

47-
Widget _appBar() {
46+
PreferredSizeWidget _appBar() {
4847
return LunaAppBar.empty(
4948
child: RadarrCatalogueSearchBar(
5049
scrollController: RadarrNavigationBar.scrollControllers[0],

lib/modules/radarr/routes/missing/route.dart

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class _State extends State<RadarrMissingRoute>
2727
return LunaScaffold(
2828
scaffoldKey: _scaffoldKey,
2929
body: _body,
30-
hideDrawer: true,
3130
);
3231
}
3332

lib/modules/radarr/routes/more/route.dart

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class _State extends State<RadarrMoreRoute> with AutomaticKeepAliveClientMixin {
2222
super.build(context);
2323
return LunaScaffold(
2424
scaffoldKey: _scaffoldKey,
25-
hideDrawer: true,
2625
body: _body(),
2726
);
2827
}

lib/modules/radarr/routes/movie_details/widgets/page_cast_crew.dart

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class _State extends State<RadarrMovieDetailsCastCrewPage>
2828
super.build(context);
2929
return LunaScaffold(
3030
module: LunaModule.RADARR,
31-
hideDrawer: true,
3231
scaffoldKey: _scaffoldKey,
3332
body: _body(),
3433
);

lib/modules/radarr/routes/movie_details/widgets/page_files.dart

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class _State extends State<RadarrMovieDetailsFilesPage>
2525
super.build(context);
2626
return LunaScaffold(
2727
module: LunaModule.RADARR,
28-
hideDrawer: true,
2928
scaffoldKey: _scaffoldKey,
3029
body: _body(),
3130
);

lib/modules/radarr/routes/movie_details/widgets/page_history.dart

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class _State extends State<RadarrMovieDetailsHistoryPage>
2828
super.build(context);
2929
return LunaScaffold(
3030
module: LunaModule.RADARR,
31-
hideDrawer: true,
3231
scaffoldKey: _scaffoldKey,
3332
body: _body(),
3433
);

lib/modules/radarr/routes/movie_details/widgets/page_overview.dart

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class _State extends State<RadarrMovieDetailsOverviewPage>
3030
super.build(context);
3131
return LunaScaffold(
3232
module: LunaModule.RADARR,
33-
hideDrawer: true,
3433
scaffoldKey: _scaffoldKey,
3534
body: Selector<RadarrState, Future<List<RadarrMovie>>?>(
3635
selector: (_, state) => state.movies,

lib/modules/radarr/routes/upcoming/route.dart

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class _State extends State<RadarrUpcomingRoute>
2727
return LunaScaffold(
2828
scaffoldKey: _scaffoldKey,
2929
body: _body,
30-
hideDrawer: true,
3130
);
3231
}
3332

lib/modules/settings/routes/configuration/route.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class _State extends State<_Widget> with LunaScrollControllerMixin {
103103
}
104104

105105
List<Widget> _moduleList() {
106-
return ([LunaModule.DASHBOARD, ...LunaModule.DASHBOARD.allModules()])
106+
return ([LunaModule.DASHBOARD, ...LunaModule.active])
107107
.map(_tileFromModuleMap)
108108
.toList();
109109
}

lib/modules/settings/routes/configuration_drawer/route.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class _State extends State<_Widget> with LunaScrollControllerMixin {
7575
LunaModule module = _modules![oIndex];
7676
_modules!.remove(module);
7777
_modules!.insert(nIndex, module);
78-
LunaSeaDatabase.DRAWER_MANUAL_ORDER.update(_modules);
78+
LunaSeaDatabase.DRAWER_MANUAL_ORDER.update(_modules!);
7979
},
8080
),
8181
),

lib/modules/sonarr/routes/add_series_details/state.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ class SonarrSeriesAddDetailsState extends ChangeNotifier {
128128

129129
void initializeTags(List<SonarrTag> tags) {
130130
_tags = tags
131-
.where((tag) => (SonarrDatabase.ADD_SERIES_DEFAULT_TAGS.read() ?? [])
132-
.contains(tag.id))
131+
.where((tag) =>
132+
(SonarrDatabase.ADD_SERIES_DEFAULT_TAGS.read()).contains(tag.id))
133133
.toList();
134134
}
135135

lib/modules/sonarr/routes/catalogue/route.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@ class _State extends State<SonarrCatalogueRoute>
4242
return LunaScaffold(
4343
scaffoldKey: _scaffoldKey,
4444
module: LunaModule.SONARR,
45-
hideDrawer: true,
4645
body: _body(),
47-
appBar: _appBar() as PreferredSizeWidget?,
46+
appBar: _appBar(),
4847
);
4948
}
5049

51-
Widget _appBar() {
50+
PreferredSizeWidget _appBar() {
5251
return LunaAppBar.empty(
5352
child: SonarrSeriesSearchBar(
5453
scrollController: SonarrNavigationBar.scrollControllers[0],

lib/modules/sonarr/routes/missing/route.dart

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class _State extends State<SonarrMissingRoute>
3333
return LunaScaffold(
3434
scaffoldKey: _scaffoldKey,
3535
module: LunaModule.SONARR,
36-
hideDrawer: true,
3736
body: _body(),
3837
);
3938
}

lib/modules/sonarr/routes/more/route.dart

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class _State extends State<SonarrMoreRoute> with AutomaticKeepAliveClientMixin {
2323
return LunaScaffold(
2424
scaffoldKey: _scaffoldKey,
2525
module: LunaModule.SONARR,
26-
hideDrawer: true,
2726
body: _body(),
2827
);
2928
}

lib/modules/sonarr/routes/series_details/widgets/page_history.dart

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class _State extends State<SonarrSeriesDetailsHistoryPage>
2626
return LunaScaffold(
2727
scaffoldKey: _scaffoldKey,
2828
module: LunaModule.SONARR,
29-
hideDrawer: true,
3029
body: _body(),
3130
);
3231
}

lib/modules/sonarr/routes/series_details/widgets/page_overview.dart

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class _State extends State<SonarrSeriesDetailsOverviewPage>
3333
return LunaScaffold(
3434
scaffoldKey: _scaffoldKey,
3535
module: LunaModule.SONARR,
36-
hideDrawer: true,
3736
body: Selector<SonarrState, Future<Map<int?, SonarrSeries>>?>(
3837
selector: (_, state) => state.series,
3938
builder: (context, movies, _) => LunaListView(

lib/modules/sonarr/routes/series_details/widgets/page_seasons.dart

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class _State extends State<SonarrSeriesDetailsSeasonsPage> {
2323
return LunaScaffold(
2424
scaffoldKey: _scaffoldKey,
2525
module: LunaModule.SONARR,
26-
hideDrawer: true,
2726
body: _body(),
2827
);
2928
}

lib/modules/sonarr/routes/upcoming/route.dart

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class _State extends State<SonarrUpcomingRoute>
3232
return LunaScaffold(
3333
scaffoldKey: _scaffoldKey,
3434
module: LunaModule.SONARR,
35-
hideDrawer: true,
3635
body: _body(),
3736
);
3837
}

lib/modules/tautulli/routes/activity/route.dart

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class _State extends State<TautulliActivityRoute>
3232
return LunaScaffold(
3333
scaffoldKey: _scaffoldKey,
3434
module: LunaModule.TAUTULLI,
35-
hideDrawer: true,
3635
body: _body(),
3736
);
3837
}

lib/modules/tautulli/routes/history/route.dart

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class _State extends State<TautulliHistoryRoute>
3232
return LunaScaffold(
3333
scaffoldKey: _scaffoldKey,
3434
module: LunaModule.TAUTULLI,
35-
hideDrawer: true,
3635
body: _body(),
3736
);
3837
}

lib/modules/tautulli/routes/more/route.dart

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class _State extends State<TautulliMoreRoute>
2424
return LunaScaffold(
2525
scaffoldKey: _scaffoldKey,
2626
module: LunaModule.TAUTULLI,
27-
hideDrawer: true,
2827
body: _body,
2928
);
3029
}

lib/modules/tautulli/routes/users/route.dart

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class _State extends State<TautulliUsersRoute>
3232
return LunaScaffold(
3333
scaffoldKey: _scaffoldKey,
3434
module: LunaModule.TAUTULLI,
35-
hideDrawer: true,
3635
body: _body(),
3736
);
3837
}

lib/modules/tautulli/routes/users_details/widgets/history.dart

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class _State extends State<TautulliUserDetailsHistory>
4141
return LunaScaffold(
4242
scaffoldKey: _scaffoldKey,
4343
module: LunaModule.TAUTULLI,
44-
hideDrawer: true,
4544
body: _body(),
4645
);
4746
}

lib/modules/tautulli/routes/users_details/widgets/ip_addresses.dart

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class _State extends State<TautulliUserDetailsIPAddresses>
4242
super.build(context);
4343
return LunaScaffold(
4444
module: LunaModule.TAUTULLI,
45-
hideDrawer: true,
4645
scaffoldKey: _scaffoldKey,
4746
body: _body(),
4847
);

lib/modules/tautulli/routes/users_details/widgets/profile.dart

-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ class _State extends State<TautulliUserDetailsProfile>
6767
return LunaScaffold(
6868
scaffoldKey: _scaffoldKey,
6969
module: LunaModule.TAUTULLI,
70-
hideDrawer: true,
7170
body: _initialLoad ? _body() : const LunaLoader(),
7271
);
7372
}

lib/modules/tautulli/routes/users_details/widgets/synced_items.dart

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class _State extends State<TautulliUserDetailsSyncedItems>
4242
return LunaScaffold(
4343
scaffoldKey: _scaffoldKey,
4444
module: LunaModule.TAUTULLI,
45-
hideDrawer: true,
4645
body: _body(),
4746
);
4847
}

lib/vendor.dart

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export 'package:hive/hive.dart';
1616
export 'package:hive_flutter/hive_flutter.dart';
1717
export 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
1818
export 'package:json_annotation/json_annotation.dart';
19-
export 'package:layout/layout.dart';
2019
export 'package:package_info_plus/package_info_plus.dart';
2120
export 'package:stash/stash_api.dart';
2221
export 'package:stash_memory/stash_memory.dart';

0 commit comments

Comments
 (0)