better types thx wasm-bindgen

This commit is contained in:
Paul Miller
2023-11-10 14:29:33 -06:00
parent 21ccd954a0
commit 4b34b66ee8
9 changed files with 39 additions and 75 deletions

View File

@@ -1,4 +1,3 @@
import { NwcProfile } from "@mutinywallet/mutiny-wasm";
import {
createEffect,
createResource,
@@ -42,10 +41,11 @@ export function PendingNwc() {
const [error, setError] = createSignal<Error>();
async function fetchPendingRequests() {
const profiles: NwcProfile[] =
await state.mutiny_wallet?.get_nwc_profiles();
const profiles = await state.mutiny_wallet?.get_nwc_profiles();
if (!profiles) return [];
const pending = await state.mutiny_wallet?.get_pending_nwc_invoices();
if (!pending) return [];
const pendingItems: PendingItem[] = [];

View File

@@ -2,30 +2,31 @@ import { createOptions, Select } from "@thisbeyond/solid-select";
import "~/styles/solid-select.css";
import { TagItem, TagKind } from "@mutinywallet/mutiny-wasm";
import { createMemo, createSignal, onMount } from "solid-js";
import { useMegaStore } from "~/state/megaStore";
import { MutinyTagItem, sortByLastUsed } from "~/utils";
import { sortByLastUsed } from "~/utils";
const createLabelValue = (label: string): Partial<MutinyTagItem> => {
return { name: label, kind: "Contact" };
const createLabelValue = (label: string): Partial<TagItem> => {
return { name: label, kind: TagKind.Contact };
};
export function TagEditor(props: {
selectedValues: Partial<MutinyTagItem>[];
setSelectedValues: (value: Partial<MutinyTagItem>[]) => void;
selectedValues: Partial<TagItem>[];
setSelectedValues: (value: Partial<TagItem>[]) => void;
placeholder: string;
autoFillTag?: string | undefined;
}) {
const [_state, actions] = useMegaStore();
const [availableTags, setAvailableTags] = createSignal<MutinyTagItem[]>([]);
const [availableTags, setAvailableTags] = createSignal<TagItem[]>([]);
onMount(async () => {
const tags = await actions.listTags();
if (tags) {
setAvailableTags(
tags
.filter((tag) => tag.kind === "Contact")
.filter((tag) => tag.kind === TagKind.Contact)
.sort(sortByLastUsed)
);
if (props.autoFillTag && availableTags()) {
@@ -51,7 +52,7 @@ export function TagEditor(props: {
});
});
const onChange = (selected: MutinyTagItem[]) => {
const onChange = (selected: TagItem[]) => {
props.setSelectedValues(selected);
const lastValue = selected[selected.length - 1];

View File

@@ -4,6 +4,7 @@ import {
Checkbox as KCheckbox,
Separator
} from "@kobalte/core";
import { TagItem, TagKind } from "@mutinywallet/mutiny-wasm";
import {
createResource,
createSignal,
@@ -27,7 +28,7 @@ import {
} from "~/components";
import { useI18n } from "~/i18n/context";
import { useMegaStore } from "~/state/megaStore";
import { generateGradient, MutinyTagItem } from "~/utils";
import { generateGradient } from "~/utils";
export const SmallHeader: ParentComponent<{ class?: string }> = (props) => {
return (
@@ -268,7 +269,7 @@ export const TinyText: ParentComponent = (props) => {
export const TinyButton: ParentComponent<{
onClick: () => void;
tag?: MutinyTagItem;
tag?: TagItem;
}> = (props) => {
// TODO: don't need to run this if it's not a contact
const [gradient] = createResource(async () => {
@@ -276,7 +277,7 @@ export const TinyButton: ParentComponent<{
});
const bg = () =>
props.tag?.name && props.tag?.kind === "Contact"
props.tag?.name && props.tag?.kind === TagKind.Contact
? gradient()
: "rgb(255 255 255 / 0.1)";