parser: setup clap

This commit is contained in:
k
2024-07-15 18:52:29 +02:00
parent 91f2427b44
commit ad51edbe07
22 changed files with 363 additions and 211 deletions

View File

@@ -18,14 +18,14 @@ export function createResourceDataset<
const baseURL = `${
location.hostname === "localhost"
? "http://localhost:3111"
? "http://localhost:3110"
: "https://api.satonomics.xyz"
// "https://api.satonomics.xyz"
}${path}`;
const backupURL = `${
location.hostname === "localhost"
? "http://localhost:3111"
? "http://localhost:3110"
: "https://api-bkp.satonomics.xyz"
}${path}`;

View File

@@ -8,6 +8,27 @@ const LOCAL_STORAGE_RANGE_KEY = "chart-range";
const URL_PARAMS_RANGE_FROM_KEY = "from";
const URL_PARAMS_RANGE_TO_KEY = "to";
export function setInitialTimeRange({
chart,
range,
}: {
chart: IChartApi;
range: TimeRange;
}) {
if (range) {
chart.timeScale().setVisibleRange(range);
// On small screen it doesn't it might not set it in time
const timeout = setTimeout(() => {
chart.timeScale().setVisibleRange(range);
}, 50);
onCleanup(() => {
clearTimeout(timeout);
});
}
}
export function getInitialTimeRange(scale: ResourceScale): TimeRange {
const urlParams = new URLSearchParams(window.location.search);
@@ -145,4 +166,4 @@ function saveTimeRange({
localStorage.setItem(getLocalStorageKey(scale), JSON.stringify(range));
}
const debouncedSaveTimeRange = debounce(saveTimeRange, 500);
const debouncedSaveTimeRange = debounce(saveTimeRange, 250);

View File

@@ -16,6 +16,7 @@ import {
getInitialTimeRange,
initTimeScale,
setActiveIds,
setInitialTimeRange,
} from "../lightweightCharts/time";
import { setWhitespace } from "../lightweightCharts/whitespace";
import { colors } from "../utils/colors";
@@ -121,9 +122,7 @@ export function applySeriesList({
const range = exactRange();
if (range) {
chart.timeScale().setVisibleRange(range);
}
setInitialTimeRange({ chart, range });
if (chartIndex === 0) {
initTimeScale({