simplified code across the app and consolidated duplicated helpers
This commit is contained in:
@@ -88,14 +88,10 @@ class DevToolsSettings {
|
||||
if (trimmed.isEmpty) return null;
|
||||
final uri = Uri.tryParse(trimmed);
|
||||
if (uri == null || !uri.hasScheme) return null;
|
||||
if (uri.scheme == 'https') {
|
||||
// always fine
|
||||
} else if (uri.scheme == 'http' && allowsHttpCustomEndpoint) {
|
||||
// dev only
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
if (uri.host.isEmpty) return null;
|
||||
final schemeAllowed =
|
||||
uri.scheme == 'https' ||
|
||||
(uri.scheme == 'http' && allowsHttpCustomEndpoint);
|
||||
if (!schemeAllowed || uri.host.isEmpty) return null;
|
||||
return trimmed.endsWith('/')
|
||||
? trimmed.substring(0, trimmed.length - 1)
|
||||
: trimmed;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import '../../state/app/modules/app_modules.dart';
|
||||
import '../state/app/modules/app_modules.dart';
|
||||
|
||||
part 'modules_settings.g.dart';
|
||||
|
||||
|
||||
@@ -34,8 +34,7 @@ class TimetableFavoritesSettings {
|
||||
/// Adds or removes the element in place. Returns the new favorite state
|
||||
/// (`true` = now starred). Callers persist via `SettingsCubit.val(write: true)`.
|
||||
bool toggle(TimetableElementType type, int id, String label) {
|
||||
final existing = favorites.where((f) => f.type == type && f.id == id);
|
||||
if (existing.isNotEmpty) {
|
||||
if (isFavorite(type, id)) {
|
||||
favorites.removeWhere((f) => f.type == type && f.id == id);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import '../../../view/pages/timetable/data/timetable_name_mode.dart';
|
||||
import '../view/pages/timetable/data/timetable_name_mode.dart';
|
||||
|
||||
part 'timetable_settings.g.dart';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user