diff --git a/app/UI/app_update.tsx b/app/UI/app_update.tsx
index a27d040..9a1d74d 100644
--- a/app/UI/app_update.tsx
+++ b/app/UI/app_update.tsx
@@ -188,7 +188,7 @@ export async function* UI_Interaction_Update(args: {
app.popOverInputChan.put({
children: (
),
@@ -323,7 +323,19 @@ export async function* UI_Interaction_Update(args: {
children:
,
});
} else if (event.type == "RelayConfigChange") {
- console.log(event, "not handled yet");
+ (async () => {
+ let relay;
+ if (event.kind == "add") {
+ relay = await app.relayConfig.add(event.url);
+ } else {
+ relay = await app.relayConfig.remove(event.url);
+ }
+ if (relay instanceof Error) {
+ console.error(relay);
+ const msg = relay.message;
+ app.toastInputChan.put(() => msg);
+ }
+ })();
} else if (event.type == "ViewEventDetail") {
const nostrEvent = event.message.event;
const eventID = nostrEvent.id;
diff --git a/app/UI/setting.tsx b/app/UI/setting.tsx
index 543232c..81d9b46 100644
--- a/app/UI/setting.tsx
+++ b/app/UI/setting.tsx
@@ -63,7 +63,7 @@ export const Setting = (props: SettingProps) => {
@@ -102,11 +102,12 @@ export type ViewRelayDetail = {
export type ViewRecommendedRelaysList = {
type: "ViewRecommendedRelaysList";
- relayConfig: RelayConfig;
};
+export type func_GetRelayURLs = () => Set;
+
type RelaySettingProp = {
- relayConfig: RelayConfig;
+ getRelayURLs: func_GetRelayURLs;
relayPool: ConnectionPool;
emit: emitFunc;
};
@@ -141,7 +142,7 @@ export class RelaySetting extends Component
computeRelayStatus(props: RelaySettingProp) {
const _relayStatus: { url: string; status: keyof typeof colors }[] = [];
- for (const url of props.relayConfig.getRelayURLs()) {
+ for (const url of props.getRelayURLs()) {
const relay = props.relayPool.getRelay(url);
let status: keyof typeof colors = "Closed";
if (relay) {
@@ -165,7 +166,6 @@ export class RelaySetting extends Component
showRecommendedRelaysList = () => {
this.props.emit({
type: "ViewRecommendedRelaysList",
- relayConfig: this.props.relayConfig,
});
};
@@ -175,25 +175,19 @@ export class RelaySetting extends Component
const relayStatus = this.computeRelayStatus(props);
const addRelay = async () => {
- // props.eventBus.emit({ type: "AddRelay" });
console.log("add", addRelayInput);
- if (addRelayInput.length > 0) {
- const p = props.relayConfig.add(addRelayInput);
- this.setState({
- addRelayInput: "",
- relayStatus: this.computeRelayStatus(props),
- });
- const relay = await p;
- if (relay instanceof Error) {
- console.error(relay);
- return;
- }
- props.emit({
- type: "RelayConfigChange",
- kind: "add",
- url: relay.url,
- });
+ if (addRelayInput.length < 0) {
+ return;
}
+ this.setState({
+ addRelayInput: "",
+ relayStatus: this.computeRelayStatus(props),
+ });
+ props.emit({
+ type: "RelayConfigChange",
+ kind: "add",
+ url: addRelayInput,
+ });
};
return (
@@ -251,24 +245,7 @@ export class RelaySetting extends Component
? (