Skip to content

Commit

Permalink
fix: reset Governance dashboard on wallet switch (#5737)
Browse files Browse the repository at this point in the history
* fix: add account switching for proposal details view

* chore: rename some components

* fix: allow switching on dashboard view

* chore: add explanatory comments

* chore: apply changes per PR review
  • Loading branch information
maxwellmattryan authored and Tuditi committed Feb 1, 2023
1 parent b853b6a commit c5f064a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
@@ -1,9 +1,9 @@
<script lang="ts">
import { CollectiblesDetailsView, CollectiblesGalleryView } from './views'
import { selectedAccountIndex } from '@core/account/stores/selected-account-id.store'
import { selectedAccountIndex } from '@core/account/stores'
import { collectiblesRoute, CollectiblesRoute, collectiblesRouter } from '@core/router'
$: $selectedAccountIndex && $collectiblesRouter.reset()
$: $selectedAccountIndex !== undefined && $collectiblesRouter.reset()
</script>

<div class="w-full h-full flex flex-col flex-nowrap p-8 relative flex-1 bg-gray-50 dark:bg-gray-900">
Expand Down
12 changes: 7 additions & 5 deletions packages/desktop/views/dashboard/governance/Governance.svelte
@@ -1,13 +1,15 @@
<script lang="ts">
import { DetailsView, ProposalsView } from './views'
import { selectedAccount } from '@core/account'
import { GovernanceRoute, governanceRoute } from '@core/router'
import { GovernanceDashboardView, ProposalDetailsView } from './views'
import { selectedAccount, selectedAccountIndex } from '@core/account/stores'
import { GovernanceRoute, governanceRoute, governanceRouter } from '@core/router'
$: $selectedAccountIndex !== undefined && $governanceRouter.reset()
</script>

{#if $selectedAccount}
{#if $governanceRoute === GovernanceRoute.Proposals}
<ProposalsView />
<GovernanceDashboardView />
{:else if $governanceRoute === GovernanceRoute.Details}
<DetailsView />
<ProposalDetailsView />
{/if}
{/if}
Expand Up @@ -10,13 +10,14 @@
FontWeight,
Button,
} from '@ui'
import { openPopup } from '@auxiliary/popup'
import { selectedAccountIndex } from '@core/account/stores'
import { localize } from '@core/i18n'
import { registeredEventIds } from '@contexts/governance/stores'
import { createProposals } from '@contexts/governance/utils'
import { localize } from '@core/i18n'
import { openPopup } from '@auxiliary/popup'
let promise = createProposals()
$: $registeredEventIds, (promise = createProposals())
$: $selectedAccountIndex, $registeredEventIds, (promise = createProposals())
function handleAddProposal(): void {
openPopup({
Expand Down
Expand Up @@ -106,10 +106,14 @@
async function setVotingEventPayload(eventId: string): Promise<void> {
const event = await getVotingEvent(eventId)
if (event?.data?.payload?.type === ParticipationEventType.Voting) {
votingPayload = event.data.payload
if (event) {
if (event.data?.payload?.type === ParticipationEventType.Voting) {
votingPayload = event.data.payload
} else {
throw new Error('Event is a staking event')
}
} else {
throw new Error('Event is a staking event!')
throw new Error('Event not found')
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop/views/dashboard/governance/views/index.js
@@ -1,2 +1,2 @@
export { default as DetailsView } from './DetailsView.svelte'
export { default as ProposalsView } from './ProposalsView.svelte'
export { default as GovernanceDashboardView } from './GovernanceDashboardView.svelte'
export { default as ProposalDetailsView } from './ProposalDetailsView.svelte'

0 comments on commit c5f064a

Please sign in to comment.