Skip to content

Commit

Permalink
fix: update privacy checks to match new type (#1088)
Browse files Browse the repository at this point in the history
* fix: update privacy checks to match new type

Old checks expected no-privacy proposals to use null, but now it's
string 'none'.

We have to update checks to match.

Regression form #954

* fix: map backend from "" to "none"
  • Loading branch information
Sekhmet authored Jan 9, 2025
1 parent 8f4f6d5 commit ca1a032
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion apps/ui/src/components/Modal/Vote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ watchEffect(async () => {
v-text="formattedVotingPower"
/>
</dl>
<div v-if="!proposal.privacy" class="s-box">
<div v-if="proposal.privacy === 'none'" class="s-box">
<UiForm
v-model="form"
:error="formErrors"
Expand Down
6 changes: 3 additions & 3 deletions apps/ui/src/components/ProposalResults.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ onMounted(() => {
</div>
<div
v-else-if="
!!props.proposal.privacy &&
props.proposal.privacy !== 'none' &&
props.proposal.state === 'active' &&
withDetails
"
Expand Down Expand Up @@ -193,7 +193,7 @@ onMounted(() => {
v-text="proposal.choices[result.choice - 1]"
/>
<IH-lock-closed
v-if="!!proposal.privacy && !proposal.completed"
v-if="proposal.privacy !== 'none' && !proposal.completed"
class="size-[16px] shrink-0"
/>
<template v-else>
Expand Down Expand Up @@ -236,7 +236,7 @@ onMounted(() => {
</div>
</div>
<div
v-else-if="!props.proposal.privacy || props.proposal.completed"
v-else-if="props.proposal.privacy === 'none' || props.proposal.completed"
class="h-full flex items-center"
>
<div
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/src/components/ProposalVote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const isEditable = computed(() => {
@click="$emit('enterEditMode')"
>
<div
v-if="proposal.privacy"
v-if="proposal.privacy !== 'none'"
class="flex space-x-2 items-center grow truncate text-skin-link"
>
<IH-lock-closed class="size-[16px] shrink-0" />
Expand Down
4 changes: 3 additions & 1 deletion apps/ui/src/components/ProposalVoteApproval.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const emit = defineEmits<{
}>();
const selectedChoices = ref<ApprovalChoice>(
(!props.proposal.privacy && (props.defaultChoice as ApprovalChoice)) || []
(props.proposal.privacy === 'none' &&
(props.defaultChoice as ApprovalChoice)) ||
[]
);
function toggleSelectedChoice(choice: number) {
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/src/components/ProposalVoteChoice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ withDefaults(

<template>
<div
v-if="!!proposal.privacy && !proposal.completed"
v-if="proposal.privacy !== 'none' && !proposal.completed"
class="flex gap-1 items-center"
>
<span class="text-skin-heading leading-[22px]">Encrypted choice</span>
Expand Down
3 changes: 2 additions & 1 deletion apps/ui/src/components/ProposalVoteRankedChoice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const emit = defineEmits<{
}>();
const selectedChoices = ref<RankedChoice>(
(!props.proposal.privacy && (props.defaultChoice as RankedChoice)) ||
(props.proposal.privacy === 'none' &&
(props.defaultChoice as RankedChoice)) ||
props.proposal.choices.map((_, i) => i + 1)
);
</script>
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/src/components/ProposalVoteSingleChoice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const emit = defineEmits<{
}>();
const selectedChoice = ref<number | null>(
(!props.proposal.privacy && (props.defaultChoice as number)) || null
(props.proposal.privacy === 'none' && (props.defaultChoice as number)) || null
);
</script>

Expand Down
4 changes: 3 additions & 1 deletion apps/ui/src/components/ProposalVoteWeighted.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ defineEmits<{
}>();
const selectedChoices = ref<WeightedChoice>(
(!props.proposal.privacy && (props.defaultChoice as WeightedChoice)) || {}
(props.proposal.privacy === 'none' &&
(props.defaultChoice as WeightedChoice)) ||
{}
);
function increaseChoice(index: number) {
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/src/networks/offchain/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ function formatProposal(proposal: ApiProposal, networkId: NetworkID): Proposal {
tx: '',
execution_tx: null,
veto_tx: null,
privacy: proposal.privacy,
privacy: proposal.privacy || 'none',
flagged: proposal.flagged
};
}
Expand Down
3 changes: 1 addition & 2 deletions apps/ui/src/networks/offchain/api/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
DelegationType,
NetworkID,
Privacy,
SpaceMetadataLabel,
VoteType
} from '@/types';
Expand Down Expand Up @@ -126,7 +125,7 @@ export type ApiProposal = {
created: number;
updated: number | null;
votes: number;
privacy: Privacy;
privacy: 'shutter' | '';
plugins: Record<string, any>;
flagged: boolean;
};
Expand Down

0 comments on commit ca1a032

Please sign in to comment.