Skip to content

Commit

Permalink
fix: initialize url params object
Browse files Browse the repository at this point in the history
  • Loading branch information
jacovinus committed Jan 17, 2024
1 parent ea5ba6e commit 47bc78c
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions packages/main/services/localUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,40 @@ const localUrl = () => {
};

const add = (hash: string, item: any, maxLength = Infinity) => {
// we should pass the paeams here istead of parsing inside
let previousData = get() || [];
const { href, url, type, queryInput, queryType, limit, panel } =
item.data;

const origin = window.location.origin;
const urlParams = new URLSearchParams(hash.replace(/#/, ""));

let paramsData = {} as UrlParamsData;
let paramsData: UrlParamsData = {
autoTheme: "",
isEmbed: "",
isSplit: "",
isSubmit: "",
left: "",
right: "",
step: "",
start: "",
stop: "",
theme: "",
time: "",
};
urlParams.set("isSubmit", "true");

for (let [key, value] of urlParams) {
paramsData[key] = value;
if (paramsData.hasOwnProperty(key)) {
paramsData[key] = value;
}
}

const fromDate = format(
parseInt(paramsData?.start) / 1000000,
"yyyy-MM-dd HH:mm:ss"
);
const toDate = format(
parseInt(paramsData.stop) / 1000000,
parseInt(paramsData?.stop) / 1000000,
"yyyy-MM-dd HH:mm:ss"
);

Expand Down

0 comments on commit 47bc78c

Please sign in to comment.