Skip to content

Commit

Permalink
fix: watch proposal id, but ignore if space is unresolved (#624)
Browse files Browse the repository at this point in the history
Because space data and proposal ID are resolved in different stages
we have to avoid fetching new proposal if we have mismatched data
(proposalId from new space, space data from new space).

Previously I changed it so we only watch space data and read proposalId
on demand, but it introduced a bug that if only proposalId changes
it wouldn't be triggered at all.

Now we watch both space data and proposalId, but only act when we know
that space data was resolved.
  • Loading branch information
Sekhmet authored Aug 13, 2024
1 parent 6474faf commit c8334dc
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions apps/ui/src/views/Proposal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,17 @@ watch(
);
watch(
[networkId, spaceAddress],
async ([networkId, spaceAddress]) => {
// NOTE: do not watch id as it's not updated in-sync with networkId and spaceAddress (those are resolved async)
[networkId, spaceAddress, id],
async ([networkId, spaceAddress, id]) => {
if (!resolved.value) {
// NOTE: id's not updated in-sync with networkId and spaceAddress (those are resolved async)
// we want to ignore updates if the values are not resolved yet
return;
}
if (!networkId || !spaceAddress) return;
proposalsStore.fetchProposal(spaceAddress, id.value, networkId);
proposalsStore.fetchProposal(spaceAddress, id, networkId);
},
{ immediate: true }
);
Expand Down

0 comments on commit c8334dc

Please sign in to comment.