From cfc7fea6f48069e8a234684eb7faf4fa4182447b Mon Sep 17 00:00:00 2001 From: Chaphasilor Date: Thu, 26 Sep 2024 21:47:03 +0200 Subject: [PATCH] automatically add playlist metadata download item during migration --- lib/services/downloads_service.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/services/downloads_service.dart b/lib/services/downloads_service.dart index a6b508f96..91de12164 100644 --- a/lib/services/downloads_service.dart +++ b/lib/services/downloads_service.dart @@ -5,6 +5,7 @@ import 'dart:io'; import 'package:background_downloader/background_downloader.dart'; import 'package:collection/collection.dart'; import 'package:finamp/components/global_snackbar.dart'; +import 'package:finamp/services/finamp_user_helper.dart'; import 'package:finamp/services/jellyfin_api_helper.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; @@ -1011,6 +1012,7 @@ class DownloadsService { /// always be re-run later by the user. Note that the existing hive metadata is /// not deleted by this migration, we just stop using it. Future migrateFromHive() async { + final finampUserHelper = GetIt.instance(); if (FinampSettingsHelper.finampSettings.downloadLocationsMap.values .where((element) => element.baseDirectory == DownloadLocationType.internalSupport) @@ -1036,6 +1038,13 @@ class DownloadsService { content: Text(AppLocalizations.of(scaffold)!.runRepairWarning), duration: const Duration(seconds: 20))); })); + + // Automatically download playlist metadata (to enhance the playlist actions dialog and offline mode) + unawaited(addDownload( + stub: DownloadStub.fromFinampCollection(FinampCollection(type: FinampCollectionType.allPlaylistsMetadata)), + viewId: finampUserHelper.currentUser!.currentViewId!, + transcodeProfile: DownloadProfile(transcodeCodec: FinampTranscodingCodec.original), + )); } /// Substep 1 of [migrateFromHive].