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

fix: flickering page when renaming #187

Merged
merged 7 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Bug fixes

- [#187](https://github.com/alleslabs/celatone-frontend/pull/187) Fix renaming list flicker to the all lists for a second
- [#184](https://github.com/alleslabs/celatone-frontend/pull/184) Fix next seo to use default seo
- [#186](https://github.com/alleslabs/celatone-frontend/pull/186) Fix logo navigation
- [#185](https://github.com/alleslabs/celatone-frontend/pull/185) Fix sentry in next.config.js
Expand Down
3 changes: 2 additions & 1 deletion src/lib/components/modal/list/EditListName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ export function EditListNameModal({
handleSave();
if (reroute)
navigate({
pathname: `/contract-list/${formatSlugName(listName)}`,
pathname: "/contract-list/[slug]",
query: { slug: formatSlugName(listName) },
replace: true,
});
}}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/pages/contract-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const AllContractListsPage = observer(() => {
const contractLists = [useInstantiatedMockInfoByMe(), ...getContractLists()];

const handleListSelect = (slug: string) => {
navigate({ pathname: `/contract-list/${slug}` });
navigate({ pathname: "/contract-list/[slug]", query: { slug } });
};

return (
Expand Down
9 changes: 6 additions & 3 deletions src/lib/pages/contract-list/slug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ const ContractsByList = observer(() => {
: getContractLists().find((item) => item.slug === listSlug);

useEffect(() => {
if (isHydrated && contractListInfo === undefined) {
navigate({ pathname: "/contract-list" });
}
// TODO: find a better approach?
const timeoutId = setTimeout(() => {
if (isHydrated && contractListInfo === undefined)
navigate({ pathname: "/contract-list" });
}, 100);
return () => clearTimeout(timeoutId);
}, [contractListInfo, isHydrated, navigate]);

if (!contractListInfo) return null;
Expand Down
13 changes: 11 additions & 2 deletions src/lib/pages/instantiate/component/InstantiateOffchainForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import { useForm } from "react-hook-form";
import { useInternalNavigate } from "lib/app-provider";
import { OffChainForm } from "lib/components/OffChainForm";
import type { OffchainDetail } from "lib/components/OffChainForm";
import { INSTANTIATED_LIST_NAME } from "lib/data";
import { useContractStore } from "lib/hooks";
import { useUserKey } from "lib/hooks/useUserKey";
import type { ContractAddr, HumanAddr, LVPair } from "lib/types";
import { formatSlugName } from "lib/utils";

interface InstantiateOffChainFormProps {
title?: string;
Expand All @@ -30,6 +32,7 @@ export const InstantiateOffChainForm = observer(
const navigate = useInternalNavigate();
const { updateContractLocalInfo } = useContractStore();
const userKey = useUserKey();
const instantiatedListSlug = formatSlugName(INSTANTIATED_LIST_NAME);

const {
control,
Expand Down Expand Up @@ -72,7 +75,10 @@ export const InstantiateOffChainForm = observer(
data.tags,
data.lists
);
navigate({ pathname: "/contract-list/instantiated-by-me" });
navigate({
pathname: "/contract-list/[slug]",
query: { slug: instantiatedListSlug },
});
})();
};

Expand Down Expand Up @@ -109,7 +115,10 @@ export const InstantiateOffChainForm = observer(
w="128px"
variant="outline-gray"
onClick={() =>
navigate({ pathname: "/contract-list/instantiated-by-me" })
navigate({
pathname: "/contract-list/[slug]",
query: { slug: instantiatedListSlug },
})
}
>
Skip
Expand Down