- -
- {{ option.title }}
-
+
+ -
+
+
+
+
+
+ -
+ {{ option.title }}
+
+
-
Vote
+
Vote
{{ poll.votes_count }} votes,
until {{ parseDatetime(poll.expires_at, now) }}
@@ -49,6 +60,9 @@ export default {
if (this.pollRadio !== null) {
this.$emit('vote', [this.pollRadio])
}
+ },
+ progress(percent) {
+ return `width: ${percent}%`
}
}
}
@@ -61,7 +75,31 @@ export default {
padding-left: 16px;
li {
+ position: relative;
margin: 4px 0;
+ line-height: 32px;
+ }
+
+ .voted {
+ max-width: 200px;
+
+ .progress-bar {
+ position: absolute;
+ display: inline-block;
+ height: 100%;
+ background-color: #409eff;
+ border-radius: 4px;
+ }
+
+ .text {
+ position: relative;
+ display: inline-block;
+ padding-left: 8px;
+
+ .percentage {
+ font-weight: bold;
+ }
+ }
}
}
}
diff --git a/src/renderer/components/organisms/Toot.vue b/src/renderer/components/organisms/Toot.vue
index 3b4257ae..053fd26c 100644
--- a/src/renderer/components/organisms/Toot.vue
+++ b/src/renderer/components/organisms/Toot.vue
@@ -199,7 +199,8 @@ export default {
showContent: this.$store.state.App.ignoreCW,
showAttachments: this.$store.state.App.ignoreNFSW,
hideAllAttachments: this.$store.state.App.hideAllAttachments,
- now: Date.now()
+ now: Date.now(),
+ pollResponse: null
}
},
props: {
@@ -279,7 +280,11 @@ export default {
return !this.spoilered || this.showContent
},
poll: function() {
- return this.originalMessage.poll
+ if (this.pollResponse) {
+ return this.pollResponse
+ } else {
+ return this.originalMessage.poll
+ }
},
sensitive: function() {
return (this.hideAllAttachments || this.originalMessage.sensitive) && this.mediaAttachments.length > 0
@@ -555,8 +560,12 @@ export default {
break
}
},
- vote(choices) {
- console.log(choices)
+ async vote(choices) {
+ const res = await this.$store.dispatch('organisms/Toot/vote', {
+ id: this.poll.id,
+ choices: choices
+ })
+ this.pollResponse = res
}
}
}
diff --git a/src/renderer/store/organisms/Toot.ts b/src/renderer/store/organisms/Toot.ts
index e1f3f322..01d17551 100644
--- a/src/renderer/store/organisms/Toot.ts
+++ b/src/renderer/store/organisms/Toot.ts
@@ -1,8 +1,13 @@
-import Mastodon, { Response, Status, Account } from 'megalodon'
+import Mastodon, { Response, Status, Account, Poll } from 'megalodon'
import { ipcRenderer } from 'electron'
import { Module, ActionTree } from 'vuex'
import { RootState } from '@/store'
+type VoteParam = {
+ id: string
+ choices: Array