forked from misskey-dev/misskey
-
Notifications
You must be signed in to change notification settings - Fork 12
/
featured.vue
124 lines (114 loc) · 3 KB
/
featured.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<template>
<mk-ui>
<template #header><span style="margin-right:4px;"><fa :icon="faNewspaper"/></span>{{ $t('@.featured-notes') }}</template>
<main>
<details>
<summary>{{ $t('options') }}</summary>
<ui-select v-model="days" :disabled="fetching">
<template #label>{{ $t('days') }}</template>
<option value="0.125">3 {{ $t('hour') }}</option>
<option value="0.25">6 {{ $t('hour') }}</option>
<option value="0.5">12 {{ $t('hour') }}</option>
<option value="1">1 {{ $t('day') }}</option>
<option value="2">2 {{ $t('day') }}</option>
<option value="7">7 {{ $t('day') }}</option>
<option value="30">30 {{ $t('day') }}</option>
</ui-select>
<div>
<ui-switch v-model="includeGlobal" :disabled="fetching">{{ $t('include-global') }}</ui-switch>
<ui-switch v-model="mediaOnly" :disabled="fetching">{{ $t('media-only') }}</ui-switch>
<ui-switch v-model="sfwOnly" :disabled="fetching">{{ $t('sfw-only') }}</ui-switch>
<ui-switch v-model="nsfwOnly" :disabled="fetching">{{ $t('nsfw-only') }}</ui-switch>
</div>
</details>
<div>
<template v-for="note in notes">
<mk-note class="post" :note="note" :key="note.id" :class="{ round: $store.state.device.roundedCorners }"/>
</template>
</div>
</main>
</mk-ui>
</template>
<script lang="ts">
import Vue from 'vue';
import i18n from '../../../i18n';
import Progress from '../../../common/scripts/loading';
import { faNewspaper } from '@fortawesome/free-solid-svg-icons';
export default Vue.extend({
i18n: i18n('mobile/views/pages/featured.vue'),
data() {
return {
includeGlobal: false,
mediaOnly: false,
sfwOnly: false,
nsfwOnly: false,
days: 2,
fetching: false,
notes: [],
faNewspaper
};
},
watch: {
includeGlobal() {
this.fetch();
},
mediaOnly() {
this.fetch();
},
sfwOnly() {
this.fetch();
},
nsfwOnly() {
this.fetch();
},
days() {
this.fetch();
},
},
created() {
this.$root.getMeta().then((meta: any) => {
this.includeGlobal = !!meta?.featuredGlobal;
this.fetch();
});
},
mounted() {
document.title = this.$root.instanceName;
},
methods: {
fetch() {
if (this.fetching) return;
Progress.start();
this.fetching = true;
this.$root.api('notes/featured', {
limit: 30,
days: Number(this.days),
includeGlobal: this.includeGlobal,
fileType: this.mediaOnly ? ['image/jpeg', 'image/png', 'image/apng', 'image/gif', 'image/webp', 'video/mp4', 'video/webm'] : undefined,
excludeNsfw: this.sfwOnly,
excludeSfw: this.nsfwOnly,
}, false, true).then((notes: any) => {
notes.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
this.notes = notes;
this.fetching = false;
Progress.done();
});
},
}
});
</script>
<style lang="stylus" scoped>
main
> details
margin 16px 8px
color var(--text)
cursor pointer
> * > .post
margin-bottom 8px
background var(--face)
border-bottom 0
&.round
border-radius 6px
@media (min-width 500px)
> * > .post
margin-bottom 16px
</style>