Skip to content

Commit

Permalink
demo mode detection improved
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr committed Nov 26, 2024
1 parent 37f14ce commit 9f6ed13
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FacetValues, Message, Row, TraceRow } from "./types";
import { Layout } from "./config";
import { useFilterStore } from "./stores/filter";
import { client } from "./api";
import { formatThousands } from "./utils";
import { formatThousands, getUrlParam } from "./utils";

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

const demoMode = ref<boolean>(
document.location.host.indexOf('demo.logdy.dev') >= 0 ||
document.location.search.indexOf('demo') >= 0
!!getUrlParam(document.location.search, 'demo_mode')
)
const demoStatus = ref<"started" | "stopped">("started")
const demoContent = ref<"json" | "string">("json")
Expand Down
6 changes: 6 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
export function formatThousands(x: number): string {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}

export function getUrlParam(url: string, param: string): string | null {
let params = new URLSearchParams(url)
console.log(params, url)
return params.get(param)
}

0 comments on commit 9f6ed13

Please sign in to comment.