feat: safe sync appdata
This commit is contained in:
@ -4,14 +4,12 @@ import { MixCloudRegex } from "@/Utils/Const";
|
||||
const MixCloudEmbed = ({ link }: { link: string }) => {
|
||||
const feedPath = (MixCloudRegex.test(link) && RegExp.$1) + "%2F" + (MixCloudRegex.test(link) && RegExp.$2);
|
||||
|
||||
const theme = useLogin(s => s.appData.item.preferences.theme);
|
||||
const theme = useLogin(s => s.appData.json.preferences.theme);
|
||||
const lightParams = theme === "light" ? "light=1" : "light=0";
|
||||
return (
|
||||
<>
|
||||
<br />
|
||||
<iframe
|
||||
// eslint-disable-next-line react/no-unknown-property
|
||||
credentialless=""
|
||||
title="SoundCloud player"
|
||||
width="100%"
|
||||
height="120"
|
||||
|
@ -22,7 +22,7 @@ export default function PubkeyList({ ev, className }: { ev: NostrEvent; classNam
|
||||
for (const pk of ids) {
|
||||
try {
|
||||
const profile = await UserCache.get(pk);
|
||||
const amtSend = login.appData.item.preferences.defaultZapAmount;
|
||||
const amtSend = login.appData.json.preferences.defaultZapAmount;
|
||||
const lnurl = profile?.lud16 || profile?.lud06;
|
||||
if (lnurl) {
|
||||
const svc = new LNURL(lnurl);
|
||||
@ -74,7 +74,7 @@ export default function PubkeyList({ ev, className }: { ev: NostrEvent; classNam
|
||||
defaultMessage="Zap all {n} sats"
|
||||
id="IVbtTS"
|
||||
values={{
|
||||
n: <FormattedNumber value={login.appData.item.preferences.defaultZapAmount * ids.length} />,
|
||||
n: <FormattedNumber value={login.appData.json.preferences.defaultZapAmount * ids.length} />,
|
||||
}}
|
||||
/>
|
||||
</AsyncButton>
|
||||
|
@ -56,7 +56,7 @@ const quoteNoteOptions = {
|
||||
export function NoteCreator() {
|
||||
const { formatMessage } = useIntl();
|
||||
const uploader = useFileUpload();
|
||||
const login = useLogin(s => ({ relays: s.relays, publicKey: s.publicKey, pow: s.appData.item.preferences.pow }));
|
||||
const login = useLogin(s => ({ relays: s.relays, publicKey: s.publicKey, pow: s.appData.json.preferences.pow }));
|
||||
const { system, publisher: pub } = useEventPublisher();
|
||||
const publisher = login.pow ? pub?.pow(login.pow, GetPowWorker()) : pub;
|
||||
const note = useNoteCreator();
|
||||
|
@ -4,7 +4,7 @@ import { FormattedMessage } from "react-intl";
|
||||
import useLogin from "@/Hooks/useLogin";
|
||||
|
||||
const HiddenNote = ({ children }: { children: React.ReactNode }) => {
|
||||
const hideMutedNotes = useLogin(s => s.appData.item.preferences.hideMutedNotes);
|
||||
const hideMutedNotes = useLogin(s => s.appData.json.preferences.hideMutedNotes);
|
||||
const [show, setShow] = useState(false);
|
||||
if (hideMutedNotes) return;
|
||||
|
||||
|
@ -78,7 +78,7 @@ export function NoteContextMenu({ ev, ...props }: NoteContextMenuProps) {
|
||||
|
||||
useEffect(() => {
|
||||
const sub = getCurrentSubscription(login.subscriptions);
|
||||
if (sub?.type === SubscriptionType.Premium && (login.appData.item.preferences.autoTranslate ?? true)) {
|
||||
if (sub?.type === SubscriptionType.Premium && (login.appData.json.preferences.autoTranslate ?? true)) {
|
||||
translate();
|
||||
}
|
||||
}, []);
|
||||
|
@ -30,7 +30,7 @@ export const FooterZapButton = ({ ev, zaps, onClickZappers }: ZapIconProps) => {
|
||||
} = useLogin(s => ({
|
||||
publicKey: s.publicKey,
|
||||
readonly: s.readonly,
|
||||
preferences: s.appData.item.preferences,
|
||||
preferences: s.appData.json.preferences,
|
||||
}));
|
||||
const walletState = useWallet();
|
||||
const wallet = walletState.wallet;
|
||||
|
@ -26,7 +26,7 @@ export default function NoteFooter(props: NoteFooterProps) {
|
||||
const { positive } = reactions;
|
||||
|
||||
const { preferences: prefs, readonly } = useLogin(s => ({
|
||||
preferences: s.appData.item.preferences,
|
||||
preferences: s.appData.json.preferences,
|
||||
publicKey: s.publicKey,
|
||||
readonly: s.readonly,
|
||||
}));
|
||||
|
@ -16,7 +16,7 @@ export const RepostButton = ({ ev, reposts }: { ev: TaggedNostrEvent; reposts: T
|
||||
const navigate = useNavigate();
|
||||
const { publisher, system } = useEventPublisher();
|
||||
const { publicKey, preferences: prefs } = useLogin(s => ({
|
||||
preferences: s.appData.item.preferences,
|
||||
preferences: s.appData.json.preferences,
|
||||
publicKey: s.publicKey,
|
||||
}));
|
||||
const note = useNoteCreator(n => ({ show: n.show, replyTo: n.replyTo, update: n.update, quote: n.quote }));
|
||||
|
@ -53,7 +53,7 @@ export const NoteText = memo(function InnerContent(
|
||||
</>
|
||||
);
|
||||
|
||||
if (!appData.item.showContentWarningPosts) {
|
||||
if (!appData.json.showContentWarningPosts) {
|
||||
const contentWarning = ev.tags.find(a => a[0] === "content-warning");
|
||||
if (contentWarning) {
|
||||
return (
|
||||
|
@ -27,7 +27,7 @@ export default function Poll(props: PollProps) {
|
||||
preferences: prefs,
|
||||
publicKey: myPubKey,
|
||||
relays,
|
||||
} = useLogin(s => ({ preferences: s.appData.item.preferences, publicKey: s.publicKey, relays: s.relays }));
|
||||
} = useLogin(s => ({ preferences: s.appData.json.preferences, publicKey: s.publicKey, relays: s.relays }));
|
||||
const pollerProfile = useUserProfile(props.ev.pubkey);
|
||||
const [tallyBy, setTallyBy] = useState<PollTally>("pubkeys");
|
||||
const [error, setError] = useState("");
|
||||
|
@ -17,7 +17,7 @@ interface RevealMediaProps {
|
||||
|
||||
export default function RevealMedia(props: RevealMediaProps) {
|
||||
const { preferences, follows, publicKey } = useLogin(s => ({
|
||||
preferences: s.appData.item.preferences,
|
||||
preferences: s.appData.json.preferences,
|
||||
follows: s.follows.item,
|
||||
publicKey: s.publicKey,
|
||||
}));
|
||||
|
@ -19,7 +19,7 @@ export function RootTabs({ base = "/" }: { base: string }) {
|
||||
} = useLogin(s => ({
|
||||
publicKey: s.publicKey,
|
||||
tags: s.tags,
|
||||
preferences: s.appData.item.preferences,
|
||||
preferences: s.appData.json.preferences,
|
||||
}));
|
||||
|
||||
const menuItems = useMemo(() => rootTabItems(base, pubKey, tags), [base, pubKey, tags]);
|
||||
|
@ -5,7 +5,7 @@ import { LangOverride } from "@/Components/IntlProvider/langStore";
|
||||
import useLogin from "@/Hooks/useLogin";
|
||||
|
||||
export function useLocale() {
|
||||
const { language } = useLogin(s => ({ language: s.appData.item.preferences.language }));
|
||||
const { language } = useLogin(s => ({ language: s.appData.json.preferences.language }));
|
||||
const loggedOutLang = useSyncExternalStore(
|
||||
c => LangOverride.hook(c),
|
||||
() => LangOverride.snapshot(),
|
||||
|
@ -104,8 +104,8 @@ export function LoginUnlock() {
|
||||
const newPin = await PinEncrypted.create(k, pin);
|
||||
|
||||
const pub = EventPublisher.privateKey(k);
|
||||
if (login.appData.item.preferences.pow) {
|
||||
pub.pow(login.appData.item.preferences.pow, GetPowWorker());
|
||||
if (login.appData.json.preferences.pow) {
|
||||
pub.pow(login.appData.json.preferences.pow, GetPowWorker());
|
||||
}
|
||||
LoginStore.setPublisher(login.id, pub);
|
||||
LoginStore.updateSession({
|
||||
@ -121,8 +121,8 @@ export function LoginUnlock() {
|
||||
await key.unlock(pin);
|
||||
const pub = createPublisher(login);
|
||||
if (pub) {
|
||||
if (login.appData.item.preferences.pow) {
|
||||
pub.pow(login.appData.item.preferences.pow, GetPowWorker());
|
||||
if (login.appData.json.preferences.pow) {
|
||||
pub.pow(login.appData.json.preferences.pow, GetPowWorker());
|
||||
}
|
||||
LoginStore.setPublisher(login.id, pub);
|
||||
LoginStore.updateSession({
|
||||
|
@ -22,7 +22,7 @@ export function ZapModalInput(props: {
|
||||
onNextStage: (v: SendSatsInputSelection) => Promise<void>;
|
||||
}) {
|
||||
const { defaultZapAmount, readonly } = useLogin(s => ({
|
||||
defaultZapAmount: s.appData.item.preferences.defaultZapAmount,
|
||||
defaultZapAmount: s.appData.json.preferences.defaultZapAmount,
|
||||
readonly: s.readonly,
|
||||
}));
|
||||
const { formatMessage } = useIntl();
|
||||
|
Reference in New Issue
Block a user