overhaul trending polls
* Split into local, global, and completed sections * Don't require credential, but check for local/global timeline perms * Fix rate limit * Return polls where the current user has already voted * Return non-public polls if the user has permission to view them * Apply user/instance blocks * Fetch polls + notes + users in a single step to speed up pack
This commit is contained in:
parent
b05b4ec74d
commit
3c949f0b81
6 changed files with 140 additions and 24 deletions
|
|
@ -10,27 +10,67 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<option value="polls">{{ i18n.ts.poll }}</option>
|
||||
</MkTab>
|
||||
<MkNotes v-if="tab === 'notes'" :pagination="paginationForNotes"/>
|
||||
<MkNotes v-else-if="tab === 'polls'" :pagination="paginationForPolls"/>
|
||||
<div v-else-if="tab === 'polls'">
|
||||
<MkFoldableSection class="_margin">
|
||||
<template #header><i class="ph-house ph-bold ph-lg" style="margin-right: 0.5em;"></i>{{ i18n.tsx.pollsOnLocal({ host: instance.name ?? host }) }}</template>
|
||||
<MkNotes :pagination="paginationForPollsLocal" :disableAutoLoad="true"/>
|
||||
</MkFoldableSection>
|
||||
|
||||
<MkFoldableSection class="_margin">
|
||||
<template #header><i class="ph-globe ph-bold ph-lg" style="margin-right: 0.5em;"></i>{{ i18n.ts.pollsOnRemote }}</template>
|
||||
<MkNotes :pagination="paginationForPollsRemote" :disableAutoLoad="true"/>
|
||||
</MkFoldableSection>
|
||||
|
||||
<MkFoldableSection class="_margin">
|
||||
<template #header><i class="ph-timer ph-bold ph-lg" style="margin-right: 0.5em;"></i>{{ i18n.ts.pollsExpired }}</template>
|
||||
<MkNotes :pagination="paginationForPollsExpired" :disableAutoLoad="true"/>
|
||||
</MkFoldableSection>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { host } from '@@/js/config.js';
|
||||
import MkNotes from '@/components/MkNotes.vue';
|
||||
import MkTab from '@/components/MkTab.vue';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
||||
import { instance } from '@/instance.js';
|
||||
|
||||
const paginationForNotes = {
|
||||
endpoint: 'notes/featured' as const,
|
||||
limit: 10,
|
||||
};
|
||||
|
||||
const paginationForPolls = {
|
||||
const paginationForPollsLocal = {
|
||||
endpoint: 'notes/polls/recommendation' as const,
|
||||
limit: 10,
|
||||
offsetMode: true,
|
||||
params: {
|
||||
excludeChannels: true,
|
||||
local: true,
|
||||
},
|
||||
};
|
||||
|
||||
const paginationForPollsRemote = {
|
||||
endpoint: 'notes/polls/recommendation' as const,
|
||||
limit: 10,
|
||||
offsetMode: true,
|
||||
params: {
|
||||
excludeChannels: true,
|
||||
local: false,
|
||||
},
|
||||
};
|
||||
|
||||
const paginationForPollsExpired = {
|
||||
endpoint: 'notes/polls/recommendation' as const,
|
||||
limit: 10,
|
||||
offsetMode: true,
|
||||
params: {
|
||||
excludeChannels: true,
|
||||
local: null,
|
||||
expired: true,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue