Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refetch federation balances on updates #867

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/routes/settings/ManageFederations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
setValue,
SubmitHandler
} from "@modular-forms/solid";
import { FederationBalance } from "@mutinywallet/mutiny-wasm";
import { useSearchParams } from "@solidjs/router";
import {
createResource,
Expand Down Expand Up @@ -51,7 +52,15 @@ export type MutinyFederationIdentity = {
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 [state, actions] = useMegaStore();
const [error, setError] = createSignal<Error>();
Expand Down Expand Up @@ -88,6 +97,9 @@ function AddFederationForm() {
i18n.t("settings.manage_federations.federation_added_success")
);
await actions.refreshFederations();
if (props.refetch) {
await props.refetch();
}
reset(feedbackForm);
} catch (e) {
console.error("Error submitting federation:", e);
Expand Down Expand Up @@ -225,7 +237,7 @@ export function ManageFederations() {
const i18n = useI18n();
const [state, _actions] = useMegaStore();

const [balances] = createResource(async () => {
const [balances, { refetch }] = createResource(async () => {
try {
const balances =
await state.mutiny_wallet?.get_federation_balances();
Expand Down Expand Up @@ -253,7 +265,7 @@ export function ManageFederations() {
{i18n.t("settings.manage_federations.learn_more")}
</ExternalLink>
</NiceP>
<AddFederationForm />
<AddFederationForm refetch={refetch} />
<VStack>
<Suspense>
<Switch>
Expand Down
Loading