mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-16 04:13:12 +00:00
feat: pass search params to shortcuts
This commit is contained in:
parent
5539c2802b
commit
4336e89ba2
@ -1,7 +1,7 @@
|
|||||||
import { Button } from "@mui/joy";
|
import { Button } from "@mui/joy";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import { useParams } from "react-router-dom";
|
import { useLocation, useParams, useSearchParams } from "react-router-dom";
|
||||||
import CreateShortcutDrawer from "@/components/CreateShortcutDrawer";
|
import CreateShortcutDrawer from "@/components/CreateShortcutDrawer";
|
||||||
import { isURL } from "@/helpers/utils";
|
import { isURL } from "@/helpers/utils";
|
||||||
import useNavigateTo from "@/hooks/useNavigateTo";
|
import useNavigateTo from "@/hooks/useNavigateTo";
|
||||||
@ -10,6 +10,7 @@ import { Shortcut } from "@/types/proto/api/v1/shortcut_service";
|
|||||||
|
|
||||||
const ShortcutSpace = () => {
|
const ShortcutSpace = () => {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
|
const [searchParams] = useSearchParams();
|
||||||
const shortcutName = params["*"] || "";
|
const shortcutName = params["*"] || "";
|
||||||
const navigateTo = useNavigateTo();
|
const navigateTo = useNavigateTo();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
@ -69,7 +70,11 @@ const ShortcutSpace = () => {
|
|||||||
// If shortcut is a URL, redirect to it directly.
|
// If shortcut is a URL, redirect to it directly.
|
||||||
if (isURL(shortcut.link)) {
|
if (isURL(shortcut.link)) {
|
||||||
window.document.title = "Redirecting...";
|
window.document.title = "Redirecting...";
|
||||||
window.location.href = shortcut.link;
|
const url = new URL(shortcut.link);
|
||||||
|
searchParams.forEach((value, key) => {
|
||||||
|
url.searchParams.append(key, value);
|
||||||
|
});
|
||||||
|
window.location.href = url.toString();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user