mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-10 18:48:13 -07:00
general: snapshot
This commit is contained in:
@@ -11,7 +11,7 @@ export function FavoritesFrame({
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
class="flex-1 overflow-y-auto"
|
||||
class="flex-1 overflow-y-auto overflow-x-hidden"
|
||||
style={{
|
||||
display: selectedFrame() !== "Favorites" ? "none" : undefined,
|
||||
}}
|
||||
|
||||
@@ -29,7 +29,7 @@ export function FoldersFrame({
|
||||
display: selectedFrame() !== "Folders" ? "none" : undefined,
|
||||
}}
|
||||
>
|
||||
<div class="flex-1 overflow-y-auto">
|
||||
<div class="flex-1 overflow-y-auto overflow-x-hidden">
|
||||
<div class="flex max-h-full min-h-0 flex-1 flex-col gap-4 p-4">
|
||||
<Header title="Folders">
|
||||
<Number number={() => presets.list.length} /> charts organized in a
|
||||
|
||||
@@ -12,7 +12,7 @@ export function HistoryFrame({
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
class="flex-1 overflow-y-auto"
|
||||
class="flex-1 overflow-y-auto overflow-x-hidden"
|
||||
style={{
|
||||
display: selectedFrame() !== "History" ? "none" : undefined,
|
||||
}}
|
||||
|
||||
@@ -21,7 +21,7 @@ export function SettingsFrame({
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
class="flex-1 overflow-y-auto"
|
||||
class="flex-1 overflow-y-auto overflow-x-hidden"
|
||||
style={{
|
||||
display: selectedFrame() !== "Settings" ? "none" : undefined,
|
||||
}}
|
||||
@@ -119,7 +119,7 @@ export function SettingsFrame({
|
||||
{
|
||||
name: "btcschellingpt",
|
||||
url: "https://primal.net/p/npub1nvfgglea9zlcs58tcqlc6j26rt50ngkgdk7699wfq4txrx37aqcsz4e7zd",
|
||||
amount: 1_000,
|
||||
amount: 1_000 + 1_000,
|
||||
},
|
||||
{
|
||||
name: "Coinatra",
|
||||
@@ -136,6 +136,21 @@ export function SettingsFrame({
|
||||
url: "https://primal.net/p/npub1hqthdsed0wpg57sqsc5mtyqxxgrh3s7493ja5h49v23v2nhhds4qk4w0kz",
|
||||
amount: 17_509,
|
||||
},
|
||||
{
|
||||
name: "DerGigi",
|
||||
url: "https://primal.net/p/npub1dergggklka99wwrs92yz8wdjs952h2ux2ha2ed598ngwu9w7a6fsh9xzpc",
|
||||
amount: 6001,
|
||||
},
|
||||
{
|
||||
name: "Adarnit",
|
||||
url: "https://primal.net/p/npub17armdveqy42uhuuuwjc5m2dgjkz7t7epgvwpuccqw8jusm8m0g4sn86n3s",
|
||||
amount: 17_726,
|
||||
},
|
||||
{
|
||||
name: "Auburn Citadel",
|
||||
url: "https://primal.net/p/npub1730y5k2s9u82w9snx3hl37r8gpsrmqetc2y3xyx9h65yfpf28rtq0y635y",
|
||||
amount: 17_471,
|
||||
},
|
||||
]
|
||||
.sort((a, b) =>
|
||||
b.amount !== a.amount
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { requestIdleCallbackPossible } from "/src/env";
|
||||
import { ONE_HOUR_IN_MS, ONE_MINUTE_IN_MS } from "/src/scripts/utils/time";
|
||||
import { createRWS } from "/src/solid/rws";
|
||||
|
||||
@@ -22,6 +23,13 @@ export function createResourceDataset<
|
||||
"https://api.satonomics.xyz"
|
||||
}${path}`;
|
||||
|
||||
const backupURL = `${
|
||||
// location.hostname === "localhost"
|
||||
// ? "http://localhost:3110"
|
||||
// : "https://api.satonomics.xyz"
|
||||
"https://api-bkp.satonomics.xyz"
|
||||
}${path}`;
|
||||
|
||||
const fetchedJSONs = new Array(
|
||||
(new Date().getFullYear() - new Date("2009-01-01").getFullYear() + 2) *
|
||||
(scale === "date" ? 1 : 6),
|
||||
@@ -114,6 +122,7 @@ export function createResourceDataset<
|
||||
let cache: Cache | undefined;
|
||||
|
||||
const urlWithQuery = `${baseURL}?chunk=${id}`;
|
||||
const backupUrlWithQuery = `${backupURL}?chunk=${id}`;
|
||||
|
||||
if (!fetched.json()) {
|
||||
try {
|
||||
@@ -138,68 +147,87 @@ export function createResourceDataset<
|
||||
return;
|
||||
}
|
||||
|
||||
let fetchedResponse: Response | undefined;
|
||||
|
||||
try {
|
||||
const fetchedResponse = await fetch(urlWithQuery);
|
||||
fetchedResponse = await fetch(urlWithQuery);
|
||||
|
||||
if (!fetchedResponse.ok) {
|
||||
throw Error;
|
||||
}
|
||||
} catch {
|
||||
try {
|
||||
fetchedResponse = await fetch(backupUrlWithQuery);
|
||||
} catch {
|
||||
fetched.loading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const clonedResponse = fetchedResponse.clone();
|
||||
if (!fetchedResponse || !fetchedResponse.ok) {
|
||||
fetched.loading = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const json = await convertResponseToJSON<Scale, Type>(fetchedResponse);
|
||||
const clonedResponse = fetchedResponse.clone();
|
||||
|
||||
if (json) {
|
||||
console.log(`fetch: ${path}?chunk=${id}`);
|
||||
const json = await convertResponseToJSON<Scale, Type>(fetchedResponse);
|
||||
|
||||
const previousMap = fetched.json()?.dataset.map;
|
||||
const newMap = json.dataset.map;
|
||||
if (!json) {
|
||||
fetched.loading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const previousLength = Object.keys(previousMap || []).length;
|
||||
const newLength = Object.keys(newMap).length;
|
||||
console.log(`fetch: ${path}?chunk=${id}`);
|
||||
|
||||
if (!newLength) {
|
||||
const previousMap = fetched.json()?.dataset.map;
|
||||
const newMap = json.dataset.map;
|
||||
|
||||
const previousLength = Object.keys(previousMap || []).length;
|
||||
const newLength = Object.keys(newMap).length;
|
||||
|
||||
if (!newLength) {
|
||||
fetched.loading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (previousLength && previousLength === newLength) {
|
||||
const previousLastValue = Object.values(previousMap || []).at(-1);
|
||||
const newLastValue = Object.values(newMap).at(-1);
|
||||
|
||||
if (typeof newLastValue === "number") {
|
||||
if (previousLastValue === newLastValue) {
|
||||
fetched.at = new Date();
|
||||
fetched.loading = false;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
const previousLastOHLC = previousLastValue as OHLC;
|
||||
const newLastOHLC = newLastValue as OHLC;
|
||||
|
||||
if (previousLength && previousLength === newLength) {
|
||||
const previousLastValue = Object.values(previousMap || []).at(-1);
|
||||
const newLastValue = Object.values(newMap).at(-1);
|
||||
|
||||
if (typeof newLastValue === "number") {
|
||||
if (previousLastValue === newLastValue) {
|
||||
fetched.at = new Date();
|
||||
fetched.loading = false;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
const previousLastOHLC = previousLastValue as OHLC;
|
||||
const newLastOHLC = newLastValue as OHLC;
|
||||
|
||||
if (
|
||||
previousLastOHLC.open === newLastOHLC.open &&
|
||||
previousLastOHLC.high === newLastOHLC.high &&
|
||||
previousLastOHLC.low === newLastOHLC.low &&
|
||||
previousLastOHLC.close === newLastOHLC.close
|
||||
) {
|
||||
fetched.loading = false;
|
||||
fetched.at = new Date();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fetched.json.set(() => json);
|
||||
|
||||
if (cache) {
|
||||
cache.put(urlWithQuery, clonedResponse);
|
||||
if (
|
||||
previousLastOHLC.open === newLastOHLC.open &&
|
||||
previousLastOHLC.high === newLastOHLC.high &&
|
||||
previousLastOHLC.low === newLastOHLC.low &&
|
||||
previousLastOHLC.close === newLastOHLC.close
|
||||
) {
|
||||
fetched.loading = false;
|
||||
fetched.at = new Date();
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
fetched.loading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
fetched.json.set(() => json);
|
||||
|
||||
function saveToCache() {
|
||||
cache?.put(urlWithQuery, clonedResponse);
|
||||
}
|
||||
|
||||
if (requestIdleCallbackPossible) {
|
||||
requestIdleCallback(saveToCache);
|
||||
} else {
|
||||
setTimeout(saveToCache, 1);
|
||||
}
|
||||
|
||||
fetched.at = new Date();
|
||||
|
||||
@@ -33,6 +33,13 @@ export const createBaseLineSeries = ({
|
||||
|
||||
const bottomLineColor = bottomColor || color || DEFAULT_BASELINE_BOTTOM_COLOR;
|
||||
|
||||
function computeColors() {
|
||||
return {
|
||||
topLineColor: topLineColor(dark),
|
||||
bottomLineColor: bottomLineColor(dark),
|
||||
} as const;
|
||||
}
|
||||
|
||||
const seriesOptions: DeepPartialBaselineOptions = {
|
||||
priceScaleId: "right",
|
||||
...defaultSeriesOptions,
|
||||
@@ -45,15 +52,13 @@ export const createBaseLineSeries = ({
|
||||
topFillColor2: transparent,
|
||||
bottomFillColor1: transparent,
|
||||
bottomFillColor2: transparent,
|
||||
...computeColors(),
|
||||
};
|
||||
|
||||
const series = chart.addBaselineSeries(seriesOptions);
|
||||
|
||||
createEffect(() => {
|
||||
series.applyOptions({
|
||||
topLineColor: topLineColor(dark),
|
||||
bottomLineColor: bottomLineColor(dark),
|
||||
});
|
||||
series.applyOptions(computeColors());
|
||||
});
|
||||
|
||||
return series;
|
||||
|
||||
@@ -11,6 +11,22 @@ export const createCandlesticksSeries = ({
|
||||
}): [ISeriesApi<"Candlestick">, Color[]] => {
|
||||
const { inverseColors } = options;
|
||||
|
||||
const _upColor = inverseColors ? colors.loss : colors.profit;
|
||||
|
||||
const _downColor = inverseColors ? colors.profit : colors.loss;
|
||||
|
||||
function computeColors() {
|
||||
const upColor = _upColor(dark);
|
||||
|
||||
const downColor = _downColor(dark);
|
||||
|
||||
return {
|
||||
upColor,
|
||||
wickUpColor: upColor,
|
||||
downColor,
|
||||
wickDownColor: downColor,
|
||||
} as const;
|
||||
}
|
||||
const candlestickSeries = chart.addCandlestickSeries({
|
||||
baseLineVisible: false,
|
||||
borderVisible: false,
|
||||
@@ -20,23 +36,11 @@ export const createCandlesticksSeries = ({
|
||||
borderDownColor: "",
|
||||
borderUpColor: "",
|
||||
...options.seriesOptions,
|
||||
...computeColors(),
|
||||
});
|
||||
|
||||
const _upColor = inverseColors ? colors.loss : colors.profit;
|
||||
|
||||
const _downColor = inverseColors ? colors.profit : colors.loss;
|
||||
|
||||
createEffect(() => {
|
||||
const upColor = _upColor(dark);
|
||||
|
||||
const downColor = _downColor(dark);
|
||||
|
||||
candlestickSeries.applyOptions({
|
||||
upColor,
|
||||
wickUpColor: upColor,
|
||||
downColor,
|
||||
wickDownColor: downColor,
|
||||
});
|
||||
candlestickSeries.applyOptions(computeColors());
|
||||
});
|
||||
|
||||
return [candlestickSeries, [_upColor, _downColor]];
|
||||
|
||||
@@ -11,15 +11,20 @@ export const createLineSeries = ({
|
||||
color: Color;
|
||||
options?: DeepPartialLineOptions;
|
||||
}) => {
|
||||
function computeColors() {
|
||||
return {
|
||||
color: color(dark),
|
||||
} as const;
|
||||
}
|
||||
|
||||
const series = chart.addLineSeries({
|
||||
...defaultSeriesOptions,
|
||||
...options,
|
||||
...computeColors(),
|
||||
});
|
||||
|
||||
createEffect(() => {
|
||||
series.applyOptions({
|
||||
color: color(dark),
|
||||
});
|
||||
series.applyOptions(computeColors());
|
||||
});
|
||||
|
||||
return series;
|
||||
|
||||
Reference in New Issue
Block a user