Small improvements

This commit is contained in:
PartyDonut 2025-07-27 11:47:31 +02:00
parent 86ff355e21
commit b17a74bb23
10 changed files with 81 additions and 20 deletions

2
.vscode/launch.json vendored
View file

@ -81,7 +81,6 @@
"args": [
"--web-port",
"9090",
"--web-experimental-hot-reload"
],
},
{
@ -93,7 +92,6 @@
"args": [
"--web-port",
"9090",
"--web-experimental-hot-reload"
],
},
],

View file

@ -1284,5 +1284,10 @@
"type": "int"
}
}
}
},
"syncPauseAll": "Pause all",
"syncResumeAll": "Resume all",
"syncStopAll": "Stop all",
"syncDeleteAll": "Delete all files",
"syncAllFiles": "Sync all files"
}

View file

@ -9,7 +9,6 @@ import 'package:flutter/services.dart';
import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:path/path.dart' as path;
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:smtc_windows/smtc_windows.dart' if (dart.library.html) 'package:fladder/stubs/web/smtc_web.dart';
@ -69,13 +68,10 @@ void main(List<String> args) async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
Directory isarPath = Directory("");
Directory applicationDirectory = Directory("");
if (!kIsWeb) {
applicationDirectory = await getApplicationDocumentsDirectory();
isarPath = Directory(path.joinAll([applicationDirectory.path, 'Fladder', 'Database']));
await isarPath.create(recursive: true);
}
if (_isDesktop) {
@ -96,10 +92,7 @@ void main(List<String> args) async {
applicationInfoProvider.overrideWith((ref) => applicationInfo),
crashLogProvider.overrideWith((ref) => crashProvider),
argumentsStateProvider.overrideWith((ref) => ArgumentsModel.fromArguments(args)),
syncProvider.overrideWith((ref) => SyncNotifier(
ref,
applicationDirectory,
))
syncProvider.overrideWith((ref) => SyncNotifier(ref, applicationDirectory))
],
child: AdaptiveLayoutBuilder(
child: (context) => const Main(),

View file

@ -35,7 +35,7 @@ class DatabaseItems extends Table {
TextColumn get userData => text().nullable()();
@override
Set<Column<Object>> get primaryKey => {id};
Set<Column<Object>> get primaryKey => {id, userId};
}
@DriftDatabase(tables: [DatabaseItems])

View file

@ -194,7 +194,7 @@ class $DatabaseItemsTable extends DatabaseItems
}
@override
Set<GeneratedColumn> get $primaryKey => {id};
Set<GeneratedColumn> get $primaryKey => {id, userId};
@override
DatabaseItem map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';

View file

@ -669,6 +669,7 @@ extension SyncNotifierHelpers on SyncNotifier {
for (var i = 0; i < itemsToDownload.length; i++) {
final item = itemsToDownload[i];
//No need to await file sync happens in the background
syncFile(item, false);
}

View file

@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:auto_route/auto_route.dart';
@ -91,7 +92,7 @@ class HomeScreen extends ConsumerWidget {
action: () => e.navigate(context),
);
case HomeTabs.sync:
if (canDownload) {
if (canDownload && !kIsWeb) {
return DestinationModel(
label: context.localized.navigationSync,
icon: Icon(e.icon),

View file

@ -154,7 +154,7 @@ class SeasonPoster extends ConsumerWidget {
items: season.generateActions(context, ref).popupMenuItems(useIcons: true));
},
onTap: () => onSeasonPressed?.call(season),
onLongPress: AdaptiveLayout.of(context).inputDevice != InputDevice.touch
onLongPress: AdaptiveLayout.of(context).inputDevice == InputDevice.touch
? () {
showBottomSheetPill(
context: context,

View file

@ -7,6 +7,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:iconsax_plus/iconsax_plus.dart';
import 'package:fladder/models/syncing/sync_item.dart';
import 'package:fladder/providers/sync/background_download_provider.dart';
import 'package:fladder/providers/sync/sync_provider_helpers.dart';
import 'package:fladder/providers/sync_provider.dart';
import 'package:fladder/util/localization_helper.dart';
@ -33,7 +34,23 @@ class SyncOptionsButton extends ConsumerWidget {
final syncedChildren =
children.where((element) => element.hasVideoFile && element.videoFile.existsSync()).toList();
return [
final syncTasks = children
.map((element) {
final task = ref.read(syncDownloadStatusProvider(element, []));
if (task?.status != TaskStatus.notFound) {
return task;
} else {
return null;
}
})
.nonNulls
.toList();
final runningTasks = syncTasks.where((element) => element.status == TaskStatus.running).toList();
final enqueuedTasks = syncTasks.where((element) => element.status == TaskStatus.enqueued).toList();
final pausedTasks = syncTasks.where((element) => element.status == TaskStatus.paused).toList();
return <PopupMenuEntry>[
PopupMenuItem(
child: Row(
spacing: 12,
@ -45,13 +62,14 @@ class SyncOptionsButton extends ConsumerWidget {
onTap: () => context.refreshData(),
),
if (children.isNotEmpty) ...[
const PopupMenuDivider(),
PopupMenuItem(
enabled: unSyncedChildren.isNotEmpty,
child: Row(
spacing: 12,
children: [
const Icon(IconsaxPlusLinear.cloud_add),
Text(context.localized.sync),
Text(context.localized.syncAllFiles),
],
),
onTap: () async => _syncRemainingItems(context, syncedItem, unSyncedChildren, ref),
@ -62,11 +80,54 @@ class SyncOptionsButton extends ConsumerWidget {
spacing: 12,
children: [
const Icon(IconsaxPlusLinear.trash),
Text(context.localized.delete),
Text(context.localized.syncDeleteAll),
],
),
onTap: () async => _deleteSyncedItems(context, syncedItem, syncedChildren, ref),
)
),
const PopupMenuDivider(),
PopupMenuItem(
enabled: pausedTasks.isNotEmpty,
child: Row(
spacing: 12,
children: [
const Icon(IconsaxPlusLinear.play),
Text(context.localized.syncResumeAll),
],
),
onTap: () => ref
.read(backgroundDownloaderProvider)
.resumeAll(tasks: pausedTasks.map((e) => e.task).nonNulls.toList()),
),
PopupMenuItem(
enabled: runningTasks.isNotEmpty,
child: Row(
spacing: 12,
children: [
const Icon(IconsaxPlusLinear.pause),
Text(context.localized.syncPauseAll),
],
),
onTap: () {
ref
.read(backgroundDownloaderProvider)
.pauseAll(tasks: runningTasks.map((e) => e.task).nonNulls.toList());
},
),
PopupMenuItem(
enabled: [...runningTasks, ...pausedTasks, ...enqueuedTasks].isNotEmpty,
child: Row(
spacing: 12,
children: [
const Icon(IconsaxPlusLinear.stop),
Text(context.localized.syncStopAll),
],
),
onTap: () {
ref.read(backgroundDownloaderProvider).cancelAll(
tasks: [...runningTasks, ...pausedTasks, ...enqueuedTasks].map((e) => e.task).nonNulls.toList());
},
),
]
];
},

View file

@ -35,6 +35,8 @@ extension RefreshContextExtension on BuildContext {
Future<void> refreshData() async {
//Small delay to fix server not updating response based on successful query
await Future.delayed(const Duration(milliseconds: 250));
await RefreshState.maybeOf(this)?.refresh();
if (mounted) {
await RefreshState.maybeOf(this)?.refresh();
}
}
}