refs #3730 Fix to set poll expire

This commit is contained in:
AkiraFukushima 2022-11-04 21:39:52 +09:00
parent 14b9b81ffe
commit 07cb9dcb73
No known key found for this signature in database
GPG Key ID: B6E51BAC4DE1A957
2 changed files with 16 additions and 4 deletions

View File

@ -31,7 +31,8 @@
<Poll
v-if="openPoll"
v-model:polls="polls"
v-model:expire="pollExpire"
:expire="pollExpire"
@update:expire="updatePollExpire"
@addPoll="addPoll"
@removePoll="removePoll"
ref="pollRef"
@ -425,6 +426,11 @@ export default defineComponent({
enableResizing.value = true
})
}
const updatePollExpire = newExpire => {
pollExpire.label = newExpire.label
pollExpire.value = newExpire.value
}
const toggleContentWarning = () => {
const previousHeight = spoilerRef.value ? spoilerRef.value.offsetHeight : 0
enableResizing.value = false
@ -468,6 +474,7 @@ export default defineComponent({
openPoll,
polls,
pollExpire,
updatePollExpire,
statusHeight,
// DOM refs
previewRef,

View File

@ -9,7 +9,7 @@
</li>
</ul>
<el-button class="add-poll" type="info" size="small" @click="addPoll" plain>{{ $t('modals.new_toot.poll.add_choice') }}</el-button>
<el-select :modelValue="expire" @change="$emit('update:expire', $event)" size="small" value-key="value">
<el-select :model-value="expire" size="small" value-key="value" @change="updateExpire">
<el-option v-for="exp in expiresList" :key="exp.value" :label="exp.label" :value="exp"> </el-option>
</el-select>
</div>
@ -36,6 +36,7 @@ export default defineComponent({
required: true
}
},
emits: ['addPoll', 'removePoll', 'update:expire', 'update:polls'],
setup(props, ctx) {
const i18n = useI18next()
const { expire, polls } = toRefs(props)
@ -76,9 +77,12 @@ export default defineComponent({
const removePoll = (id: number) => {
ctx.emit('removePoll', id)
}
const updateExpire = newExpire => {
ctx.emit('update:expire', newExpire)
}
watch(expire, (newExpire, _old) => {
ctx.emit('update:expire', newExpire)
updateExpire(newExpire)
})
watch(
polls,
@ -93,7 +97,8 @@ export default defineComponent({
expire,
expiresList,
addPoll,
removePoll
removePoll,
updateExpire
}
}
})