fix(search): include Library source filter in shareable URL
The new library_source provenance filter wasn't serialised into the Share-view URL, so a copied link lost the 'search results only' (or 'include search') selection. Add it as the 'source' param (emitted only in 'all' scope, omitted for the default 'organic').
This commit is contained in:
parent
74cf31b58d
commit
a528e2c366
1 changed files with 8 additions and 0 deletions
|
|
@ -9,6 +9,7 @@ const KEYS = [
|
||||||
"show",
|
"show",
|
||||||
"sort",
|
"sort",
|
||||||
"scope",
|
"scope",
|
||||||
|
"source",
|
||||||
"normal",
|
"normal",
|
||||||
"shorts",
|
"shorts",
|
||||||
"live",
|
"live",
|
||||||
|
|
@ -28,6 +29,9 @@ export function filtersToParams(f: FeedFilters): URLSearchParams {
|
||||||
if (f.show && f.show !== "unwatched") p.set("show", f.show);
|
if (f.show && f.show !== "unwatched") p.set("show", f.show);
|
||||||
if (f.sort && f.sort !== "newest") p.set("sort", f.sort);
|
if (f.sort && f.sort !== "newest") p.set("sort", f.sort);
|
||||||
if (f.scope === "all") p.set("scope", "all");
|
if (f.scope === "all") p.set("scope", "all");
|
||||||
|
// Library provenance filter (only meaningful in "all" scope); "organic" is the default.
|
||||||
|
if (f.scope === "all" && f.librarySource && f.librarySource !== "organic")
|
||||||
|
p.set("source", f.librarySource);
|
||||||
if (!f.includeNormal) p.set("normal", "0");
|
if (!f.includeNormal) p.set("normal", "0");
|
||||||
if (f.includeShorts) p.set("shorts", "1");
|
if (f.includeShorts) p.set("shorts", "1");
|
||||||
if (f.includeLive) p.set("live", "1");
|
if (f.includeLive) p.set("live", "1");
|
||||||
|
|
@ -55,6 +59,10 @@ export function paramsToFilters(params: URLSearchParams, base: FeedFilters): Fee
|
||||||
if (params.has("show")) f.show = params.get("show") || "unwatched";
|
if (params.has("show")) f.show = params.get("show") || "unwatched";
|
||||||
if (params.has("sort")) f.sort = params.get("sort") || "newest";
|
if (params.has("sort")) f.sort = params.get("sort") || "newest";
|
||||||
if (params.has("scope")) f.scope = params.get("scope") === "all" ? "all" : "my";
|
if (params.has("scope")) f.scope = params.get("scope") === "all" ? "all" : "my";
|
||||||
|
if (params.has("source")) {
|
||||||
|
const s = params.get("source");
|
||||||
|
f.librarySource = s === "all" || s === "search" ? s : "organic";
|
||||||
|
}
|
||||||
if (params.has("normal")) f.includeNormal = params.get("normal") !== "0";
|
if (params.has("normal")) f.includeNormal = params.get("normal") !== "0";
|
||||||
if (params.has("shorts")) f.includeShorts = params.get("shorts") === "1";
|
if (params.has("shorts")) f.includeShorts = params.get("shorts") === "1";
|
||||||
if (params.has("live")) f.includeLive = params.get("live") === "1";
|
if (params.has("live")) f.includeLive = params.get("live") === "1";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue