replace eslint/prettier with rome
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
import { getActiveAccount } from '@utils/storage';
|
||||
import { getActiveAccount } from "@utils/storage";
|
||||
|
||||
import useSWR from 'swr';
|
||||
import useSWR from "swr";
|
||||
|
||||
const fetcher = () => getActiveAccount();
|
||||
|
||||
export function useActiveAccount() {
|
||||
const { data, error, isLoading } = useSWR('activeAcount', fetcher);
|
||||
const { data, error, isLoading } = useSWR("activeAcount", fetcher);
|
||||
|
||||
return {
|
||||
account: data,
|
||||
isLoading,
|
||||
isError: error,
|
||||
};
|
||||
return {
|
||||
account: data,
|
||||
isLoading,
|
||||
isError: error,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
const getOnLineStatus = () =>
|
||||
typeof navigator !== 'undefined' && typeof navigator.onLine === 'boolean' ? navigator.onLine : true;
|
||||
typeof navigator !== "undefined" && typeof navigator.onLine === "boolean"
|
||||
? navigator.onLine
|
||||
: true;
|
||||
|
||||
export function useNetworkStatus() {
|
||||
const [status, setStatus] = useState(getOnLineStatus());
|
||||
const [status, setStatus] = useState(getOnLineStatus());
|
||||
|
||||
const setOnline = () => setStatus(true);
|
||||
const setOffline = () => setStatus(false);
|
||||
const setOnline = () => setStatus(true);
|
||||
const setOffline = () => setStatus(false);
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener('online', setOnline);
|
||||
window.addEventListener('offline', setOffline);
|
||||
useEffect(() => {
|
||||
window.addEventListener("online", setOnline);
|
||||
window.addEventListener("offline", setOffline);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('online', setOnline);
|
||||
window.removeEventListener('offline', setOffline);
|
||||
};
|
||||
}, []);
|
||||
return () => {
|
||||
window.removeEventListener("online", setOnline);
|
||||
window.removeEventListener("offline", setOffline);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return status;
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
// `usePageContext` allows us to access `pageContext` in any React component.
|
||||
// See https://vite-plugin-ssr.com/pageContext-anywhere
|
||||
import type { PageContext } from '@renderer/types';
|
||||
import type { PageContext } from "@renderer/types";
|
||||
|
||||
import { createContext, useContext } from 'react';
|
||||
import { createContext, useContext } from "react";
|
||||
|
||||
const Context = createContext<PageContext>(undefined as any);
|
||||
|
||||
export function PageContextProvider({
|
||||
pageContext,
|
||||
children,
|
||||
pageContext,
|
||||
children,
|
||||
}: {
|
||||
pageContext: PageContext;
|
||||
children: React.ReactNode;
|
||||
pageContext: PageContext;
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return <Context.Provider value={pageContext}>{children}</Context.Provider>;
|
||||
return <Context.Provider value={pageContext}>{children}</Context.Provider>;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line react-refresh/only-export-components
|
||||
export function usePageContext() {
|
||||
const pageContext = useContext(Context);
|
||||
return pageContext;
|
||||
const pageContext = useContext(Context);
|
||||
return pageContext;
|
||||
}
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
import { METADATA_SERVICE } from '@stores/constants';
|
||||
import { METADATA_SERVICE } from "@stores/constants";
|
||||
|
||||
import { createPleb, getPleb } from '@utils/storage';
|
||||
import { createPleb, getPleb } from "@utils/storage";
|
||||
|
||||
import useSWR from 'swr';
|
||||
import useSWR from "swr";
|
||||
|
||||
const fetcher = async (pubkey: string) => {
|
||||
const result = await getPleb(pubkey);
|
||||
if (result) {
|
||||
const metadata = JSON.parse(result['metadata']);
|
||||
result['content'] = metadata.content;
|
||||
delete result['metadata'];
|
||||
const result = await getPleb(pubkey);
|
||||
if (result) {
|
||||
const metadata = JSON.parse(result["metadata"]);
|
||||
result["content"] = metadata.content;
|
||||
result["metadata"] = undefined;
|
||||
|
||||
return result;
|
||||
} else {
|
||||
const result = await fetch(`${METADATA_SERVICE}/${pubkey}/metadata.json`);
|
||||
const resultJSON = await result.json();
|
||||
const cache = await createPleb(pubkey, resultJSON);
|
||||
return result;
|
||||
} else {
|
||||
const result = await fetch(`${METADATA_SERVICE}/${pubkey}/metadata.json`);
|
||||
const resultJSON = await result.json();
|
||||
const cache = await createPleb(pubkey, resultJSON);
|
||||
|
||||
if (cache) {
|
||||
return resultJSON;
|
||||
}
|
||||
}
|
||||
if (cache) {
|
||||
return resultJSON;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export function useProfile(pubkey: string) {
|
||||
const { data, error, isLoading } = useSWR(pubkey, fetcher);
|
||||
const { data, error, isLoading } = useSWR(pubkey, fetcher);
|
||||
|
||||
return {
|
||||
user: data ? JSON.parse(data.content ? data.content : null) : null,
|
||||
isLoading,
|
||||
isError: error,
|
||||
};
|
||||
return {
|
||||
user: data ? JSON.parse(data.content ? data.content : null) : null,
|
||||
isLoading,
|
||||
isError: error,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user