feat: fix frontend based lint errors

This commit is contained in:
benalleng
2023-06-21 14:03:11 -04:00
committed by Paul Miller
parent e7418eb2f4
commit c5bf39cfd4
4 changed files with 60 additions and 46 deletions

View File

@@ -1,7 +1,7 @@
import { NiceP } from "./layout"; import { NiceP } from "./layout";
import { For, Match, Show, Switch, createEffect, createSignal } from "solid-js"; import { For, Match, Show, Switch, createEffect, createSignal } from "solid-js";
import { useMegaStore } from "~/state/megaStore"; import { useMegaStore } from "~/state/megaStore";
import { ActivityItem as MutinyActivity } from "@mutinywallet/mutiny-wasm"; import { Contact } from "@mutinywallet/mutiny-wasm";
import { ActivityItem, HackActivityType } from "./ActivityItem"; import { ActivityItem, HackActivityType } from "./ActivityItem";
import { DetailsIdModal } from "./DetailsModal"; import { DetailsIdModal } from "./DetailsModal";
@@ -39,8 +39,18 @@ export type UtxoItem = {
redshifted?: boolean; redshifted?: boolean;
}; };
export type ActivityItem = {
kind: HackActivityType
id: string;
amount_sats: number;
inbound: boolean;
labels: string[];
contacts: Contact[];
last_updated: number;
};
function UnifiedActivityItem(props: { function UnifiedActivityItem(props: {
item: MutinyActivity; item: ActivityItem;
onClick: (id: string, kind: HackActivityType) => void; onClick: (id: string, kind: HackActivityType) => void;
}) { }) {
const click = () => { const click = () => {

View File

@@ -12,7 +12,6 @@ import {
} from "solid-js"; } from "solid-js";
import { Hr, ModalCloseButton, TinyButton, VStack } from "~/components/layout"; import { Hr, ModalCloseButton, TinyButton, VStack } from "~/components/layout";
import { import {
ChannelClosure,
MutinyChannel, MutinyChannel,
MutinyInvoice MutinyInvoice
} from "@mutinywallet/mutiny-wasm"; } from "@mutinywallet/mutiny-wasm";
@@ -35,6 +34,13 @@ import { AmountSmall } from "./Amount";
import { ExternalLink } from "./layout/ExternalLink"; import { ExternalLink } from "./layout/ExternalLink";
import { InfoBox } from "./InfoBox"; import { InfoBox } from "./InfoBox";
type ChannelClosure = {
channel_id: string;
node_id: string;
reason: string;
timestamp: number;
};
export const OVERLAY = "fixed inset-0 z-50 bg-black/50 backdrop-blur-sm"; export const OVERLAY = "fixed inset-0 z-50 bg-black/50 backdrop-blur-sm";
export const DIALOG_POSITIONER = export const DIALOG_POSITIONER =
"fixed inset-0 z-50 flex items-center justify-center"; "fixed inset-0 z-50 flex items-center justify-center";

View File

@@ -1,12 +1,13 @@
import { Component, For, createEffect, createSignal } from "solid-js"; import { Component, For, createEffect, createSignal } from "solid-js";
import { Event, nip19 } from "nostr-tools"; import { nip19 } from "nostr-tools";
import { Linkify } from "~/components/layout"; import { Linkify } from "~/components/layout";
type NostrEvent = { type NostrEvent = {
content: string; content: string;
created_at: number; created_at: number;
id?: string; id?: string;
tags: string;
}; };
const Note: Component<{ e: NostrEvent }> = (props) => { const Note: Component<{ e: NostrEvent }> = (props) => {
@@ -46,7 +47,7 @@ const Note: Component<{ e: NostrEvent }> = (props) => {
); );
}; };
function filterReplies(event: Event) { function filterReplies(event: NostrEvent) {
// If there's a "p" tag or an "e" tag we want to return false, otherwise true // If there's a "p" tag or an "e" tag we want to return false, otherwise true
for (const tag of event.tags) { for (const tag of event.tags) {
if (tag[0] === "p" || tag[0] === "e") { if (tag[0] === "p" || tag[0] === "e") {
@@ -56,7 +57,7 @@ function filterReplies(event: Event) {
return true; return true;
} }
const Notes: Component<{ notes: Event[] }> = (props) => { const Notes: Component<{ notes: NostrEvent[] }> = (props) => {
return ( return (
<ul class="flex flex-col"> <ul class="flex flex-col">
<For <For

View File

@@ -14,16 +14,13 @@ import {
MutinyWalletSettingStrings, MutinyWalletSettingStrings,
setupMutinyWallet setupMutinyWallet
} from "~/logic/mutinyWalletSetup"; } from "~/logic/mutinyWalletSetup";
import { import { MutinyBalance, MutinyWallet } from "@mutinywallet/mutiny-wasm";
MutinyBalance,
MutinyWallet,
ActivityItem as MutinyActivity
} from "@mutinywallet/mutiny-wasm";
import { ParsedParams } from "~/routes/Scanner"; import { ParsedParams } from "~/routes/Scanner";
import { MutinyTagItem } from "~/utils/tags"; import { MutinyTagItem } from "~/utils/tags";
import { checkBrowserCompatibility } from "~/logic/browserCompatibility"; import { checkBrowserCompatibility } from "~/logic/browserCompatibility";
import eify from "~/utils/eify"; import eify from "~/utils/eify";
import { timeout } from "~/utils/timeout"; import { timeout } from "~/utils/timeout";
import { ActivityItem } from "~/components/Activity";
const MegaStoreContext = createContext<MegaStore>(); const MegaStoreContext = createContext<MegaStore>();
@@ -45,7 +42,7 @@ export type MegaStore = [
dismissed_restore_prompt: boolean; dismissed_restore_prompt: boolean;
wallet_loading: boolean; wallet_loading: boolean;
nwc_enabled: boolean; nwc_enabled: boolean;
activity: MutinyActivity[]; activity: ActivityItem[];
setup_error?: Error; setup_error?: Error;
is_pwa: boolean; is_pwa: boolean;
existing_tab_detected: boolean; existing_tab_detected: boolean;
@@ -85,7 +82,7 @@ export const Provider: ParentComponent = (props) => {
localStorage.getItem("dismissed_restore_prompt") === "true", localStorage.getItem("dismissed_restore_prompt") === "true",
wallet_loading: true, wallet_loading: true,
nwc_enabled: localStorage.getItem("nwc_enabled") === "true", nwc_enabled: localStorage.getItem("nwc_enabled") === "true",
activity: [] as MutinyActivity[], activity: [] as ActivityItem[],
setup_error: undefined as Error | undefined, setup_error: undefined as Error | undefined,
is_pwa: window.matchMedia("(display-mode: standalone)").matches, is_pwa: window.matchMedia("(display-mode: standalone)").matches,
existing_tab_detected: false existing_tab_detected: false
@@ -248,18 +245,7 @@ export const Provider: ParentComponent = (props) => {
actions.fetchUserStatus().then((status) => { actions.fetchUserStatus().then((status) => {
setState({ user_status: status }); setState({ user_status: status });
// Only load node manager when status is approved function handleExisting() {
if (
state.user_status === "approved" &&
!state.mutiny_wallet &&
!state.deleting
) {
console.log("checking for browser compatibility...");
actions.checkBrowserCompat().then((browserIsGood) => {
if (browserIsGood) {
console.log("checking if any other tabs are open");
// 500ms should hopefully be enough time for any tabs to reply
timeout(500).then(() => {
if (state.existing_tab_detected) { if (state.existing_tab_detected) {
setState({ setState({
setup_error: new Error( setup_error: new Error(
@@ -270,9 +256,7 @@ export const Provider: ParentComponent = (props) => {
console.log("running setup node manager..."); console.log("running setup node manager...");
actions actions
.setupMutinyWallet() .setupMutinyWallet()
.then(() => .then(() => console.log("node manager setup done"))
console.log("node manager setup done")
)
.catch((e) => { .catch((e) => {
console.error(e); console.error(e);
setState({ setup_error: eify(e) }); setState({ setup_error: eify(e) });
@@ -285,9 +269,22 @@ export const Provider: ParentComponent = (props) => {
console.log("mutiny_wallet stopped"); console.log("mutiny_wallet stopped");
}; };
} }
});
} }
});
function handleGoodBrowser() {
console.log("checking if any other tabs are open");
// 500ms should hopefully be enough time for any tabs to reply
timeout(500).then(handleExisting);
}
// Only load node manager when status is approved
if (
state.user_status === "approved" &&
!state.mutiny_wallet &&
!state.deleting
) {
console.log("checking for browser compatibility...");
actions.checkBrowserCompat().then(handleGoodBrowser);
} }
}); });
}); });