Skip to content

Commit 64a4ff2

Browse files
committed
Restore saved library selections on connection select
1 parent a50c63a commit 64a4ff2

4 files changed

Lines changed: 15 additions & 10 deletions

File tree

‎plugins/ChannelFlow.Plugin.Jellyfin/JellyfinPlugin.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ private static HttpClient Client(string apiKey)
2424
};
2525
var c = new HttpClient(handler);
2626
c.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("MediaBrowser", $"Token=\"{apiKey}\"");
27-
c.Timeout = TimeSpan.FromSeconds(30);
27+
c.Timeout = TimeSpan.FromMinutes(10);
2828
return c;
2929
}
3030

0 Bytes
Binary file not shown.

‎plugins/com.channelflow.jellyfin/JellyfinPlugin.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ private static HttpClient Client(string apiKey)
2424
};
2525
var c = new HttpClient(handler);
2626
c.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("MediaBrowser", $"Token=\"{apiKey}\"");
27-
c.Timeout = TimeSpan.FromSeconds(30);
27+
c.Timeout = TimeSpan.FromMinutes(10);
2828
return c;
2929
}
3030

@@ -98,12 +98,12 @@ public async Task<SyncReport> SyncLibraryAsync(SyncContext ctx)
9898
var id = it.GetProperty("Id").GetString() ?? "";
9999
var name = it.GetProperty("Name").GetString() ?? id;
100100
var type = it.TryGetProperty("Type", out var t) ? t.GetString() : "Movie";
101-
var kind = type?.ToLowerInvariant() switch
101+
var kind = ctx.MediaType != "movie" ? ctx.MediaType : (type?.ToLowerInvariant() switch
102102
{
103103
"series" => "series",
104104
"episode" => "episode",
105105
_ => "movie"
106-
};
106+
});
107107
int? year = it.TryGetProperty("ProductionYear", out var y) && y.ValueKind == JsonValueKind.Number ? y.GetInt32() : null;
108108
long? runtime = null;
109109
if (it.TryGetProperty("RunTimeTicks", out var rt) && rt.ValueKind == JsonValueKind.Number)

‎src/ChannelFlow.Core/Components/Pages/Library.razor‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,20 @@ else if (activeTab.StartsWith("conn-"))
179179
try
180180
{
181181
var libs = await Http.GetFromJsonAsync<List<LibraryDto>>($"api/media/libraries/{c.Id}", new System.Text.Json.JsonSerializerOptions { PropertyNameCaseInsensitive = true });
182+
// Restore saved selections
183+
var savedLibs = new List<string>();
184+
try
185+
{
186+
using var doc = System.Text.Json.JsonDocument.Parse(c.ConfigJson);
187+
if (doc.RootElement.TryGetProperty("selectedLibraries", out var sl) && sl.ValueKind == System.Text.Json.JsonValueKind.Array)
188+
savedLibs = sl.EnumerateArray().Select(e => e.GetString() ?? "").ToList();
189+
}
190+
catch { }
182191
if (libs is not null)
183192
foreach (var l in libs)
184193
{
185-
l.Selected = false;
186-
// Default media type from collection type
187-
if (string.IsNullOrEmpty(l.MediaTypeStr))
188-
{
189-
l.MediaTypeStr = "movie";
190-
}
194+
l.Selected = savedLibs.Contains(l.Id);
195+
if (string.IsNullOrEmpty(l.MediaTypeStr)) l.MediaTypeStr = "movie";
191196
libraries.Add(l);
192197
}
193198
// Set sync URL from connection config

0 commit comments

Comments
 (0)