2023-07-27 14:31:52 +09:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
<template>
|
2022-07-17 21:06:33 +09:00
|
|
|
<component
|
|
|
|
:is="popup.component"
|
2021-11-19 19:36:12 +09:00
|
|
|
v-for="popup in popups"
|
2020-10-17 20:12:00 +09:00
|
|
|
:key="popup.id"
|
|
|
|
v-bind="popup.props"
|
|
|
|
v-on="popup.events"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<XUpload v-if="uploads.length > 0"/>
|
|
|
|
|
2023-01-10 14:37:32 +09:00
|
|
|
<TransitionGroup
|
2023-06-01 17:19:46 +09:00
|
|
|
tag="div"
|
|
|
|
:class="[$style.notifications, {
|
|
|
|
[$style.notificationsPosition_leftTop]: defaultStore.state.notificationPosition === 'leftTop',
|
|
|
|
[$style.notificationsPosition_leftBottom]: defaultStore.state.notificationPosition === 'leftBottom',
|
|
|
|
[$style.notificationsPosition_rightTop]: defaultStore.state.notificationPosition === 'rightTop',
|
|
|
|
[$style.notificationsPosition_rightBottom]: defaultStore.state.notificationPosition === 'rightBottom',
|
|
|
|
[$style.notificationsStackAxis_vertical]: defaultStore.state.notificationStackAxis === 'vertical',
|
|
|
|
[$style.notificationsStackAxis_horizontal]: defaultStore.state.notificationStackAxis === 'horizontal',
|
|
|
|
}]"
|
2023-05-19 20:52:15 +09:00
|
|
|
:moveClass="defaultStore.state.animation ? $style.transition_notification_move : ''"
|
|
|
|
:enterActiveClass="defaultStore.state.animation ? $style.transition_notification_enterActive : ''"
|
|
|
|
:leaveActiveClass="defaultStore.state.animation ? $style.transition_notification_leaveActive : ''"
|
|
|
|
:enterFromClass="defaultStore.state.animation ? $style.transition_notification_enterFrom : ''"
|
|
|
|
:leaveToClass="defaultStore.state.animation ? $style.transition_notification_leaveTo : ''"
|
2023-01-10 14:37:32 +09:00
|
|
|
>
|
2023-04-17 13:12:58 +09:00
|
|
|
<div v-for="notification in notifications" :key="notification.id" :class="$style.notification">
|
|
|
|
<XNotification :notification="notification"/>
|
|
|
|
</div>
|
2023-01-01 11:57:37 +09:00
|
|
|
</TransitionGroup>
|
|
|
|
|
2020-10-25 01:21:41 +09:00
|
|
|
<XStreamIndicator/>
|
|
|
|
|
2021-11-19 19:36:12 +09:00
|
|
|
<div v-if="pendingApiRequestsCount > 0" id="wait"></div>
|
2022-03-03 01:17:37 +09:00
|
|
|
|
|
|
|
<div v-if="dev" id="devTicker"><span>DEV BUILD</span></div>
|
2022-12-23 17:13:43 +09:00
|
|
|
|
|
|
|
<div v-if="$i && $i.isBot" id="botWarn"><span>{{ i18n.ts.loggedInAsBot }}</span></div>
|
2020-10-17 20:12:00 +09:00
|
|
|
</template>
|
|
|
|
|
2022-07-17 21:06:33 +09:00
|
|
|
<script lang="ts" setup>
|
2023-04-17 13:12:58 +09:00
|
|
|
import { defineAsyncComponent, ref } from 'vue';
|
2023-01-01 11:57:37 +09:00
|
|
|
import * as misskey from 'misskey-js';
|
2022-07-17 21:06:33 +09:00
|
|
|
import { swInject } from './sw-inject';
|
2023-01-01 11:57:37 +09:00
|
|
|
import XNotification from './notification.vue';
|
2023-02-16 23:09:41 +09:00
|
|
|
import { popups, pendingApiRequestsCount } from '@/os';
|
2022-04-28 11:14:03 +09:00
|
|
|
import { uploads } from '@/scripts/upload';
|
2021-11-12 02:02:25 +09:00
|
|
|
import * as sound from '@/scripts/sound';
|
|
|
|
import { $i } from '@/account';
|
2023-05-15 19:08:46 +09:00
|
|
|
import { useStream } from '@/stream';
|
2022-12-23 17:13:43 +09:00
|
|
|
import { i18n } from '@/i18n';
|
2023-04-01 13:42:40 +09:00
|
|
|
import { defaultStore } from '@/store';
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-07-17 21:06:33 +09:00
|
|
|
const XStreamIndicator = defineAsyncComponent(() => import('./stream-indicator.vue'));
|
|
|
|
const XUpload = defineAsyncComponent(() => import('./upload.vue'));
|
|
|
|
|
|
|
|
const dev = _DEV_;
|
|
|
|
|
2023-01-01 11:57:37 +09:00
|
|
|
let notifications = $ref<misskey.entities.Notification[]>([]);
|
|
|
|
|
|
|
|
function onNotification(notification) {
|
2022-07-17 21:06:33 +09:00
|
|
|
if ($i.mutingNotificationTypes.includes(notification.type)) return;
|
|
|
|
|
|
|
|
if (document.visibilityState === 'visible') {
|
2023-05-15 19:08:46 +09:00
|
|
|
useStream().send('readNotification');
|
2022-07-17 21:06:33 +09:00
|
|
|
|
2023-01-01 11:57:37 +09:00
|
|
|
notifications.unshift(notification);
|
|
|
|
window.setTimeout(() => {
|
|
|
|
if (notifications.length > 3) notifications.pop();
|
|
|
|
}, 500);
|
|
|
|
|
|
|
|
window.setTimeout(() => {
|
|
|
|
notifications = notifications.filter(x => x.id !== notification.id);
|
|
|
|
}, 6000);
|
2022-07-17 21:06:33 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
sound.play('notification');
|
2023-01-01 11:57:37 +09:00
|
|
|
}
|
2022-07-17 21:06:33 +09:00
|
|
|
|
|
|
|
if ($i) {
|
2023-05-15 19:08:46 +09:00
|
|
|
const connection = useStream().useChannel('main', null, 'UI');
|
2022-07-17 21:06:33 +09:00
|
|
|
connection.on('notification', onNotification);
|
|
|
|
|
|
|
|
//#region Listen message from SW
|
|
|
|
if ('serviceWorker' in navigator) {
|
|
|
|
swInject();
|
|
|
|
}
|
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
</script>
|
|
|
|
|
2023-01-10 14:37:32 +09:00
|
|
|
<style lang="scss" module>
|
|
|
|
.transition_notification_move,
|
|
|
|
.transition_notification_enterActive,
|
|
|
|
.transition_notification_leaveActive {
|
2023-01-01 11:57:37 +09:00
|
|
|
transition: opacity 0.3s, transform 0.3s !important;
|
|
|
|
}
|
2023-04-17 13:12:58 +09:00
|
|
|
.transition_notification_enterFrom {
|
|
|
|
opacity: 0;
|
|
|
|
transform: translateX(250px);
|
|
|
|
}
|
2023-01-10 14:37:32 +09:00
|
|
|
.transition_notification_leaveTo {
|
2023-01-01 11:57:37 +09:00
|
|
|
opacity: 0;
|
|
|
|
transform: translateX(-250px);
|
|
|
|
}
|
|
|
|
|
|
|
|
.notifications {
|
|
|
|
position: fixed;
|
|
|
|
z-index: 3900000;
|
2023-04-17 13:12:58 +09:00
|
|
|
padding: 0 var(--margin);
|
2023-01-01 11:57:37 +09:00
|
|
|
pointer-events: none;
|
2023-04-17 13:12:58 +09:00
|
|
|
display: flex;
|
2023-01-01 11:57:37 +09:00
|
|
|
|
2023-06-01 17:19:46 +09:00
|
|
|
&.notificationsPosition_leftTop {
|
2023-04-17 13:12:58 +09:00
|
|
|
top: var(--margin);
|
|
|
|
left: 0;
|
|
|
|
}
|
|
|
|
|
2023-06-01 17:19:46 +09:00
|
|
|
&.notificationsPosition_rightTop {
|
2023-04-17 13:12:58 +09:00
|
|
|
top: var(--margin);
|
|
|
|
right: 0;
|
2023-01-01 11:57:37 +09:00
|
|
|
}
|
|
|
|
|
2023-06-01 17:19:46 +09:00
|
|
|
&.notificationsPosition_leftBottom {
|
2023-01-10 13:50:34 +09:00
|
|
|
bottom: calc(var(--minBottomSpacing) + var(--margin));
|
2023-04-17 13:12:58 +09:00
|
|
|
left: 0;
|
|
|
|
}
|
|
|
|
|
2023-06-01 17:19:46 +09:00
|
|
|
&.notificationsPosition_rightBottom {
|
2023-04-17 13:12:58 +09:00
|
|
|
bottom: calc(var(--minBottomSpacing) + var(--margin));
|
|
|
|
right: 0;
|
|
|
|
}
|
|
|
|
|
2023-06-01 17:19:46 +09:00
|
|
|
&.notificationsStackAxis_vertical {
|
2023-04-17 13:12:58 +09:00
|
|
|
width: 250px;
|
|
|
|
|
2023-06-01 17:19:46 +09:00
|
|
|
&.notificationsPosition_leftTop,
|
|
|
|
&.notificationsPosition_rightTop {
|
2023-04-17 13:12:58 +09:00
|
|
|
flex-direction: column;
|
|
|
|
|
|
|
|
.notification {
|
|
|
|
& + .notification {
|
|
|
|
margin-top: 8px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-01 17:19:46 +09:00
|
|
|
&.notificationsPosition_leftBottom,
|
|
|
|
&.notificationsPosition_rightBottom {
|
2023-04-17 13:12:58 +09:00
|
|
|
flex-direction: column-reverse;
|
|
|
|
|
|
|
|
.notification {
|
|
|
|
& + .notification {
|
|
|
|
margin-bottom: 8px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-01-10 14:37:32 +09:00
|
|
|
}
|
2023-01-01 11:57:37 +09:00
|
|
|
|
2023-06-01 17:19:46 +09:00
|
|
|
&.notificationsStackAxis_horizontal {
|
2023-04-17 13:12:58 +09:00
|
|
|
width: 100%;
|
|
|
|
|
2023-06-01 17:19:46 +09:00
|
|
|
&.notificationsPosition_leftTop,
|
|
|
|
&.notificationsPosition_leftBottom {
|
2023-04-17 13:12:58 +09:00
|
|
|
flex-direction: row;
|
|
|
|
|
|
|
|
.notification {
|
|
|
|
& + .notification {
|
|
|
|
margin-left: 8px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-01 17:19:46 +09:00
|
|
|
&.notificationsPosition_rightTop,
|
|
|
|
&.notificationsPosition_rightBottom {
|
2023-04-17 13:12:58 +09:00
|
|
|
flex-direction: row-reverse;
|
|
|
|
|
|
|
|
.notification {
|
|
|
|
& + .notification {
|
|
|
|
margin-right: 8px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.notification {
|
|
|
|
width: 250px;
|
|
|
|
flex-shrink: 0;
|
2023-01-01 11:57:37 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-04-17 13:12:58 +09:00
|
|
|
|
|
|
|
.notification {
|
|
|
|
container-type: inline-size;
|
|
|
|
}
|
2023-01-01 11:57:37 +09:00
|
|
|
</style>
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
<style lang="scss">
|
2022-03-03 01:17:37 +09:00
|
|
|
@keyframes dev-ticker-blink {
|
|
|
|
0% { opacity: 1; }
|
|
|
|
50% { opacity: 0; }
|
|
|
|
100% { opacity: 1; }
|
|
|
|
}
|
|
|
|
|
|
|
|
@keyframes progress-spinner {
|
|
|
|
0% {
|
|
|
|
transform: rotate(0deg);
|
|
|
|
}
|
|
|
|
100% {
|
|
|
|
transform: rotate(360deg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
#wait {
|
|
|
|
display: block;
|
|
|
|
position: fixed;
|
2021-12-18 12:12:47 +09:00
|
|
|
z-index: 4000000;
|
2020-10-17 20:12:00 +09:00
|
|
|
top: 15px;
|
|
|
|
right: 15px;
|
2023-01-16 14:24:24 +09:00
|
|
|
pointer-events: none;
|
2020-10-17 20:12:00 +09:00
|
|
|
|
|
|
|
&:before {
|
|
|
|
content: "";
|
|
|
|
display: block;
|
|
|
|
width: 18px;
|
|
|
|
height: 18px;
|
|
|
|
box-sizing: border-box;
|
|
|
|
border: solid 2px transparent;
|
|
|
|
border-top-color: var(--accent);
|
|
|
|
border-left-color: var(--accent);
|
|
|
|
border-radius: 50%;
|
|
|
|
animation: progress-spinner 400ms linear infinite;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-23 17:13:43 +09:00
|
|
|
#botWarn {
|
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
bottom: 0;
|
|
|
|
margin: auto;
|
|
|
|
width: 100%;
|
|
|
|
height: max-content;
|
|
|
|
text-align: center;
|
|
|
|
z-index: 2147483647;
|
|
|
|
color: #ff0;
|
|
|
|
background: rgba(0, 0, 0, 0.5);
|
|
|
|
padding: 4px 7px;
|
|
|
|
font-size: 14px;
|
|
|
|
pointer-events: none;
|
|
|
|
user-select: none;
|
|
|
|
|
|
|
|
> span {
|
|
|
|
animation: dev-ticker-blink 2s infinite;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-03 01:17:37 +09:00
|
|
|
#devTicker {
|
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
z-index: 2147483647;
|
|
|
|
color: #ff0;
|
|
|
|
background: rgba(0, 0, 0, 0.5);
|
|
|
|
padding: 4px 5px;
|
|
|
|
font-size: 14px;
|
|
|
|
pointer-events: none;
|
2022-03-06 23:21:25 +09:00
|
|
|
user-select: none;
|
2022-03-03 01:17:37 +09:00
|
|
|
|
|
|
|
> span {
|
|
|
|
animation: dev-ticker-blink 2s infinite;
|
2020-10-17 20:12:00 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|