merge-requests/3333/head
danidfra 2025-03-25 14:51:38 -03:00
rodzic 0877e388d2
commit 575c81cde9
8 zmienionych plików z 11 dodań i 82 usunięć

Wyświetl plik

@ -1,4 +1,3 @@
import toast from 'soapbox/toast.tsx';
import { isLoggedIn } from 'soapbox/utils/auth.ts';
import api from '../api/index.ts';
@ -74,10 +73,6 @@ const FAVOURITES_EXPAND_FAIL = 'FAVOURITES_EXPAND_FAIL';
const REBLOGS_EXPAND_SUCCESS = 'REBLOGS_EXPAND_SUCCESS';
const REBLOGS_EXPAND_FAIL = 'REBLOGS_EXPAND_FAIL';
const NUTZAP_REQUEST = 'NUTZAP_REQUEST';
const NUTZAP_SUCCESS = 'NUTZAP_SUCCESS';
const NUTZAP_FAIL = 'NUTZAP_FAIL';
const ZAP_REQUEST = 'ZAP_REQUEST';
const ZAP_SUCCESS = 'ZAP_SUCCESS';
const ZAP_FAIL = 'ZAP_FAIL';
@ -362,57 +357,6 @@ const zapFail = (status: StatusEntity, error: unknown) => ({
skipLoading: true,
});
const nutzap = (account: AccountEntity, status: StatusEntity | undefined, amount: number, comment: string) =>
async (dispatch: AppDispatch, getState: () => RootState) => {
if (!isLoggedIn(getState)) return;
try {
const response = await api(getState).post('/api/v1/ditto/cashu/nutzap', {
amount,
comment,
account_id: account.id,
status_id: status?.id,
});
const data = await response.json();
if (data) {
toast.success(data.message);
} else {
toast.success('Nutzap sent successfully!');
}
if (status) dispatch(nutzapSuccess(status));
} catch (e) {
if (e instanceof Error) {
toast.error(e.message);
} else {
toast.error('An unexpected error occurred');
}
if (status) dispatch(nutzapFail(status, e));
}
};
const nutzapRequest = (status: StatusEntity) => ({
type: NUTZAP_REQUEST,
status: status,
skipLoading: true,
});
const nutzapSuccess = (status: StatusEntity) => ({
type: NUTZAP_SUCCESS,
status: status,
skipLoading: true,
});
const nutzapFail = (status: StatusEntity, error: unknown) => ({
type: NUTZAP_FAIL,
status: status,
error: error,
skipLoading: true,
});
const bookmarkRequest = (status: StatusEntity) => ({
type: BOOKMARK_REQUEST,
status: status,
@ -849,9 +793,6 @@ export {
FAVOURITES_EXPAND_FAIL,
REBLOGS_EXPAND_SUCCESS,
REBLOGS_EXPAND_FAIL,
NUTZAP_REQUEST,
NUTZAP_SUCCESS,
NUTZAP_FAIL,
ZAP_REQUEST,
ZAP_FAIL,
ZAPS_FETCH_REQUEST,
@ -923,10 +864,6 @@ export {
remoteInteractionRequest,
remoteInteractionSuccess,
remoteInteractionFail,
nutzapRequest,
nutzapSuccess,
nutzapFail,
nutzap,
zap,
fetchZaps,
expandZaps,

Wyświetl plik

@ -25,7 +25,6 @@ import { useNutzapRequest } from 'soapbox/features/zap/hooks/useHooks.ts';
import { usePaymentMethod } from 'soapbox/features/zap/usePaymentMethod.ts';
import { useAppDispatch } from 'soapbox/hooks/useAppDispatch.ts';
import { emojifyText } from 'soapbox/utils/emojify.tsx';
import { capitalize } from 'soapbox/utils/strings.ts';
import PaymentButton from './zap-button/payment-button.tsx';
@ -48,8 +47,8 @@ interface IPayRequestForm {
const closeIcon = xIcon;
const messages = defineMessages({
zap_button_rounded: { id: 'zap.button.text.rounded', defaultMessage: '{method} {amount}K sats' },
zap_button: { id: 'payment_method.button.text.raw', defaultMessage: '{method} {amount} sats' },
zap_button_rounded: { id: 'zap.button.text.rounded', defaultMessage: 'Zap {amount}K sats' },
zap_button: { id: 'payment_method.button.text.raw', defaultMessage: 'Zap {amount} sats' },
zap_commentPlaceholder: { id: 'payment_method.comment_input.placeholder', defaultMessage: 'Optional comment' },
});
@ -108,9 +107,9 @@ const PayRequestForm = ({ account, status, onClose }: IPayRequestForm) => {
const renderPaymentButtonText = () => {
if (amount >= 1000) {
return intl.formatMessage(messages.zap_button_rounded, { amount: Math.round((amount / 1000) * 10) / 10, method: isCashu ? 'Nutzap' : capitalize(paymentMethod) });
return intl.formatMessage(messages.zap_button_rounded, { amount: Math.round((amount / 1000) * 10) / 10 });
}
return intl.formatMessage(messages.zap_button, { amount: amount, method: isCashu ? 'Nutzap' : capitalize(paymentMethod) });
return intl.formatMessage(messages.zap_button, { amount: amount });
};
useEffect(() => {

Wyświetl plik

@ -177,7 +177,7 @@ const useNutzapRequest = () => {
addNutzap(status.id, { status, amount, comment });
}
toast.success(data.message || 'Nutzap sent successfully!');
toast.success(data.message || 'Zap sent successfully!');
getWallet();
getTransactions();
} catch (err) {

Wyświetl plik

@ -1295,7 +1295,7 @@
"password_reset.reset": "Reset password",
"patron.donate": "Donate",
"patron.title": "Funding Goal",
"payment_method.button.text.raw": "{method} {amount} sats",
"payment_method.button.text.raw": "Zap {amount} sats",
"payment_method.comment_input.placeholder": "Optional comment",
"payment_method.send_to": "Send {method} to {target}",
"payment_method.split_message.deducted": "{amountDeducted} sats will deducted*",
@ -1743,7 +1743,7 @@
"wallet.transactions.no_transactions": "You don't have transactions yet.",
"wallet.transactions.show_more": "Show More",
"who_to_follow.title": "People To Follow",
"zap.button.text.rounded": "{method} {amount}K sats",
"zap.button.text.rounded": "Zap {amount}K sats",
"zap.finish": "Finish",
"zap.next": "Next",
"zap.open_wallet": "Open Wallet",

Wyświetl plik

@ -1626,7 +1626,7 @@
"video.play": "Reproducir",
"video.unmute": "Dejar de silenciar sonido",
"who_to_follow.title": "Personas a seguir",
"payment_method.button.text.raw": "{method} {amount} sats",
"payment_method.button.text.raw": "Zap {amount} sats",
"payment_method.comment_input.placeholder": "Comentario opcional",
"zap.open_wallet": "Abrir Wallet",
"zap.send_to": "Enviar zaps a {target}",

Wyświetl plik

@ -1679,8 +1679,8 @@
"video.play": "Seinn",
"video.unmute": "Fuaim gan iomrá",
"who_to_follow.title": "Daoine le Leanúint",
"payment_method.button.text.raw": "Suíonn {method} {amount}",
"zap.button.text.rounded": "{method} {amount}K shuíonn",
"payment_method.button.text.raw": "Suíonn Zap {amount}",
"zap.button.text.rounded": "Zap {amount}K shuíonn",
"payment_method.comment_input.placeholder": "Nóta roghnach",
"zap.finish": "Críochnaigh",
"zap.next": "Ar Aghaidh",

Wyświetl plik

@ -1635,7 +1635,7 @@
"video.play": "Reproduzir",
"video.unmute": "Reativar som",
"who_to_follow.title": "Quem seguir",
"payment_method.button.text.raw": "{method} {amount} sats",
"payment_method.button.text.raw": "Zap {amount} sats",
"payment_method.comment_input.placeholder": "Comentário opcional",
"zap.open_wallet": "Abrir Carteira",
"zap.send_to": "Enviar zaps para {target}",

Wyświetl plik

@ -28,8 +28,6 @@ import {
DISLIKE_REQUEST,
UNDISLIKE_REQUEST,
DISLIKE_FAIL,
NUTZAP_FAIL,
NUTZAP_SUCCESS,
ZAP_REQUEST,
ZAP_FAIL,
} from '../actions/interactions.ts';
@ -239,7 +237,6 @@ const simulatePayment = (state: State, statusId: string, paid: boolean, method:
});
}
return state.set(statusId, updatedStatus);
};
@ -301,10 +298,6 @@ export default function statuses(state = initialState, action: AnyAction): State
return simulatePayment(state, action.status.id, true, 'zap');
case ZAP_FAIL:
return simulatePayment(state, action.status.id, false, 'zap');
case NUTZAP_SUCCESS:
return simulatePayment(state, action.status.id, true, 'cashu');
case NUTZAP_FAIL:
return simulatePayment(state, action.status.id, false, 'cashu');
case REBLOG_REQUEST:
return state.setIn([action.status.id, 'reblogged'], true);
case REBLOG_FAIL: