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