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

Deploy fixes #1435

Merged
merged 5 commits into from
Oct 31, 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
16 changes: 10 additions & 6 deletions apps/dapp/pages/dao/[address]/[[...slug]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
useDaoInfoContext,
useDaoNavHelpers,
} from '@dao-dao/stateless'
import { ActionKey, DaoPageMode } from '@dao-dao/types'
import { ActionKey, DaoPageMode, DaoTabId } from '@dao-dao/types'
import {
SITE_URL,
getDaoPath,
Expand Down Expand Up @@ -150,12 +150,16 @@ const InnerDaoHome = () => {
useFollowingDaos(daoInfo.chainId)
const following = isFollowing(daoInfo.coreAddress)

const tabs = useDaoTabs()
const firstTabId = tabs[0].id
const loadingTabs = useDaoTabs()
// Just a type-check because some tabs are loaded at the beginning.
const tabs = loadingTabs.loading ? undefined : loadingTabs.data
// Default to proposals tab for type-check, but should never happen as some
// tabs are loaded at the beginning.
const firstTabId = tabs?.[0].id || DaoTabId.Proposals

// Pre-fetch tabs.
useEffect(() => {
tabs.forEach((tab) => {
tabs?.forEach((tab) => {
router.prefetch(getDaoPath(daoInfo.coreAddress, tab.id))
})
}, [daoInfo.coreAddress, getDaoPath, router, tabs])
Expand All @@ -171,7 +175,7 @@ const InnerDaoHome = () => {
}, [daoInfo.coreAddress, getDaoPath, router, slug.length, firstTabId])

const tabId =
slug.length > 0 && tabs.some(({ id }) => id === slug[0])
slug.length > 0 && tabs?.some(({ id }) => id === slug[0])
? slug[0]
: // If tab is invalid, default to first tab.
firstTabId
Expand All @@ -197,7 +201,7 @@ const InnerDaoHome = () => {
onSelectTabId={onSelectTabId}
rightSidebarContent={<ProfileDaoHomeCard />}
selectedTabId={tabId}
tabs={tabs}
tabs={tabs || []}
/>
)
}
Expand Down
16 changes: 10 additions & 6 deletions apps/sda/pages/[address]/[[...slug]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,24 @@ import {
useDaoInfoContext,
useDaoNavHelpers,
} from '@dao-dao/stateless'
import { DaoPageMode } from '@dao-dao/types'
import { DaoPageMode, DaoTabId } from '@dao-dao/types'
import { SITE_URL, getDaoPath } from '@dao-dao/utils'

const DaoHomePage: NextPage = () => {
const router = useRouter()
const { coreAddress } = useDaoInfoContext()
const { getDaoPath } = useDaoNavHelpers()

const tabs = useDaoTabs()
const firstTabId = tabs[0].id
const loadingTabs = useDaoTabs()
// Just a type-check because some tabs are loaded at the beginning.
const tabs = loadingTabs.loading ? undefined : loadingTabs.data
// Default to proposals tab for type-check, but should never happen as some
// tabs are loaded at the beginning.
const firstTabId = tabs?.[0].id || DaoTabId.Proposals

// Pre-fetch tabs.
useEffect(() => {
tabs.forEach((tab) => {
tabs?.forEach((tab) => {
router.prefetch(getDaoPath(coreAddress, tab.id))
})
}, [coreAddress, getDaoPath, router, tabs])
Expand All @@ -45,15 +49,15 @@ const DaoHomePage: NextPage = () => {
}, [coreAddress, getDaoPath, router, slug.length, firstTabId])

const selectedTabId =
slug.length > 0 && tabs.some(({ id }) => id === slug[0])
slug.length > 0 && tabs?.some(({ id }) => id === slug[0])
? slug[0]
: // If tab is invalid, default to first tab.
firstTabId

return (
<DaoSdaWrappedTab
SuspenseLoader={SuspenseLoader}
allTabs={tabs}
allTabs={tabs || []}
rightSidebarContent={<ProfileDaoHomeCard />}
tabId={selectedTabId}
/>
Expand Down
3 changes: 2 additions & 1 deletion packages/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@
"counterpartyBalanceInsufficient": "The counterparty's balance of {{amount}} ${{tokenSymbol}} is insufficient. They may be unable to complete this swap.",
"daoAccountNotFound": "The DAO account could not be found for this chain.",
"daoAndSubDaosAlreadyOnV2": "This DAO (and all of its SubDAOs, if it has any) have already been upgraded.",
"daoCreationIncomplete": "DAO creation is incomplete. Ensure all required fields have been filled out.",
"daoFeatureUnsupported": "{{name}} does not support {{feature}} yet.",
"daoIsInactive_absolute_one": "This DAO is inactive. Proposals cannot be created until {{count}} token is staked.",
"daoIsInactive_absolute_other": "This DAO is inactive. Proposals cannot be created until {{count}} tokens are staked.",
Expand Down Expand Up @@ -605,6 +606,7 @@
"tokenAddress": "Token address",
"tokenContractAddressTitle": "Token contract address",
"tokenDefinition": "Token definition",
"tokenIdentifier": "Token identifier",
"tokenInfo": "Token info",
"tokenInstructions": "Token instructions",
"tokenSwapCreateInstructions": "In this step, you will create the token swap. This creation step describes how many funds each party needs to send for the swap to complete. <2>No funds will be transferred at this time.</2>",
Expand Down Expand Up @@ -1438,7 +1440,6 @@
"timeRemaining": "Time remaining",
"title": "Title",
"token": "Token",
"tokenIdentifier": "Token identifier",
"tokenSwap": "Token Swap",
"topAbsolute": "Top {{count}}",
"topPercent": "Top {{percent}}%",
Expand Down
31 changes: 19 additions & 12 deletions packages/stateful/command/contexts/generic/dao.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export const makeGenericDaoContext: CommandModalContextMaker<{
const { t } = useTranslation()
const { getDaoPath, getDaoProposalPath, router } = useDaoNavHelpers()
const { coreVersion } = useDaoInfoContext()
const tabs = useDaoTabs()
const loadingTabs = useDaoTabs({
suspendWhileLoadingOverride: false,
})

const { isFollowing, setFollowing, setUnfollowing, updatingFollowing } =
useFollowingDaos(chainId)
Expand Down Expand Up @@ -72,7 +74,9 @@ export const makeGenericDaoContext: CommandModalContextMaker<{
const routes = [
daoPageHref,
createProposalHref,
...tabs.map(({ id }) => getDaoPath(coreAddress, id)),
...(loadingTabs.loading
? []
: loadingTabs.data.map(({ id }) => getDaoPath(coreAddress, id))),
]
useDeepCompareEffect(() => {
routes.forEach((url) => router.prefetch(url))
Expand Down Expand Up @@ -153,16 +157,19 @@ export const makeGenericDaoContext: CommandModalContextMaker<{
setNavigatingToHref(href)
}
},
items: tabs.map(({ id, label, Icon }) => {
const href = getDaoPath(coreAddress, id)

return {
name: label,
Icon,
href,
loading: navigatingToHref === href,
loading: loadingTabs.loading || loadingTabs.updating,
items: (loadingTabs.loading ? [] : loadingTabs.data).map(
({ id, label, Icon }) => {
const href = getDaoPath(coreAddress, id)

return {
name: label,
Icon,
href,
loading: navigatingToHref === href,
}
}
}),
),
}

const subDaosSection: CommandModalContextSection<CommandModalDaoInfo> = {
Expand All @@ -174,7 +181,7 @@ export const makeGenericDaoContext: CommandModalContextMaker<{
dao,
})
),
loading: subDaosLoading.loading,
loading: subDaosLoading.loading || subDaosLoading.updating,
items: subDaosLoading.loading
? []
: subDaosLoading.data.map(
Expand Down
4 changes: 2 additions & 2 deletions packages/stateful/components/SdaLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ export const SdaLayout = ({ children }: { children: ReactNode }) => {
daoCreatedCardPropsAtom
)

const tabs = useDaoTabs()
const loadingTabs = useDaoTabs()

return (
<StatelessSdaLayout
connect={connect}
connectWalletButton={<ConnectWallet variant="secondary" />}
connected={isWalletConnected}
navigationProps={{
tabs,
tabs: loadingTabs.loading ? [] : loadingTabs.data,
LinkWrapper,
version: '2.0',
compact,
Expand Down
Loading
Loading