Show "Get Started" on acctions that require account

This commit is contained in:
Bojan Mojsilovic 2023-10-13 13:07:56 +02:00
parent 79110494fe
commit 5e668f5c25
3 changed files with 45 additions and 21 deletions

View File

@ -36,7 +36,8 @@ const ButtonFollow: Component<{
if (!account || !account.hasPublicKey() || !props.person) {
toast?.sendWarning(intl.formatMessage(t.needToLogin))
account?.actions.showGetStarted();
// toast?.sendWarning(intl.formatMessage(t.needToLogin))
return;
}

View File

@ -29,7 +29,8 @@ const FollowButton: Component<{
const onFollow = (e: MouseEvent) => {
e.preventDefault();
if (!account || !account.hasPublicKey() || !props.person) {
toast?.sendWarning(intl.formatMessage(t.needToLogin))
account?.actions.showGetStarted();
// toast?.sendWarning(intl.formatMessage(t.needToLogin))
return;
}

View File

@ -79,6 +79,10 @@ const NoteFooter: Component<{ note: PrimalNote, doCustomZap?: boolean, id?: stri
};
const doQuote = () => {
if (!account?.hasPublicKey()) {
account?.actions.showGetStarted();
return;
}
setIsRepostMenuVisible(false);
account?.actions?.quoteNote(`nostr:${props.note.post.noteId}`);
account?.actions?.showNewNoteForm();
@ -89,6 +93,11 @@ const NoteFooter: Component<{ note: PrimalNote, doCustomZap?: boolean, id?: stri
return;
}
if (!account.hasPublicKey()) {
account.actions.showGetStarted();
return;
}
if (account.relays.length === 0) {
toast?.sendWarning(
intl.formatMessage(t.noRelaysConnected),
@ -124,6 +133,11 @@ const NoteFooter: Component<{ note: PrimalNote, doCustomZap?: boolean, id?: stri
return;
}
if (!account.hasPublicKey()) {
account.actions.showGetStarted();
return;
}
if (account.relays.length === 0) {
toast?.sendWarning(
intl.formatMessage(t.noRelaysConnected),
@ -148,9 +162,10 @@ const NoteFooter: Component<{ note: PrimalNote, doCustomZap?: boolean, id?: stri
e.stopPropagation();
if (!account?.hasPublicKey()) {
toast?.sendWarning(
intl.formatMessage(t.zapAsGuest),
);
account?.actions.showGetStarted()
// toast?.sendWarning(
// intl.formatMessage(t.zapAsGuest),
// );
setIsZapping(false);
return;
}
@ -182,7 +197,12 @@ const NoteFooter: Component<{ note: PrimalNote, doCustomZap?: boolean, id?: stri
clearTimeout(quickZapDelay);
if (!account?.hasPublicKey() || account.relays.length === 0 || !canUserReceiveZaps(props.note.user)) {
if (!account?.hasPublicKey()) {
account?.actions.showGetStarted();
return;
}
if (account.relays.length === 0 || !canUserReceiveZaps(props.note.user)) {
return;
}
@ -278,22 +298,24 @@ const NoteFooter: Component<{ note: PrimalNote, doCustomZap?: boolean, id?: stri
}
const doQuickZap = async () => {
if (account?.hasPublicKey()) {
setZappedAmount(() => settings?.defaultZapAmount || 0);
setZappedNow(true);
animateZap();
const success = await zapNote(props.note, account.publicKey, settings?.defaultZapAmount || 10, '', account.relays);
setIsZapping(false);
if (success) {
return;
}
setZappedAmount(() => -(settings?.defaultZapAmount || 0));
setZappedNow(true);
setZapped(props.note.post.noteActions.zapped);
if (!account?.hasPublicKey()) {
account?.actions.showGetStarted();
return;
}
setZappedAmount(() => settings?.defaultZapAmount || 0);
setZappedNow(true);
animateZap();
const success = await zapNote(props.note, account.publicKey, settings?.defaultZapAmount || 10, '', account.relays);
setIsZapping(false);
if (success) {
return;
}
setZappedAmount(() => -(settings?.defaultZapAmount || 0));
setZappedNow(true);
setZapped(props.note.post.noteActions.zapped);
}
const buttonTypeClasses: Record<string, string> = {