This commit is contained in:
2023-03-29 13:10:22 +01:00
parent 8c44d123bd
commit c731c65661
27 changed files with 384 additions and 239 deletions

View File

@ -5,7 +5,7 @@ import { HexKey, TaggedRawEvent } from "@snort/nostr";
import Note from "Element/Note";
import { RootState } from "State/Store";
import { UserCache } from "State/Users/UserCache";
import { UserCache } from "Cache/UserCache";
import messages from "./messages";
@ -23,7 +23,7 @@ const Bookmarks = ({ pubkey, bookmarks, related }: BookmarksProps) => {
}, [bookmarks]);
function renderOption(p: HexKey) {
const profile = UserCache.get(p);
const profile = UserCache.getFromCache(p);
return profile ? <option value={p}>{profile?.display_name || profile?.name}</option> : null;
}

View File

@ -1,19 +1,24 @@
import { useDispatch } from "react-redux";
import { FormattedMessage } from "react-intl";
import { useNavigate } from "react-router-dom";
import { logout } from "State/Login";
import messages from "./messages";
export default function LogoutButton() {
const dispatch = useDispatch();
const navigate = useNavigate();
return (
<button
className="secondary"
type="button"
onClick={() => {
dispatch(logout());
window.location.href = "/";
dispatch(
logout(() => {
navigate("/");
})
);
}}>
<FormattedMessage {...messages.Logout} />
</button>

View File

@ -26,7 +26,7 @@ import NoteTime from "Element/NoteTime";
import useModeration from "Hooks/useModeration";
import { setPinned, setBookmarked } from "State/Login";
import type { RootState } from "State/Store";
import { UserCache } from "State/Users/UserCache";
import { UserCache } from "Cache/UserCache";
import messages from "./messages";
import { EventExt } from "System/EventExt";
@ -204,7 +204,7 @@ export default function Note(props: NoteProps) {
const replyRelayHints = thread?.replyTo?.Relay ?? thread.root?.Relay;
const mentions: { pk: string; name: string; link: ReactNode }[] = [];
for (const pk of thread?.pubKeys ?? []) {
const u = UserCache.get(pk);
const u = UserCache.getFromCache(pk);
const npub = hexToBech32(NostrPrefix.PublicKey, pk);
const shortNpub = npub.substring(0, 12);
mentions.push({

View File

@ -7,7 +7,7 @@ import { hexToBech32, profileLink } from "Util";
import Avatar from "Element/Avatar";
import Nip05 from "Element/Nip05";
import { HexKey, NostrPrefix } from "@snort/nostr";
import { MetadataCache } from "State/Users";
import { MetadataCache } from "Cache";
import usePageWidth from "Hooks/usePageWidth";
export interface ProfileImageProps {

View File

@ -10,8 +10,8 @@ import { NostrPrefix } from "@snort/nostr";
import Avatar from "Element/Avatar";
import Nip05 from "Element/Nip05";
import { hexToBech32 } from "Util";
import { MetadataCache } from "State/Users";
import { UserCache } from "State/Users/UserCache";
import { MetadataCache } from "Cache";
import { UserCache } from "Cache/UserCache";
import messages from "./messages";

View File

@ -10,7 +10,7 @@ import Text from "Element/Text";
import ProfileImage from "Element/ProfileImage";
import { RootState } from "State/Store";
import { findTag } from "Util";
import { UserCache } from "State/Users/UserCache";
import { UserCache } from "Cache/UserCache";
import messages from "./messages";
@ -65,7 +65,7 @@ export function parseZap(zapReceipt: TaggedRawEvent): ParsedZap {
ret.valid = false;
ret.errors.push("amount tag does not match invoice amount");
}
if (UserCache.get(ret.receiver)?.zapService !== ret.zapService) {
if (UserCache.getFromCache(ret.receiver)?.zapService !== ret.zapService) {
ret.valid = false;
ret.errors.push("zap service pubkey doesn't match");
}