fix: comments were kinda ass

This commit is contained in:
2026-09-16 22:33:14 +02:00
parent f6d7c21691
commit 33d9ae11d8
9 changed files with 33 additions and 49 deletions
-1
View File
@@ -33,7 +33,6 @@ class _AppBootstrapState extends State<AppBootstrap> {
DefaultExportService(database: database).uploadToServer(); DefaultExportService(database: database).uploadToServer();
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky); SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
}); });
} }
+29 -27
View File
@@ -57,8 +57,8 @@ bool _mustBeOnLock(PinLockViewModel pinLockViewModel) {
!pinLockViewModel.isPinSet && pinLockViewModel.pinRequired; !pinLockViewModel.isPinSet && pinLockViewModel.pinRequired;
final isLocked = final isLocked =
pinLockViewModel.isPinSet && pinLockViewModel.isPinSet &&
!pinLockViewModel.isUnlocked && !pinLockViewModel.isUnlocked &&
pinLockViewModel.pinRequired; pinLockViewModel.pinRequired;
return needsPinSetup || isLocked; return needsPinSetup || isLocked;
} }
@@ -81,47 +81,49 @@ bool _isDebugShortcutArea(String location) {
location.startsWith('/history/'); location.startsWith('/history/');
} }
GoRouter createAppRouter( GoRouter createAppRouter(PinLockViewModel pinLockViewModel, {
PinLockViewModel pinLockViewModel, {
required AdminPinViewModel adminPinViewModel, required AdminPinViewModel adminPinViewModel,
}) { }) {
return GoRouter( return GoRouter(
initialLocation: '/bar', initialLocation: '/bar',
observers: [routeObserver, SentryNavigatorObserver()], observers: [routeObserver, SentryNavigatorObserver()],
refreshListenable: Listenable.merge([pinLockViewModel, adminPinViewModel]), refreshListenable: Listenable.merge([pinLockViewModel, adminPinViewModel]),
redirect: (_, state) => _redirectApp( redirect: (_, state) =>
pinLockViewModel: pinLockViewModel, _redirectApp(
adminPinViewModel: adminPinViewModel, pinLockViewModel: pinLockViewModel,
state: state, adminPinViewModel: adminPinViewModel,
), state: state,
),
routes: [ routes: [
GoRoute(path: '/', redirect: (context, state) => '/bar'), GoRoute(path: '/', redirect: (context, state) => '/bar'),
GoRoute( GoRoute(
path: '/lock', path: '/lock',
builder: (context, state) => PinEntryView( builder: (context, state) =>
mode: pinLockViewModel.isPinSet PinEntryView(
? PinEntryMode.unlock mode: pinLockViewModel.isPinSet
: PinEntryMode.create, ? PinEntryMode.unlock
onSuccess: () { : PinEntryMode.create,
context.go("/bar"); onSuccess: () {
}, context.go("/bar");
), },
),
), ),
GoRoute(path: '/bar', builder: (context, state) => const BarScreenView()), GoRoute(path: '/bar', builder: (context, state) => const BarScreenView()),
GoRoute( GoRoute(
path: '/admin/lock', path: '/admin/lock',
builder: (context, state) => PinEntryView( builder: (context, state) =>
mode: adminPinViewModel.isPinSet PinEntryView(
? PinEntryMode.unlock mode: adminPinViewModel.isPinSet
: PinEntryMode.create, ? PinEntryMode.unlock
isAdmin: true, : PinEntryMode.create,
onVerify: adminPinViewModel.verify, isAdmin: true,
onSet: adminPinViewModel.setPin, onVerify: adminPinViewModel.verify,
errorMessage: () => adminPinViewModel.errorMessage, onSet: adminPinViewModel.setPin,
onSuccess: () => context.go('/admin'), errorMessage: () => adminPinViewModel.errorMessage,
), onSuccess: () => context.go('/admin'),
),
), ),
GoRoute( GoRoute(
-2
View File
@@ -53,5 +53,3 @@ class BarTab {
Object.hashAll(items), Object.hashAll(items),
); );
} }
// _listEquals moved to utils/collection_utils.dart
-2
View File
@@ -53,5 +53,3 @@ class ClosedTab {
Object.hashAll(items), Object.hashAll(items),
); );
} }
// _listEquals moved to utils/collection_utils.dart
+2 -2
View File
@@ -28,10 +28,10 @@ class DefaultExportService implements ExportService {
); );
if (response.statusCode != 200 && response.statusCode != 201) { if (response.statusCode != 200 && response.statusCode != 201) {
// Silently fail - this is a non-critical background operation // Should prob log this one tho
} }
} catch (_) { } catch (_) {
// Silently fail - this is a non-critical background operation // if this fails who cares
} }
} }
+1 -1
View File
@@ -1,2 +1,2 @@
const kUpdateServerUrl = 'https://updater.brammie15.dev'; const kUpdateServerUrl = 'https://updater.brammie15.dev';
const kExportServerUrl = 'https://your-server.com/api/backup'; const kExportServerUrl = 'https://kooltab.brammie15.dev/api/backup';
-2
View File
@@ -54,14 +54,12 @@ class AppUpdateUtil {
AppUpdateUtil({required this.serverUrl}); AppUpdateUtil({required this.serverUrl});
/// Gets the installed app version
Future<String> currentVersion() async { Future<String> currentVersion() async {
final info = await PackageInfo.fromPlatform(); final info = await PackageInfo.fromPlatform();
debugPrint("Current app version: ${info.version}"); debugPrint("Current app version: ${info.version}");
return info.version; return info.version;
} }
/// Checks the update server
Future<UpdateInfo?> checkForUpdate() async { Future<UpdateInfo?> checkForUpdate() async {
final version = await currentVersion(); final version = await currentVersion();
+1 -10
View File
@@ -40,7 +40,7 @@ class PinLockViewModel extends ChangeNotifier {
await load(); await load();
} }
/// Checks whether a PIN has already been configured on this device. // Checks whether a pin has already been configured on this device.
Future<void> load() async { Future<void> load() async {
if (_isLoading) return; if (_isLoading) return;
@@ -66,9 +66,6 @@ class PinLockViewModel extends ChangeNotifier {
} }
} }
/// Creates a new PIN (first-time setup, or after disabling an old one).
/// Unlocks the app immediately on success, since the person just proved
/// they know it by typing it.
Future<bool> setPin(String pin) async { Future<bool> setPin(String pin) async {
_errorMessage = null; _errorMessage = null;
@@ -94,7 +91,6 @@ class PinLockViewModel extends ChangeNotifier {
} }
} }
/// Checks an entered PIN against the stored one, unlocking on match.
Future<bool> verify(String pin) async { Future<bool> verify(String pin) async {
_errorMessage = null; _errorMessage = null;
@@ -118,7 +114,6 @@ class PinLockViewModel extends ChangeNotifier {
} }
} }
/// Replaces the current PIN. Requires the current PIN to match first.
Future<bool> changePin({ Future<bool> changePin({
required String currentPin, required String currentPin,
required String newPin, required String newPin,
@@ -134,7 +129,6 @@ class PinLockViewModel extends ChangeNotifier {
return setPin(newPin); return setPin(newPin);
} }
/// Removes the PIN entirely. Requires the current PIN to confirm.
Future<bool> disablePin(String currentPin) async { Future<bool> disablePin(String currentPin) async {
final matches = await pinLockService.verifyPin(currentPin); final matches = await pinLockService.verifyPin(currentPin);
@@ -158,9 +152,6 @@ class PinLockViewModel extends ChangeNotifier {
return true; return true;
} }
/// Re-locks the app. Call this on app backgrounding (e.g. from a
/// WidgetsBindingObserver on AppLifecycleState.paused) if you want the
/// PIN required again after the app is put away, not just on cold start.
void lock() { void lock() {
if (!_isUnlocked) return; if (!_isUnlocked) return;
-2
View File
@@ -103,8 +103,6 @@ class SettingsViewModel extends ChangeNotifier {
} }
} }
/// Just flips the preference flag. Caller is responsible for having
/// already set/verified the actual PIN via PinLockViewModel first.
Future<void> updatePinRequired(bool value) => Future<void> updatePinRequired(bool value) =>
_save(_settings.copyWith(pinRequired: value)); _save(_settings.copyWith(pinRequired: value));