mirror of
https://github.com/PrimalHQ/primal-web-app.git
synced 2024-10-01 17:31:13 +00:00
Fix zap user feedback
This commit is contained in:
parent
15a0b3d3f1
commit
37a522ecbe
@ -82,6 +82,7 @@ const Note: Component<{
|
||||
app?.actions.closeCustomZapModal();
|
||||
batch(() => {
|
||||
updateFooterState('zappedAmount', () => zapOption.amount || 0);
|
||||
updateFooterState('satsZapped', (z) => z + (zapOption.amount || 0));
|
||||
// updateFooterState('zappedNow', () => true);
|
||||
updateFooterState('zapped', () => true);
|
||||
updateFooterState('showZapAnim', () => true)
|
||||
@ -90,6 +91,7 @@ const Note: Component<{
|
||||
|
||||
const onSuccessZap = (zapOption: ZapOption) => {
|
||||
app?.actions.closeCustomZapModal();
|
||||
app?.actions.resetCustomZap();
|
||||
batch(() => {
|
||||
updateFooterState('zapCount', (z) => z + 1);
|
||||
// updateFooterState('satsZapped', (z) => z + (zapOption.amount || 0));
|
||||
@ -103,6 +105,7 @@ const Note: Component<{
|
||||
|
||||
const onFailZap = (zapOption: ZapOption) => {
|
||||
app?.actions.closeCustomZapModal();
|
||||
app?.actions.resetCustomZap();
|
||||
batch(() => {
|
||||
updateFooterState('zappedAmount', () => -(zapOption.amount || 0));
|
||||
updateFooterState('satsZapped', (z) => z - (zapOption.amount || 0));
|
||||
@ -116,6 +119,7 @@ const Note: Component<{
|
||||
|
||||
const onCancelZap = (zapOption: ZapOption) => {
|
||||
app?.actions.closeCustomZapModal();
|
||||
app?.actions.resetCustomZap();
|
||||
batch(() => {
|
||||
updateFooterState('zappedAmount', () => -(zapOption.amount || 0));
|
||||
updateFooterState('satsZapped', (z) => z - (zapOption.amount || 0));
|
||||
@ -127,13 +131,13 @@ const Note: Component<{
|
||||
});
|
||||
};
|
||||
|
||||
const customZapInfo: CustomZapInfo = {
|
||||
const customZapInfo: () => CustomZapInfo = () => ({
|
||||
note: props.note,
|
||||
onConfirm: onConfirmZap,
|
||||
onSuccess: onSuccessZap,
|
||||
onFail: onFailZap,
|
||||
onCancel: onCancelZap,
|
||||
};
|
||||
});
|
||||
|
||||
const openReactionModal = (openOn = 'likes') => {
|
||||
app?.actions.openReactionModal(props.note.post.id, {
|
||||
@ -150,7 +154,7 @@ const Note: Component<{
|
||||
props.note,
|
||||
noteContextMenu?.getBoundingClientRect(),
|
||||
() => {
|
||||
app?.actions.openCustomZapModal(customZapInfo);
|
||||
app?.actions.openCustomZapModal(customZapInfo());
|
||||
},
|
||||
openReactionModal,
|
||||
);
|
||||
@ -211,7 +215,7 @@ const Note: Component<{
|
||||
note={props.note}
|
||||
state={footerState}
|
||||
updateState={updateFooterState}
|
||||
customZapInfo={customZapInfo}
|
||||
customZapInfo={customZapInfo()}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -306,7 +310,7 @@ const Note: Component<{
|
||||
note={props.note}
|
||||
state={footerState}
|
||||
updateState={updateFooterState}
|
||||
customZapInfo={customZapInfo}
|
||||
customZapInfo={customZapInfo()}
|
||||
wide={true}
|
||||
large={true}
|
||||
/>
|
||||
@ -369,7 +373,7 @@ const Note: Component<{
|
||||
note={props.note}
|
||||
state={footerState}
|
||||
updateState={updateFooterState}
|
||||
customZapInfo={customZapInfo}
|
||||
customZapInfo={customZapInfo()}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -71,6 +71,7 @@ export type AppContextStore = {
|
||||
closeReactionModal: () => void,
|
||||
openCustomZapModal: (custonZapInfo: CustomZapInfo) => void,
|
||||
closeCustomZapModal: () => void,
|
||||
resetCustomZap: () => void,
|
||||
openContextMenu: (note: PrimalNote, position: DOMRect | undefined, openCustomZapModal: () => void, openReactionModal: () => void) => void,
|
||||
closeContextMenu: () => void,
|
||||
openLnbcModal: (lnbc: string, onPay: () => void) => void,
|
||||
@ -141,7 +142,7 @@ export const AppProvider = (props: { children: JSXElement }) => {
|
||||
};
|
||||
|
||||
const openCustomZapModal = (customZapInfo: CustomZapInfo) => {
|
||||
updateStore('customZap', reconcile({ ...customZapInfo }));
|
||||
updateStore('customZap', () => ({ ...customZapInfo }));
|
||||
updateStore('showCustomZapModal', () => true);
|
||||
};
|
||||
|
||||
@ -149,6 +150,10 @@ export const AppProvider = (props: { children: JSXElement }) => {
|
||||
updateStore('showCustomZapModal', () => false);
|
||||
};
|
||||
|
||||
const resetCustomZap = () => {
|
||||
updateStore('customZap', () => undefined);
|
||||
};
|
||||
|
||||
const openContextMenu = (
|
||||
note: PrimalNote,
|
||||
position: DOMRect | undefined,
|
||||
@ -258,6 +263,7 @@ export const AppProvider = (props: { children: JSXElement }) => {
|
||||
closeReactionModal,
|
||||
openCustomZapModal,
|
||||
closeCustomZapModal,
|
||||
resetCustomZap,
|
||||
openContextMenu,
|
||||
closeContextMenu,
|
||||
openLnbcModal,
|
||||
|
Loading…
Reference in New Issue
Block a user