Skip to content

Commit

Permalink
fixup! feat: save poll drafts from filled forms, created and closed p…
Browse files Browse the repository at this point in the history
…olls

Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Oct 18, 2024
1 parent c22c94f commit c4b4627
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
8 changes: 1 addition & 7 deletions src/components/NewMessage/NewMessagePollEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@
</NcCheckboxRadioSwitch>
</div>
<template #actions>
<NcButton type="tertiary" @click="emit('close')">
{{ t('spreed', 'Dismiss') }}
</NcButton>
<NcActions v-if="supportPollDrafts" force-menu>
<NcActionButton v-if="isModerator" :disabled="!isFilled" @click="createPollDraft">
<template #icon>
Expand Down Expand Up @@ -205,13 +202,10 @@ function fillPollForm(payload: createPollParams) {
* Saves a poll draft for this conversation
*/
async function createPollDraft() {
const poll = await pollsStore.createPollDraft({
await pollsStore.createPollDraft({
token: props.token,
form: pollForm,
})
if (poll) {
showSuccess(t('spreed', 'Poll draft has been saved'))
}
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/stores/polls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import debounce from 'debounce'
import { defineStore } from 'pinia'
import Vue from 'vue'

import { showError, showInfo, TOAST_PERMANENT_TIMEOUT } from '@nextcloud/dialogs'
import { showError, showInfo, showSuccess, TOAST_PERMANENT_TIMEOUT } from '@nextcloud/dialogs'
import { t } from '@nextcloud/l10n'

import {
Expand Down Expand Up @@ -141,8 +141,11 @@ export const usePollsStore = defineStore('polls', {
try {
const response = await createPollDraft({ token, ...form })
this.addPollDraft({ token, draft: response.data.ocs.data })

showSuccess(t('spreed', 'Poll draft has been saved'))
return response.data.ocs.data
} catch (error) {
showError(t('spreed', 'An error occurred while saving the draft'))
console.error(error)
}
},
Expand Down

0 comments on commit c4b4627

Please sign in to comment.