Skip to content

Commit 9f6ed13

Browse files
author
Piotr
committed
demo mode detection improved
1 parent 37f14ce commit 9f6ed13

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/store.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { FacetValues, Message, Row, TraceRow } from "./types";
55
import { Layout } from "./config";
66
import { useFilterStore } from "./stores/filter";
77
import { client } from "./api";
8-
import { formatThousands } from "./utils";
8+
import { formatThousands, getUrlParam } from "./utils";
99

1010
export interface Notification {
1111
id?: string;
@@ -36,7 +36,7 @@ export const useMainStore = defineStore("main", () => {
3636

3737
const demoMode = ref<boolean>(
3838
document.location.host.indexOf('demo.logdy.dev') >= 0 ||
39-
document.location.search.indexOf('demo') >= 0
39+
!!getUrlParam(document.location.search, 'demo_mode')
4040
)
4141
const demoStatus = ref<"started" | "stopped">("started")
4242
const demoContent = ref<"json" | "string">("json")

src/utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
export function formatThousands(x: number): string {
22
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
3+
}
4+
5+
export function getUrlParam(url: string, param: string): string | null {
6+
let params = new URLSearchParams(url)
7+
console.log(params, url)
8+
return params.get(param)
39
}

0 commit comments

Comments
 (0)