mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-02 19:02:28 +00:00
Fix: Preserve ?v= parameter when auto-redirecting to For You feed
When a user visits a direct video link (e.g. `/?v=...`) while logged in, the application auto-authenticates and redirects the view to `#view=for-you`. Previously, `setHashView` unconditionally removed all query parameters, causing the video modal to fail to open because the `v` parameter was lost before it could be read. This change: 1. Updates `setHashView` to accept an options object, allowing specific parameters to be preserved. 2. Updates `handleAuthLogin` in `app.js` to detect if a `v` parameter is present and request its preservation during the view switch.
This commit is contained in:
1 parent
adf41ff9cb
commit
dbb6c0d2be
2 files changed
+8
-3
No files matched your search
+4
-2
@@ -14,14 +14,16 @@ export function getHashViewName() {
|
||||
return viewName.trim();
|
||||
}
|
||||
|
||||
export function setHashView(viewName) {
|
||||
export function setHashView(viewName, options = {}) {
|
||||
if (typeof window === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.delete("modal");
|
||||
url.searchParams.delete("v");
|
||||
if (!options?.preserveVideoParam) {
|
||||
url.searchParams.delete("v");
|
||||
}
|
||||
const newUrl = url.pathname + url.search + `#view=${viewName}`;
|
||||
window.history.replaceState({}, "", newUrl);
|
||||
|
||||
|
||||
Reference in new issue
Block a user