Skip to content

Commit

Permalink
Merge branch 'master' into add-hibernation
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e authored Nov 15, 2023
2 parents 5a164e2 + b9bdfde commit e5b7d79
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 22 deletions.
97 changes: 80 additions & 17 deletions src/composables/useClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export function useClient() {
const { notify } = useFlashNotification();
const { notifyModal } = useModalNotification();
const { isGnosisSafe } = useGnosis();
const { mixpanel } = useMixpanel();
const { web3 } = useWeb3();
const auth = getInstance();
const route = useRoute();
Expand Down Expand Up @@ -36,14 +37,16 @@ export function useClient() {

async function sendEIP712(space: { id: string }, type: string, payload: any) {
let plugins = {};
const client = clientEIP712;

if (
payload.metadata?.plugins &&
Object.keys(payload.metadata?.plugins).length !== 0
)
plugins = payload.metadata.plugins;
const client = clientEIP712;

if (type === 'create-proposal') {
return client.proposal(auth.web3, web3.value.account, {
const receipt = await client.proposal(auth.web3, web3.value.account, {
space: space.id,
type: payload.type,
title: payload.name,
Expand All @@ -56,19 +59,36 @@ export function useClient() {
plugins: JSON.stringify(plugins),
app: DEFINED_APP
});

mixpanel.track('Propose', {
space: space.id
});

return receipt;
} else if (type === 'update-proposal') {
return client.updateProposal(auth.web3, web3.value.account, {
proposal: payload.id,
const receipt = await client.updateProposal(
auth.web3,
web3.value.account,
{
proposal: payload.id,
space: space.id,
type: payload.type,
title: payload.name,
body: payload.body,
discussion: payload.discussion,
choices: payload.choices,
plugins: JSON.stringify(plugins)
}
);

mixpanel.track('Update proposal', {
space: space.id,
type: payload.type,
title: payload.name,
body: payload.body,
discussion: payload.discussion,
choices: payload.choices,
plugins: JSON.stringify(plugins)
proposalId: payload.proposal.id
});

return receipt;
} else if (type === 'vote') {
return client.vote(auth.web3, web3.value.account, {
const receipt = await client.vote(auth.web3, web3.value.account, {
space: space.id,
proposal: payload.proposal.id,
type: payload.proposal.type,
Expand All @@ -77,31 +97,74 @@ export function useClient() {
app: DEFINED_APP,
reason: payload.reason
});

mixpanel.track('Vote', {
space: space.id,
proposalId: payload.proposal.id
});

return receipt;
} else if (type === 'delete-proposal') {
return client.cancelProposal(auth.web3, web3.value.account, {
const receipt = await client.cancelProposal(
auth.web3,
web3.value.account,
{
space: space.id,
proposal: payload.proposal.id
}
);

mixpanel.track('Delete proposal', {
space: space.id,
proposal: payload.proposal.id
proposalId: payload.proposal.id
});

return receipt;
} else if (type === 'settings') {
return client.space(auth.web3, web3.value.account, {
const receipt = await client.space(auth.web3, web3.value.account, {
space: space.id,
settings: JSON.stringify(payload)
});

mixpanel.track('Update space settings', {
space: space.id
});

return receipt;
} else if (type === 'delete-space') {
return client.deleteSpace(auth.web3, web3.value.account, {
const receipt = await client.deleteSpace(auth.web3, web3.value.account, {
space: space.id
});

mixpanel.track('Delete space', {
space: space.id
});

return receipt;
} else if (type === 'set-statement') {
return client.statement(auth.web3, web3.value.account, {
const receipt = await client.statement(auth.web3, web3.value.account, {
space: space.id,
about: payload.about,
statement: payload.statement
});

mixpanel.track('Set statement', {
space: space.id
});

return receipt;
} else if (type === 'flag-proposal') {
return client.flagProposal(auth.web3, web3.value.account, {
const receipt = await client.flagProposal(auth.web3, web3.value.account, {
space: space.id,
proposal: payload.proposal.id
});

mixpanel.track('Flag proposal', {
space: space.id,
proposalId: payload.proposal.id
});

return receipt;
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/views/SpaceSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,16 @@ const {
cancel: cancelDelete
} = useConfirmDialog();
const isViewOnly = computed(() => {
return !(isSpaceController.value || isSpaceAdmin.value);
});
onBeforeRouteLeave(async () => {
if (hasFormChanged.value) {
if (hasFormChanged.value && !isViewOnly.value) {
const { data } = await openConfirmLeave();
if (!data) return false;
}
});
const isViewOnly = computed(() => {
return !(isSpaceController.value || isSpaceAdmin.value);
});
</script>

<template>
Expand Down

0 comments on commit e5b7d79

Please sign in to comment.