2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
2024-02-13 16:59:27 +01:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 07:31:52 +02:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2022-06-20 10:38:49 +02:00
|
|
|
<MkStickyContainer>
|
2023-08-13 13:12:29 +02:00
|
|
|
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
2023-05-19 09:20:53 +02:00
|
|
|
<MkSpacer :contentMax="800">
|
2024-01-18 10:21:33 +01:00
|
|
|
<MkHorizontalSwipe v-model:tab="tab" :tabs="headerTabs">
|
|
|
|
<div :key="tab" class="_gaps">
|
|
|
|
<MkInfo v-if="$i && $i.hasUnreadAnnouncement && tab === 'current'" warn>{{ i18n.ts.youHaveUnreadAnnouncements }}</MkInfo>
|
|
|
|
<MkPagination ref="paginationEl" :key="tab" v-slot="{items}" :pagination="tab === 'current' ? paginationCurrent : paginationPast" class="_gaps">
|
|
|
|
<section v-for="announcement in items" :key="announcement.id" class="_panel" :class="$style.announcement">
|
2024-06-21 15:30:40 +02:00
|
|
|
<div v-if="announcement.forYou" :class="$style.forYou"><i class="ti ti-pin"></i> {{ i18n.ts.forYou }}</div>
|
2024-01-18 10:21:33 +01:00
|
|
|
<div :class="$style.header">
|
|
|
|
<span v-if="$i && !announcement.silence && !announcement.isRead" style="margin-right: 0.5em;">🆕</span>
|
|
|
|
<span style="margin-right: 0.5em;">
|
2024-06-21 17:27:36 +02:00
|
|
|
<i v-if="announcement.icon === 'info'" class="ti ti-info-circle"></i>
|
2024-06-21 16:31:32 +02:00
|
|
|
<i v-else-if="announcement.icon === 'warning'" class="ti ti-alert-triangle" style="color: var(--warn);"></i>
|
2024-06-21 13:38:50 +02:00
|
|
|
<i v-else-if="announcement.icon === 'error'" class="ti ti-circle-x" style="color: var(--error);"></i>
|
2024-06-21 14:09:24 +02:00
|
|
|
<i v-else-if="announcement.icon === 'success'" class="ti ti-check" style="color: var(--success);"></i>
|
2024-01-18 10:21:33 +01:00
|
|
|
</span>
|
2024-05-27 10:15:11 +02:00
|
|
|
<MkA :to="`/announcements/${announcement.id}`"><span>{{ announcement.title }}</span></MkA>
|
2023-08-13 13:12:29 +02:00
|
|
|
</div>
|
2024-01-18 10:21:33 +01:00
|
|
|
<div :class="$style.content">
|
2024-06-07 12:01:49 +02:00
|
|
|
<Mfm :text="announcement.text" :isBlock="true" />
|
2024-01-18 10:21:33 +01:00
|
|
|
<img v-if="announcement.imageUrl" :src="announcement.imageUrl"/>
|
2024-05-27 10:15:11 +02:00
|
|
|
<MkA :to="`/announcements/${announcement.id}`">
|
|
|
|
<div style="margin-top: 8px; opacity: 0.7; font-size: 85%;">
|
|
|
|
{{ i18n.ts.createdAt }}: <MkTime :time="announcement.createdAt" mode="detail"/>
|
|
|
|
</div>
|
|
|
|
<div v-if="announcement.updatedAt" style="opacity: 0.7; font-size: 85%;">
|
|
|
|
{{ i18n.ts.updatedAt }}: <MkTime :time="announcement.updatedAt" mode="detail"/>
|
|
|
|
</div>
|
|
|
|
</MkA>
|
2024-01-18 10:21:33 +01:00
|
|
|
</div>
|
|
|
|
<div v-if="tab !== 'past' && $i && !announcement.silence && !announcement.isRead" :class="$style.footer">
|
2024-06-21 14:09:24 +02:00
|
|
|
<MkButton primary @click="read(announcement)"><i class="ti ti-check"></i> {{ i18n.ts.gotIt }}</MkButton>
|
2024-01-18 10:21:33 +01:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</MkPagination>
|
|
|
|
</div>
|
|
|
|
</MkHorizontalSwipe>
|
2022-06-20 10:38:49 +02:00
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-01-29 20:37:25 +01:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
<script lang="ts" setup>
|
2023-12-07 06:42:09 +01:00
|
|
|
import { ref, computed } from 'vue';
|
2023-12-27 07:55:09 +01:00
|
|
|
import MkPagination from '@/components/MkPagination.vue';
|
2022-09-06 11:21:49 +02:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-08-13 13:12:29 +02:00
|
|
|
import MkInfo from '@/components/MkInfo.vue';
|
2024-01-18 10:21:33 +01:00
|
|
|
import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue';
|
2023-09-19 09:37:43 +02:00
|
|
|
import * as os from '@/os.js';
|
2024-01-04 10:32:46 +01:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2023-09-19 09:37:43 +02:00
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
|
|
|
import { $i, updateAccount } from '@/account.js';
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2023-08-13 13:12:29 +02:00
|
|
|
const paginationCurrent = {
|
2022-06-20 10:38:49 +02:00
|
|
|
endpoint: 'announcements' as const,
|
|
|
|
limit: 10,
|
2023-08-13 13:12:29 +02:00
|
|
|
params: {
|
|
|
|
isActive: true,
|
|
|
|
},
|
2023-12-27 07:55:09 +01:00
|
|
|
};
|
2023-08-13 13:12:29 +02:00
|
|
|
|
|
|
|
const paginationPast = {
|
|
|
|
endpoint: 'announcements' as const,
|
|
|
|
limit: 10,
|
|
|
|
params: {
|
|
|
|
isActive: false,
|
|
|
|
},
|
2023-12-27 07:55:09 +01:00
|
|
|
};
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2023-07-31 07:13:34 +02:00
|
|
|
const paginationEl = ref<InstanceType<typeof MkPagination>>();
|
|
|
|
|
2023-08-13 13:12:29 +02:00
|
|
|
const tab = ref('current');
|
|
|
|
|
2024-05-27 10:15:11 +02:00
|
|
|
async function read(target) {
|
|
|
|
if (target.needConfirmationToRead) {
|
2023-08-13 13:12:29 +02:00
|
|
|
const confirm = await os.confirm({
|
|
|
|
type: 'question',
|
|
|
|
title: i18n.ts._announcement.readConfirmTitle,
|
2024-05-27 10:15:11 +02:00
|
|
|
text: i18n.tsx._announcement.readConfirmText({ title: target.title }),
|
2023-08-13 13:12:29 +02:00
|
|
|
});
|
|
|
|
if (confirm.canceled) return;
|
|
|
|
}
|
|
|
|
|
2023-07-31 07:13:34 +02:00
|
|
|
if (!paginationEl.value) return;
|
2024-05-27 10:15:11 +02:00
|
|
|
paginationEl.value.updateItem(target.id, a => {
|
2023-08-13 13:12:29 +02:00
|
|
|
a.isRead = true;
|
|
|
|
return a;
|
|
|
|
});
|
2024-05-27 10:15:11 +02:00
|
|
|
misskeyApi('i/read-announcement', { announcementId: target.id });
|
2023-08-13 13:12:29 +02:00
|
|
|
updateAccount({
|
2024-05-27 10:15:11 +02:00
|
|
|
unreadAnnouncements: $i!.unreadAnnouncements.filter(a => a.id !== target.id),
|
2023-07-31 07:13:34 +02:00
|
|
|
});
|
2022-06-20 10:38:49 +02:00
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
const headerActions = computed(() => []);
|
2022-06-20 10:38:49 +02:00
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
const headerTabs = computed(() => [{
|
2023-08-13 13:12:29 +02:00
|
|
|
key: 'current',
|
|
|
|
title: i18n.ts.currentAnnouncements,
|
2024-06-22 16:12:43 +02:00
|
|
|
icon: 'ti ti-flare',
|
2023-08-13 13:12:29 +02:00
|
|
|
}, {
|
|
|
|
key: 'past',
|
|
|
|
title: i18n.ts.pastAnnouncements,
|
2024-06-22 16:12:43 +02:00
|
|
|
icon: 'ti ti-point',
|
2023-08-13 13:12:29 +02:00
|
|
|
}]);
|
2022-06-20 10:38:49 +02:00
|
|
|
|
2024-02-16 08:17:09 +01:00
|
|
|
definePageMetadata(() => ({
|
2022-06-20 10:38:49 +02:00
|
|
|
title: i18n.ts.announcements,
|
2024-06-22 14:34:55 +02:00
|
|
|
icon: 'ti ti-speakerphone',
|
2024-02-16 08:17:09 +01:00
|
|
|
}));
|
2020-01-29 20:37:25 +01:00
|
|
|
</script>
|
|
|
|
|
2023-08-13 13:12:29 +02:00
|
|
|
<style lang="scss" module>
|
|
|
|
.announcement {
|
|
|
|
padding: 16px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.forYou {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
line-height: 24px;
|
|
|
|
font-size: 90%;
|
|
|
|
white-space: pre;
|
|
|
|
color: #d28a3f;
|
|
|
|
}
|
|
|
|
|
|
|
|
.header {
|
|
|
|
margin-bottom: 16px;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
|
|
|
.content {
|
|
|
|
> img {
|
|
|
|
display: block;
|
|
|
|
max-height: 300px;
|
|
|
|
max-width: 100%;
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
}
|
2023-08-13 13:12:29 +02:00
|
|
|
|
|
|
|
.footer {
|
|
|
|
margin-top: 16px;
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
</style>
|