mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2025-12-19 07:14:22 +01:00
Refetch federation balances on updates
This commit is contained in:
committed by
Tony Giorgio
parent
c82df3df0e
commit
69d6d3d359
@@ -5,6 +5,7 @@ import {
|
|||||||
setValue,
|
setValue,
|
||||||
SubmitHandler
|
SubmitHandler
|
||||||
} from "@modular-forms/solid";
|
} from "@modular-forms/solid";
|
||||||
|
import { FederationBalance } from "@mutinywallet/mutiny-wasm";
|
||||||
import { useSearchParams } from "@solidjs/router";
|
import { useSearchParams } from "@solidjs/router";
|
||||||
import {
|
import {
|
||||||
createResource,
|
createResource,
|
||||||
@@ -51,7 +52,15 @@ export type MutinyFederationIdentity = {
|
|||||||
federation_expiry_timestamp: number;
|
federation_expiry_timestamp: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
function AddFederationForm() {
|
type RefetchType = (
|
||||||
|
info?: unknown
|
||||||
|
) =>
|
||||||
|
| FederationBalance[]
|
||||||
|
| Promise<FederationBalance[] | undefined>
|
||||||
|
| null
|
||||||
|
| undefined;
|
||||||
|
|
||||||
|
function AddFederationForm(props: { refetch?: RefetchType }) {
|
||||||
const i18n = useI18n();
|
const i18n = useI18n();
|
||||||
const [state, actions] = useMegaStore();
|
const [state, actions] = useMegaStore();
|
||||||
const [error, setError] = createSignal<Error>();
|
const [error, setError] = createSignal<Error>();
|
||||||
@@ -88,6 +97,9 @@ function AddFederationForm() {
|
|||||||
i18n.t("settings.manage_federations.federation_added_success")
|
i18n.t("settings.manage_federations.federation_added_success")
|
||||||
);
|
);
|
||||||
await actions.refreshFederations();
|
await actions.refreshFederations();
|
||||||
|
if (props.refetch) {
|
||||||
|
await props.refetch();
|
||||||
|
}
|
||||||
reset(feedbackForm);
|
reset(feedbackForm);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Error submitting federation:", e);
|
console.error("Error submitting federation:", e);
|
||||||
@@ -225,7 +237,7 @@ export function ManageFederations() {
|
|||||||
const i18n = useI18n();
|
const i18n = useI18n();
|
||||||
const [state, _actions] = useMegaStore();
|
const [state, _actions] = useMegaStore();
|
||||||
|
|
||||||
const [balances] = createResource(async () => {
|
const [balances, { refetch }] = createResource(async () => {
|
||||||
try {
|
try {
|
||||||
const balances =
|
const balances =
|
||||||
await state.mutiny_wallet?.get_federation_balances();
|
await state.mutiny_wallet?.get_federation_balances();
|
||||||
@@ -253,7 +265,7 @@ export function ManageFederations() {
|
|||||||
{i18n.t("settings.manage_federations.learn_more")}
|
{i18n.t("settings.manage_federations.learn_more")}
|
||||||
</ExternalLink>
|
</ExternalLink>
|
||||||
</NiceP>
|
</NiceP>
|
||||||
<AddFederationForm />
|
<AddFederationForm refetch={refetch} />
|
||||||
<VStack>
|
<VStack>
|
||||||
<Suspense>
|
<Suspense>
|
||||||
<Switch>
|
<Switch>
|
||||||
|
|||||||
Reference in New Issue
Block a user