mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-09 22:43:33 -07:00
bitview: small fixes
This commit is contained in:
@@ -208,7 +208,7 @@ function createChartElement({
|
||||
|
||||
const activeResources = /** @type {Set<VecResource>} */ (new Set());
|
||||
ichart.subscribeCrosshairMove(
|
||||
utils.debounce(() => {
|
||||
utils.throttle(() => {
|
||||
activeResources.forEach((v) => {
|
||||
v.fetch();
|
||||
});
|
||||
|
||||
@@ -127,11 +127,10 @@ export function init({
|
||||
}
|
||||
|
||||
chart.inner.timeScale().subscribeVisibleLogicalRangeChange(
|
||||
utils.debounce((t) => {
|
||||
if (t) {
|
||||
from.set(t.from);
|
||||
to.set(t.to);
|
||||
}
|
||||
utils.throttle((t) => {
|
||||
if (!t) return;
|
||||
from.set(t.from);
|
||||
to.set(t.to);
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -1351,20 +1351,20 @@ function createUtils() {
|
||||
* @param {F} callback
|
||||
* @param {number} [wait=250]
|
||||
*/
|
||||
function debounce(callback, wait = 250) {
|
||||
/** @type {number | undefined} */
|
||||
let timeoutId;
|
||||
function throttle(callback, wait = 250) {
|
||||
/** @type {number | null} */
|
||||
let timeoutId = null;
|
||||
/** @type {Parameters<F>} */
|
||||
let latestArgs;
|
||||
|
||||
return (/** @type {Parameters<F>} */ ...args) => {
|
||||
return async (/** @type {Parameters<F>} */ ...args) => {
|
||||
latestArgs = args;
|
||||
|
||||
if (!timeoutId) {
|
||||
timeoutId = window.setTimeout(async () => {
|
||||
await callback(...latestArgs);
|
||||
|
||||
timeoutId = undefined;
|
||||
await callback(...latestArgs); // Execute immediately
|
||||
timeoutId = setTimeout(async () => {
|
||||
await callback(...latestArgs); // Execute with latest args
|
||||
timeoutId = null;
|
||||
}, wait);
|
||||
}
|
||||
};
|
||||
@@ -1569,7 +1569,7 @@ function createUtils() {
|
||||
serde,
|
||||
formatters,
|
||||
date,
|
||||
debounce,
|
||||
throttle,
|
||||
runWhenIdle,
|
||||
getNumberOfDaysBetweenTwoDates,
|
||||
stringToId,
|
||||
@@ -2246,7 +2246,7 @@ function main() {
|
||||
let firstTimeLoadingExplorer = true;
|
||||
|
||||
signals.createEffect(options.selected, (option) => {
|
||||
console.log(utils.url.pathnameToSelectedId(), option.id);
|
||||
// console.log(utils.url.pathnameToSelectedId(), option);
|
||||
if (previousElement) {
|
||||
previousElement.hidden = true;
|
||||
utils.url.resetParams(option);
|
||||
|
||||
@@ -3016,7 +3016,7 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) {
|
||||
}),
|
||||
createBaseSeries({
|
||||
key: "days_since_ath",
|
||||
name: "Days since",
|
||||
name: "since",
|
||||
}),
|
||||
createBaseSeries({
|
||||
key: "max_days_between_aths",
|
||||
@@ -3459,6 +3459,9 @@ function createPartialOptions({ env, colors, vecIdToIndexes }) {
|
||||
key: "difficulty_as_hash",
|
||||
name: "difficulty",
|
||||
color: colors.default,
|
||||
options: {
|
||||
lineStyle: 1,
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user