From 362f27bdd5725b9768e9fbcdc93a4c963fca2ada Mon Sep 17 00:00:00 2001 From: nixos script Date: Wed, 31 Jan 2024 15:47:06 +0800 Subject: [PATCH] speed up the video long tap add to playlist button when dearrow is enabled --- lib/service.dart | 8 +++++--- lib/videos/states/add_to_playlist.dart | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/service.dart b/lib/service.dart index 57ddab3b..933f90ae 100644 --- a/lib/service.dart +++ b/lib/service.dart @@ -565,7 +565,7 @@ class Service { return videosWithContinuation; } - Future> getUserPlaylists() async { + Future> getUserPlaylists({bool postProcessing = true}) async { var currentlySelectedServer = await db.getCurrentlySelectedServer(); try { @@ -575,8 +575,10 @@ class Service { final response = await http.get(url, headers: headers); Iterable i = handleResponse(response); var list = List.from(i.map((e) => Playlist.fromJson(e))); - for (var pl in list) { - pl.videos = (await postProcessVideos(pl.videos)).cast(); + if (postProcessing) { + for (var pl in list) { + pl.videos = (await postProcessVideos(pl.videos)).cast(); + } } return list.sortByReversed((e) => e.updated ?? 0).toList(); } catch (e) { diff --git a/lib/videos/states/add_to_playlist.dart b/lib/videos/states/add_to_playlist.dart index 5f3aa622..777b1166 100644 --- a/lib/videos/states/add_to_playlist.dart +++ b/lib/videos/states/add_to_playlist.dart @@ -43,7 +43,7 @@ class AddToPlaylistCubit extends Cubit { emit(state.copyWith(loading: true)); late List playlists; if (state.isLoggedIn) { - playlists = await service.getUserPlaylists(); + playlists = await service.getUserPlaylists(postProcessing: false); } else { playlists = List.empty(); }