refs #874 Refresh polls in timeline
This commit is contained in:
parent
1a8d49b6d6
commit
bcbcb981e6
|
@ -57,10 +57,11 @@
|
|||
"vote": "Vote",
|
||||
"votes_count": "votes",
|
||||
"until": "until {{datetime}}",
|
||||
"left": "{{datetime}} left"
|
||||
"left": "{{datetime}} left",
|
||||
"refresh": "Refresh"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"message": {
|
||||
"follow_request_accept_error": "Failed to accept the request",
|
||||
"follow_reuqest_reject_error": "failed to reject the request",
|
||||
|
|
|
@ -285,7 +285,8 @@
|
|||
"vote": "Vote",
|
||||
"votes_count": "votes",
|
||||
"until": "until {{datetime}}",
|
||||
"left": "{{datetime}} left"
|
||||
"left": "{{datetime}} left",
|
||||
"refresh": "Refresh"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
"vote": "Vote",
|
||||
"votes_count": "votes",
|
||||
"until": "until {{datetime}}",
|
||||
"left": "{{datetime}} left"
|
||||
"left": "{{datetime}} left",
|
||||
"refresh": "Refresh"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -20,10 +20,11 @@
|
|||
"vote": "Vote",
|
||||
"votes_count": "votes",
|
||||
"until": "until {{datetime}}",
|
||||
"left": "{{datetime}} left"
|
||||
"left": "{{datetime}} left",
|
||||
"refresh": "Refresh"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"message": {
|
||||
"follow_request_accept_error": "Failed to accept the request",
|
||||
"follow_reuqest_reject_error": "failed to reject the request",
|
||||
|
|
|
@ -276,9 +276,10 @@
|
|||
"pinned": "固定されたトゥート",
|
||||
"poll": {
|
||||
"vote": "投票",
|
||||
"votes_count": "投票数",
|
||||
"votes_count": "投票",
|
||||
"until": "{{datetime}}まで",
|
||||
"left": "{{datetime}}まで"
|
||||
"left": "{{datetime}}まで",
|
||||
"refresh": "更新"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
"vote": "Vote",
|
||||
"votes_count": "votes",
|
||||
"until": "until {{datetime}}",
|
||||
"left": "{{datetime}} left"
|
||||
"left": "{{datetime}} left",
|
||||
"refresh": "Refresh"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -57,7 +57,8 @@
|
|||
"vote": "Vote",
|
||||
"votes_count": "votes",
|
||||
"until": "until {{datetime}}",
|
||||
"left": "{{datetime}} left"
|
||||
"left": "{{datetime}} left",
|
||||
"refresh": "Refresh"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<template>
|
||||
<div class="poll">
|
||||
<ul class="poll-list" v-if="poll">
|
||||
<div class="poll">
|
||||
<template v-if="poll">
|
||||
<ul class="poll-list">
|
||||
<template v-if="poll.voted">
|
||||
<li class="voted" v-for="(option, id) in poll.options" v-bind:key="id">
|
||||
<span class="progress-bar" :style="progress(option.votes_count * 100 / poll.votes_count)"></span>
|
||||
|
@ -16,10 +17,12 @@
|
|||
</li>
|
||||
</template>
|
||||
</ul>
|
||||
<el-button type="success" size="small" @click="vote" v-if="!poll.voted" :disabled="pollRadio === null">{{ $t('cards.toot.poll.vote') }}</el-button>
|
||||
<el-button v-if="!poll.voted" type="success" size="small" @click="vote" :disabled="pollRadio === null">{{ $t('cards.toot.poll.vote') }}</el-button>
|
||||
<el-button v-else type="text" @click="refresh">{{ $t('cards.toot.poll.refresh') }}</el-button>
|
||||
<span class="votes-count">{{ poll.votes_count }} {{ $t('cards.toot.poll.votes_count') }},</span>
|
||||
<span class="until">{{ parseDatetime(poll.expires_at, now) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
@ -63,6 +66,9 @@ export default {
|
|||
},
|
||||
progress(percent) {
|
||||
return `width: ${percent}%`
|
||||
},
|
||||
refresh() {
|
||||
this.$emit('refresh', this.poll.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
</el-button>
|
||||
</div>
|
||||
<div class="content" v-show="isShowContent" v-html="status()" @click.capture.prevent="tootClick"></div>
|
||||
<Poll v-show="isShowContent" v-if="poll" :poll="poll" @vote="vote"></Poll>
|
||||
<Poll v-show="isShowContent" v-if="poll" :poll="poll" @vote="vote" @refresh="refresh"></Poll>
|
||||
</div>
|
||||
<div class="attachments">
|
||||
<el-button v-show="sensitive && !isShowAttachments" class="show-sensitive" type="info" @click="showAttachments = true">
|
||||
|
@ -566,6 +566,10 @@ export default {
|
|||
choices: choices
|
||||
})
|
||||
this.pollResponse = res
|
||||
},
|
||||
async refresh(id) {
|
||||
const res = await this.$store.dispatch('organisms/Toot/refresh', id)
|
||||
this.pollResponse = res
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,12 +51,17 @@ const actions: ActionTree<TootState, RootState> = {
|
|||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||
return client.post(`/accounts/${account.id}/block`)
|
||||
},
|
||||
vote: async({ rootState }, params: VoteParam): Promise<Poll> => {
|
||||
vote: async ({ rootState }, params: VoteParam): Promise<Poll> => {
|
||||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||
const res = await client.post<Poll>(`/polls/${params.id}/votes`, {
|
||||
choices: params.choices
|
||||
})
|
||||
return res.data
|
||||
},
|
||||
refresh: async ({ rootState }, id: string): Promise<Poll> => {
|
||||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||
const res = await client.get<Poll>(`/polls/${id}`)
|
||||
return res.data
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue