bug: Fix profile update & relays for new user

This commit is contained in:
2023-03-31 13:08:50 +01:00
parent 29c80c4259
commit f296063283
7 changed files with 27 additions and 56 deletions

View File

@ -7,7 +7,7 @@ import { FormattedMessage } from "react-intl";
import { RelaySettings } from "@snort/nostr";
import messages from "./messages";
import { bech32ToHex, randomSample } from "Util";
import { bech32ToHex, randomSample, unixNowMs, unwrap } from "Util";
import Icon from "Icons/Icon";
import { RootState } from "State/Store";
import { init, setRelays } from "State/Login";
@ -19,7 +19,7 @@ import useModeration from "Hooks/useModeration";
import { NoteCreator } from "Element/NoteCreator";
import { db } from "Db";
import useEventPublisher from "Feed/EventPublisher";
import { SnortPubKey } from "Const";
import { DefaultRelays, SnortPubKey } from "Const";
import SubDebug from "Element/SubDebug";
import { preload } from "Cache";
import { useDmCache } from "Hooks/useDmsCache";
@ -129,11 +129,14 @@ export default function Layout() {
const online: string[] = await rsp.json();
const pickRandom = randomSample(online, 4);
const relayObjects = pickRandom.map(a => [a, { read: true, write: true }]);
newRelays = Object.fromEntries(relayObjects);
newRelays = {
...Object.fromEntries(relayObjects),
...Object.fromEntries(DefaultRelays.entries()),
};
dispatch(
setRelays({
relays: newRelays,
createdAt: 1,
createdAt: unixNowMs(),
})
);
}
@ -141,7 +144,7 @@ export default function Layout() {
console.warn(e);
}
const ev = await pub.addFollow(bech32ToHex(SnortPubKey), newRelays);
const ev = await pub.addFollow([bech32ToHex(SnortPubKey), unwrap(publicKey)], newRelays);
pub.broadcast(ev);
}