feat: add alot
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
const kUpdateServerUrl = 'https://updater.brammie15.dev';
|
||||
const kUpdateServerUrl = 'https://updater.kooltap.com';
|
||||
const kExportServerUrl = 'https://kooltab.brammie15.dev/api/backup';
|
||||
const kRemoteServerUrl = 'https://api.kooltap.com/api/v1';
|
||||
const kSyncPollingIntervalSeconds = 90;
|
||||
// Idle sync interval; also the longest a close request from the dashboard waits
|
||||
const kSyncPollingIntervalSeconds = 15;
|
||||
// After a tab changes, sync once things are quiet for this long...
|
||||
const kSyncChangeDebounceMs = 2000;
|
||||
// ...but never wait longer than this while changes keep coming
|
||||
const kSyncChangeMaxDelayMs = 10000;
|
||||
const kSyncMaxBackoffSeconds = 600;
|
||||
const kCommandExpiryHours = 24;
|
||||
const kCommandExpiryHours = 24;
|
||||
|
||||
@@ -24,12 +24,12 @@ class UpdateInfo {
|
||||
|
||||
factory UpdateInfo.fromJson(Map<String, dynamic> json) {
|
||||
return UpdateInfo(
|
||||
update: json["update"] ?? false,
|
||||
version: json["version"] ?? "",
|
||||
notes: json["notes"] ?? "",
|
||||
mandatory: json["mandatory"] ?? false,
|
||||
sha256: json["sha256"] ?? "",
|
||||
download: json["download"] ?? "",
|
||||
update: json['update'] ?? false,
|
||||
version: json['version'] ?? '',
|
||||
notes: json['notes'] ?? '',
|
||||
mandatory: json['mandatory'] ?? false,
|
||||
sha256: json['sha256'] ?? '',
|
||||
download: json['download'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -56,26 +56,26 @@ class AppUpdateUtil {
|
||||
|
||||
Future<String> currentVersion() async {
|
||||
final info = await PackageInfo.fromPlatform();
|
||||
debugPrint("Current app version: ${info.version}");
|
||||
debugPrint('Current app version: ${info.version}');
|
||||
return info.version;
|
||||
}
|
||||
|
||||
Future<UpdateInfo?> checkForUpdate() async {
|
||||
final version = await currentVersion();
|
||||
|
||||
final url = Uri.parse("$serverUrl/api/update?version=$version");
|
||||
final url = Uri.parse('$serverUrl/api/update?version=$version');
|
||||
|
||||
final response = await http.get(url);
|
||||
|
||||
debugPrint("Response from update server: ${response.body}");
|
||||
debugPrint('Response from update server: ${response.body}');
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception("Update server unavailable");
|
||||
throw Exception('Update server unavailable');
|
||||
}
|
||||
|
||||
final data = jsonDecode(response.body);
|
||||
|
||||
if (data["update"] != true) {
|
||||
if (data['update'] != true) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@ import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:kooltab2/utils/app_update_util.dart';
|
||||
|
||||
import 'app_config.dart';
|
||||
import '../l10n/app_localizations.dart';
|
||||
import 'app_config.dart';
|
||||
import 'app_update_util.dart';
|
||||
|
||||
class UpdateChecker {
|
||||
static bool _hasChecked = false;
|
||||
@@ -13,7 +13,7 @@ class UpdateChecker {
|
||||
static Future<void> check(BuildContext context) async {
|
||||
if (!Platform.isAndroid) return;
|
||||
if (_hasChecked) {
|
||||
debugPrint("Update already checked this boot");
|
||||
debugPrint('Update already checked this boot');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,17 +25,17 @@ class UpdateChecker {
|
||||
final update = await updater.checkForUpdate();
|
||||
|
||||
if (update == null) {
|
||||
debugPrint("No update available");
|
||||
debugPrint('No update available');
|
||||
return;
|
||||
}
|
||||
|
||||
debugPrint("Update available: ${update.version}");
|
||||
debugPrint('Update available: ${update.version}');
|
||||
|
||||
if (!context.mounted) return;
|
||||
|
||||
_showUpdateDialog(context, update);
|
||||
} catch (e) {
|
||||
debugPrint("Update check failed: $e");
|
||||
debugPrint('Update check failed: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
bool listEquals<T>(List<T>? a, List<T>? b) {
|
||||
if (identical(a, b)) return true;
|
||||
if (a == null || b == null) return a == b;
|
||||
if (a.length != b.length) return false;
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
if (a[i] != b[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
final _euro = NumberFormat.currency(locale: 'nl_BE', symbol: '€');
|
||||
|
||||
extension Cents on int {
|
||||
String get asEuro => _euro.format(this / 100);
|
||||
}
|
||||
Reference in New Issue
Block a user