Compare commits

..

1 Commits

Author SHA1 Message Date
Valtteri Karesto
7f8f47cb14 Fix modal showing up bug, issue #99 2022-03-09 13:27:42 +02:00
3 changed files with 19 additions and 5 deletions

View File

@@ -87,9 +87,6 @@ By default `@monaco-editor/react` was using 0.29.? version of Monaco editor. @co
Monaco Languageclient related stuff is found from `./utils/languageClient.ts`. Basically we're connecting the editor to clangd language server which lives on separate backend. That project can be found from https://github.com/eqlabs/xrpl-hooks-compiler/. If you need access to that project ask permissions from @vbar (Vaclav Barta) on GitHub. Monaco Languageclient related stuff is found from `./utils/languageClient.ts`. Basically we're connecting the editor to clangd language server which lives on separate backend. That project can be found from https://github.com/eqlabs/xrpl-hooks-compiler/. If you need access to that project ask permissions from @vbar (Vaclav Barta) on GitHub.
### Language server hover messages
If you want to extend hover messages provided by language-server you can add extra docs to `xrpl-hooks-docs/md/` folder. Just make sure the filename is matching with the error code that comes from language server. So lets say you want to add extra documentation for `hooks-func-addr-taken` check create new file called `hooks-func-addr-taken.md` and then remember to import and export it on `docs.ts` file with same logic as the other files.
## Global state management ## Global state management
Global state management is handled with library called Valtio (https://github.com/pmndrs/valtio). Initial state can be found from `./state/index.ts` file. All the actions which updates the state is found under `./state/actions/` folder. Global state management is handled with library called Valtio (https://github.com/pmndrs/valtio). Initial state can be found from `./state/index.ts` file. All the actions which updates the state is found under `./state/actions/` folder.

View File

@@ -15,6 +15,7 @@ import state from "../state";
import TimeAgo from "javascript-time-ago"; import TimeAgo from "javascript-time-ago";
import en from "javascript-time-ago/locale/en.json"; import en from "javascript-time-ago/locale/en.json";
import { useSnapshot } from "valtio";
TimeAgo.addDefaultLocale(en); TimeAgo.addDefaultLocale(en);
function MyApp({ Component, pageProps: { session, ...pageProps } }: AppProps) { function MyApp({ Component, pageProps: { session, ...pageProps } }: AppProps) {
@@ -25,15 +26,29 @@ function MyApp({ Component, pageProps: { session, ...pageProps } }: AppProps) {
const origin = "https://xrpl-hooks-ide.vercel.app"; // TODO: Change when site is deployed const origin = "https://xrpl-hooks-ide.vercel.app"; // TODO: Change when site is deployed
const shareImg = "/share-image.png"; const shareImg = "/share-image.png";
const snap = useSnapshot(state);
useEffect(() => { useEffect(() => {
if (gistId && router.isReady) { if (gistId && router.isReady) {
fetchFiles(gistId); fetchFiles(gistId);
} else { } else {
if (!gistId && router.isReady && !router.pathname.includes("/sign-in")) { if (
!gistId &&
router.isReady &&
!router.pathname.includes("/sign-in") &&
!snap.files.length &&
!snap.mainModalShowed
) {
state.mainModalOpen = true; state.mainModalOpen = true;
state.mainModalShowed = true;
} }
} }
}, [gistId, router.isReady, router.pathname]); }, [
gistId,
router.isReady,
router.pathname,
snap.files,
snap.mainModalShowed,
]);
return ( return (
<> <>

View File

@@ -65,6 +65,7 @@ export interface IState {
client: XrplClient | null; client: XrplClient | null;
clientStatus: "offline" | "online"; clientStatus: "offline" | "online";
mainModalOpen: boolean; mainModalOpen: boolean;
mainModalShowed: boolean;
accounts: IAccount[]; accounts: IAccount[];
} }
@@ -93,6 +94,7 @@ let initialState: IState = {
client: null, client: null,
clientStatus: "offline" as "offline", clientStatus: "offline" as "offline",
mainModalOpen: false, mainModalOpen: false,
mainModalShowed: false,
accounts: [], accounts: [],
}; };