Skip to content

Commit

Permalink
fixup! feat: browse poll drafts from poll editor and shared items
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Oct 18, 2024
1 parent c4b4627 commit f8e5bb0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
6 changes: 5 additions & 1 deletion src/components/NewMessage/NewMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
:token="token"
@close="togglePollEditor" />

<PollDraftHandler v-if="showPollDraftHandler"
<PollDraftHandler v-if="canCreatePollDrafts && showPollDraftHandler"
:token="token"
@close="togglePollDraftHandler" />

Expand Down Expand Up @@ -394,6 +394,10 @@ export default {
&& this.conversation.type !== CONVERSATION.TYPE.NOTE_TO_SELF
},

canCreatePollDrafts() {
return hasTalkFeature(this.token, 'talk-polls-drafts') && this.$store.getters.isModerator
},

currentConversationIsJoined() {
return this.$store.getters.currentConversationIsJoined
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/NewMessage/NewMessagePollEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ function openPollDraftHandler() {
&__wrapper {
display: flex;
align-items: flex-end;
gap: 4px;
gap: var(--default-grid-baseline);
}

&__caption {
Expand Down
9 changes: 2 additions & 7 deletions src/components/PollViewer/PollDraftHandler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import EmptyView from '../EmptyView.vue'
import Poll from '../MessagesList/MessagesGroup/Message/MessagePart/Poll.vue'

import { useStore } from '../../composables/useStore.js'
import { hasTalkFeature } from '../../services/CapabilitiesManager.ts'
import { EventBus } from '../../services/EventBus.js'
import { usePollsStore } from '../../stores/polls.ts'

Expand All @@ -60,17 +59,13 @@ const emit = defineEmits<{
(event: 'close'): void,
}>()

const supportPollDrafts = hasTalkFeature(props.token, 'talk-polls-drafts')
const store = useStore()
const pollsStore = usePollsStore()
/**
* Receive poll drafts for the current conversation as owner/moderator
*/
const isModerator = computed(() => (store.getters as unknown).isModerator)
if (supportPollDrafts && isModerator.value) {
pollsStore.getPollDrafts(props.token)
}
const pollDrafts = computed(() => supportPollDrafts ? pollsStore.getDrafts(props.token) : [])
pollsStore.getPollDrafts(props.token)
const pollDrafts = computed(() => pollsStore.getDrafts(props.token))

/**
* Opens poll editor pre-filled from the draft
Expand Down
10 changes: 3 additions & 7 deletions src/components/RightSidebar/SharedItems/SharedItemsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<LoadingComponent v-if="loading" class="shared-items-tab__loading" />

<template v-else>
<NcButton v-if="supportPollDrafts && isModerator"
<NcButton v-if="canCreatePollDrafts"
wide
@click="openPollDraftHandler">
<template #icon>
Expand Down Expand Up @@ -160,12 +160,8 @@ export default {
return this.$store.getters.conversation(this.token)
},

supportPollDrafts() {
return hasTalkFeature(this.token, 'talk-polls-drafts')
},

isModerator() {
return this.$store.getters.isModerator
canCreatePollDrafts() {
return hasTalkFeature(this.token, 'talk-polls-drafts') && this.$store.getters.isModerator
},

loading() {
Expand Down

0 comments on commit f8e5bb0

Please sign in to comment.