fix: alot

This commit is contained in:
2026-10-19 21:41:34 +02:00
parent 30dd74af90
commit b0074aeb3f
40 changed files with 1979 additions and 405 deletions
+19 -7
View File
@@ -19,22 +19,34 @@ abstract class ExportService {
/// failed backup is logged but never interrupts the bar.
class DefaultExportService implements ExportService {
final BarTabService barTabService;
final Future<String?> Function()? authToken;
final http.Client _client;
DefaultExportService({required this.barTabService, http.Client? client})
: _client = client ?? http.Client();
DefaultExportService({
required this.barTabService,
this.authToken,
http.Client? client,
}) : _client = client ?? http.Client();
static const _timeout = Duration(seconds: 30);
@override
Future<void> uploadToServer() async {
try {
final closedTabs = await barTabService.getClosedTabs();
final appVersion = (await PackageInfo.fromPlatform()).version;
final token = await authToken?.call();
final response = await _client.post(
Uri.parse(kExportServerUrl),
headers: {'Content-Type': 'application/json'},
body: jsonEncode(_buildPayload(closedTabs, appVersion: appVersion)),
);
final response = await _client
.post(
Uri.parse(kExportServerUrl),
headers: {
'Content-Type': 'application/json',
if (token != null) 'Authorization': 'Bearer $token',
},
body: jsonEncode(_buildPayload(closedTabs, appVersion: appVersion)),
)
.timeout(_timeout);
if (response.statusCode != 200 && response.statusCode != 201) {
unawaited(