parent
ae943ce173
commit
0faf903ef0
@ -29,18 +29,17 @@ async function tryUseCacheRelay(url: string) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function tryUseLocalRelay() {
|
||||
let conn = await tryUseCacheRelay("ws://localhost:4869");
|
||||
if (!conn) {
|
||||
conn = await tryUseCacheRelay("ws://umbrel:4848");
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
|
||||
export async function initRelayWorker() {
|
||||
try {
|
||||
if (!cacheRelay) {
|
||||
let conn = await tryUseCacheRelay("ws://localhost:4869");
|
||||
if (!conn) {
|
||||
conn = await tryUseCacheRelay("ws://umbrel:4848");
|
||||
}
|
||||
if (conn) {
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
} else if (Relay instanceof ConnectionCacheRelay) {
|
||||
if (Relay instanceof ConnectionCacheRelay) {
|
||||
await Relay.connection.connect(true);
|
||||
return;
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { FeedCache } from "@snort/shared";
|
||||
import { ConnectionCacheRelay } from "@snort/system";
|
||||
import { WorkerRelayInterface } from "@snort/worker-relay";
|
||||
import { ReactNode, useEffect, useState, useSyncExternalStore } from "react";
|
||||
import { FormattedMessage, FormattedNumber } from "react-intl";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
import { GiftsCache, Relay, RelayMetrics } from "@/Cache";
|
||||
import { GiftsCache, Relay, RelayMetrics, tryUseLocalRelay } from "@/Cache";
|
||||
import AsyncButton from "@/Components/Button/AsyncButton";
|
||||
import useLogin from "@/Hooks/useLogin";
|
||||
|
||||
@ -65,11 +66,24 @@ function RelayCacheStats() {
|
||||
}
|
||||
}, []);
|
||||
|
||||
function relayType() {
|
||||
if (Relay instanceof WorkerRelayInterface) {
|
||||
return <FormattedMessage defaultMessage="Browser" />;
|
||||
} else if (Relay instanceof ConnectionCacheRelay) {
|
||||
return <FormattedMessage defaultMessage="Local" />;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex justify-between br p bg-superdark">
|
||||
<div className="flex flex-col g4 w-64">
|
||||
<FormattedMessage defaultMessage="Worker Relay" />
|
||||
{myEvents && (
|
||||
<FormattedMessage
|
||||
defaultMessage="{type} Worker Relay"
|
||||
values={{
|
||||
type: relayType(),
|
||||
}}
|
||||
/>
|
||||
{myEvents > 0 && (
|
||||
<p>
|
||||
<FormattedMessage
|
||||
defaultMessage="My events: {n}"
|
||||
@ -114,7 +128,7 @@ function RelayCacheStats() {
|
||||
</AsyncButton>
|
||||
<AsyncButton
|
||||
onClick={async () => {
|
||||
const data = await Relay.dump();
|
||||
const data = new Uint8Array();
|
||||
const url = URL.createObjectURL(
|
||||
new File([data], "snort.db", {
|
||||
type: "application/octet-stream",
|
||||
@ -130,6 +144,19 @@ function RelayCacheStats() {
|
||||
<AsyncButton onClick={() => navigate("/cache-debug")}>
|
||||
<FormattedMessage defaultMessage="Debug" />
|
||||
</AsyncButton>
|
||||
|
||||
{!(Relay instanceof ConnectionCacheRelay) && (
|
||||
<AsyncButton
|
||||
onClick={async () => {
|
||||
if (await tryUseLocalRelay()) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
alert("No local relay found");
|
||||
}
|
||||
}}>
|
||||
<FormattedMessage defaultMessage="Use Local Relay" />
|
||||
</AsyncButton>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
@ -548,6 +548,9 @@
|
||||
"Dx4ey3": {
|
||||
"defaultMessage": "Toggle all"
|
||||
},
|
||||
"E3oB+t": {
|
||||
"defaultMessage": "Browser"
|
||||
},
|
||||
"E5ZIPD": {
|
||||
"defaultMessage": "<big>{amount}</big> <small>sats</small>"
|
||||
},
|
||||
@ -1075,6 +1078,9 @@
|
||||
"TJo5E6": {
|
||||
"defaultMessage": "Preview"
|
||||
},
|
||||
"TOG64f": {
|
||||
"defaultMessage": "Use Local Relay"
|
||||
},
|
||||
"TP/cMX": {
|
||||
"defaultMessage": "Ended"
|
||||
},
|
||||
@ -1169,6 +1175,9 @@
|
||||
"W2PiAr": {
|
||||
"defaultMessage": "{n} Blocked"
|
||||
},
|
||||
"W4SaxY": {
|
||||
"defaultMessage": "Local"
|
||||
},
|
||||
"W9355R": {
|
||||
"defaultMessage": "Unmute"
|
||||
},
|
||||
@ -1701,6 +1710,9 @@
|
||||
"mErPop": {
|
||||
"defaultMessage": "It looks like you dont have any, check {link} to buy one!"
|
||||
},
|
||||
"mFtdYh": {
|
||||
"defaultMessage": "{type} Worker Relay"
|
||||
},
|
||||
"mKAr6h": {
|
||||
"defaultMessage": "Follow all"
|
||||
},
|
||||
@ -2037,9 +2049,6 @@
|
||||
"xPCyu+": {
|
||||
"defaultMessage": "nostr: URI scheme"
|
||||
},
|
||||
"xSoIUU": {
|
||||
"defaultMessage": "Worker Relay"
|
||||
},
|
||||
"xaj9Ba": {
|
||||
"defaultMessage": "Provider"
|
||||
},
|
||||
|
@ -181,6 +181,7 @@
|
||||
"DrZqav": "About must be less than {limit} characters",
|
||||
"DtYelJ": "Transfer",
|
||||
"Dx4ey3": "Toggle all",
|
||||
"E3oB+t": "Browser",
|
||||
"E5ZIPD": "<big>{amount}</big> <small>sats</small>",
|
||||
"EHqHsu": "Invoice / Lightning Address",
|
||||
"EJbFi7": "Search notes",
|
||||
@ -356,6 +357,7 @@
|
||||
"TDR5ge": "Media in notes will automatically be shown for selected people, otherwise only the link will show",
|
||||
"TH1fFo": "Telegram",
|
||||
"TJo5E6": "Preview",
|
||||
"TOG64f": "Use Local Relay",
|
||||
"TP/cMX": "Ended",
|
||||
"TaeBqw": "Sign in with Nostr Extension",
|
||||
"TdTXXf": "Learn more",
|
||||
@ -387,6 +389,7 @@
|
||||
"VnXp8Z": "Avatar",
|
||||
"W1yoZY": "It looks like you dont have any subscriptions, you can get one {link}",
|
||||
"W2PiAr": "{n} Blocked",
|
||||
"W4SaxY": "Local",
|
||||
"W9355R": "Unmute",
|
||||
"WeLEuL": "From Server",
|
||||
"WmZhfL": "Automatically translate notes to your local language",
|
||||
@ -564,6 +567,7 @@
|
||||
"lsNFM1": "Click to load content from {link}",
|
||||
"lvlPhZ": "Pay Invoice",
|
||||
"mErPop": "It looks like you dont have any, check {link} to buy one!",
|
||||
"mFtdYh": "{type} Worker Relay",
|
||||
"mKAr6h": "Follow all",
|
||||
"mKh2HS": "File upload service",
|
||||
"mKhgP9": "{n,plural,=0{} =1{zapped} other{zapped}}",
|
||||
@ -676,7 +680,6 @@
|
||||
"xIcAOU": "Votes by {type}",
|
||||
"xIoGG9": "Go to",
|
||||
"xPCyu+": "nostr: URI scheme",
|
||||
"xSoIUU": "Worker Relay",
|
||||
"xaj9Ba": "Provider",
|
||||
"xbVgIm": "Automatically load media",
|
||||
"xhQMeQ": "Expires",
|
||||
|
Loading…
x
Reference in New Issue
Block a user