This commit is contained in:
kakkokari-gtyih 2025-08-30 10:32:45 +09:00
parent cdeddab905
commit 35ec4ae7e7
2 changed files with 7 additions and 4 deletions

View File

@ -50,9 +50,11 @@ const props = defineProps<{
const now = useLowresTime(); const now = useLowresTime();
const expiresAtTime = computed(() => props.expiresAt ? new Date(props.expiresAt).getTime() : null);
const remaining = computed(() => { const remaining = computed(() => {
if (props.expiresAt == null) return -1; if (expiresAtTime.value == null) return -1;
return Math.floor(Math.max(new Date(props.expiresAt).getTime() - now.value, 0) / 1000); return Math.floor(Math.max(expiresAtTime.value - now.value, 0) / 1000);
}); });
const total = computed(() => sum(props.choices.map(x => x.votes))); const total = computed(() => sum(props.choices.map(x => x.votes)));

View File

@ -14,7 +14,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup> <script lang="ts" setup>
import isChromatic from 'chromatic/isChromatic'; import isChromatic from 'chromatic/isChromatic';
import { computed } from 'vue'; import { ref, computed, watch } from 'vue';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { dateTimeFormat } from '@@/js/intl-const.js'; import { dateTimeFormat } from '@@/js/intl-const.js';
import { useLowresTime } from '@/composables/use-lowres-time.js'; import { useLowresTime } from '@/composables/use-lowres-time.js';
@ -47,7 +47,8 @@ const _time = props.time == null ? NaN : getDateSafe(props.time).getTime();
const invalid = Number.isNaN(_time); const invalid = Number.isNaN(_time);
const absolute = !invalid ? dateTimeFormat.format(_time) : i18n.ts._ago.invalid; const absolute = !invalid ? dateTimeFormat.format(_time) : i18n.ts._ago.invalid;
const now = useLowresTime(); const actualNow = useLowresTime();
const now = computed(() => (props.origin ? props.origin.getTime() : actualNow.value));
// eslint-disable-next-line vue/no-setup-props-reactivity-loss // eslint-disable-next-line vue/no-setup-props-reactivity-loss
const ago = computed(() => (now.value - _time) / 1000/*ms*/); const ago = computed(() => (now.value - _time) / 1000/*ms*/);