fix poll labels always assuming relative time format

This commit is contained in:
Henry Jameson 2025-03-13 12:52:37 +02:00
parent 225352e090
commit fef9121fce
4 changed files with 41 additions and 37 deletions
src

View file

@ -45,6 +45,13 @@ export default {
expired () { expired () {
return (this.poll && this.poll.expired) || false return (this.poll && this.poll.expired) || false
}, },
expirationLabel () {
if (this.$store.getters.mergedConfig.useAbsoluteTimeFormat) {
return this.expired ? 'polls.expired_at' : 'polls.expires_at'
} else {
return this.expired ? 'polls.expired' : 'polls.expires_in'
}
},
loggedIn () { loggedIn () {
return this.$store.state.users.currentUser return this.$store.state.users.currentUser
}, },

View file

@ -47,12 +47,6 @@
width: 3.5em; width: 3.5em;
} }
.footer {
display: flex;
align-items: center;
flex-wrap: wrap;
}
&.loading * { &.loading * {
cursor: progress; cursor: progress;
} }

View file

@ -56,15 +56,7 @@
</div> </div>
</div> </div>
<div class="footer faint"> <div class="footer faint">
<button <p>
v-if="!showResults"
class="btn button-default poll-vote-button"
type="button"
:disabled="isDisabled"
@click="vote"
>
{{ $t('polls.vote') }}
</button>
<span <span
v-if="poll.pleroma?.non_anonymous" v-if="poll.pleroma?.non_anonymous"
:title="$t('polls.non_anonymous_title')" :title="$t('polls.non_anonymous_title')"
@ -72,7 +64,7 @@
{{ $t('polls.non_anonymous') }} {{ $t('polls.non_anonymous') }}
&nbsp;·&nbsp; &nbsp;·&nbsp;
</span> </span>
<div class="total"> <span class="total">
<template v-if="typeof poll.voters_count === 'number'"> <template v-if="typeof poll.voters_count === 'number'">
{{ $t("polls.people_voted_count", { count: poll.voters_count }, poll.voters_count) }} {{ $t("polls.people_voted_count", { count: poll.voters_count }, poll.voters_count) }}
</template> </template>
@ -82,11 +74,11 @@
<span v-if="expiresAt !== null"> <span v-if="expiresAt !== null">
&nbsp;·&nbsp; &nbsp;·&nbsp;
</span> </span>
</div> </span>
<span v-if="expiresAt !== null"> <span v-if="expiresAt !== null">
<i18n-t <i18n-t
scope="global" scope="global"
:keypath="expired ? 'polls.expired' : 'polls.expires_in'" :keypath="expirationLabel"
> >
<Timeago <Timeago
:time="expiresAt" :time="expiresAt"
@ -95,6 +87,16 @@
/> />
</i18n-t> </i18n-t>
</span> </span>
</p>
<button
v-if="!showResults"
class="btn button-default poll-vote-button"
type="button"
:disabled="isDisabled"
@click="vote"
>
{{ $t('polls.vote') }}
</button>
</div> </div>
</div> </div>
</template> </template>

View file

@ -231,8 +231,9 @@
"single_choice": "Single choice", "single_choice": "Single choice",
"multiple_choices": "Multiple choices", "multiple_choices": "Multiple choices",
"expiry": "Poll age", "expiry": "Poll age",
"expires_in": "Poll ends in {0}", "expires_at": "Poll ends {0}",
"expired": "Poll ended {0} ago", "expired": "Poll ended {0} ago",
"expired_at": "Poll ended {0}",
"not_enough_options": "Too few unique options in poll", "not_enough_options": "Too few unique options in poll",
"non_anonymous": "Public poll", "non_anonymous": "Public poll",
"non_anonymous_title": "Other instances may display the options you voted for" "non_anonymous_title": "Other instances may display the options you voted for"