2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-02-19 19:42:36 +01:00
|
|
|
<template>
|
2023-04-01 06:42:40 +02:00
|
|
|
<div v-if="hasDisconnected && defaultStore.state.serverDisconnectedBehavior === 'quiet'" :class="$style.root" class="_panel _shadow" @click="resetDisconnected">
|
2023-09-30 21:53:52 +02:00
|
|
|
<div><i class="ph-warning ph-bold ph-lg"></i> {{ i18n.ts.disconnectedFromServer }}</div>
|
2023-01-15 03:30:40 +01:00
|
|
|
<div :class="$style.command" class="_buttons">
|
2023-06-01 10:19:46 +02:00
|
|
|
<MkButton small primary @click="reload">{{ i18n.ts.reload }}</MkButton>
|
|
|
|
<MkButton small>{{ i18n.ts.doNothing }}</MkButton>
|
2020-02-19 19:42:36 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-01-16 00:38:55 +01:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { onUnmounted } from 'vue';
|
2023-10-30 01:12:20 +01:00
|
|
|
import { useStream, isReloading } from '@/stream.js';
|
2023-09-19 09:37:43 +02:00
|
|
|
import { i18n } from '@/i18n.js';
|
2023-01-15 03:30:40 +01:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-09-19 09:37:43 +02:00
|
|
|
import * as os from '@/os.js';
|
|
|
|
import { defaultStore } from '@/store.js';
|
2023-01-15 03:30:40 +01:00
|
|
|
|
|
|
|
const zIndex = os.claimZIndex('high');
|
2020-02-19 19:42:36 +01:00
|
|
|
|
2022-01-16 00:38:55 +01:00
|
|
|
let hasDisconnected = $ref(false);
|
|
|
|
|
|
|
|
function onDisconnected() {
|
2023-10-30 01:12:20 +01:00
|
|
|
if (isReloading) return;
|
2022-01-16 00:38:55 +01:00
|
|
|
hasDisconnected = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function resetDisconnected() {
|
|
|
|
hasDisconnected = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function reload() {
|
|
|
|
location.reload();
|
|
|
|
}
|
|
|
|
|
2023-05-15 12:08:46 +02:00
|
|
|
useStream().on('_disconnected_', onDisconnected);
|
2022-01-16 00:38:55 +01:00
|
|
|
|
|
|
|
onUnmounted(() => {
|
2023-05-15 12:08:46 +02:00
|
|
|
useStream().off('_disconnected_', onDisconnected);
|
2020-02-19 19:42:36 +01:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2023-01-15 03:30:40 +01:00
|
|
|
<style lang="scss" module>
|
|
|
|
.root {
|
2020-02-19 19:42:36 +01:00
|
|
|
position: fixed;
|
2023-01-15 03:30:40 +01:00
|
|
|
z-index: v-bind(zIndex);
|
2023-01-10 05:50:34 +01:00
|
|
|
bottom: calc(var(--minBottomSpacing) + var(--margin));
|
|
|
|
right: var(--margin);
|
2020-02-19 19:42:36 +01:00
|
|
|
margin: 0;
|
2023-01-15 03:30:40 +01:00
|
|
|
padding: 12px;
|
2020-02-19 19:42:36 +01:00
|
|
|
font-size: 0.9em;
|
|
|
|
max-width: 320px;
|
2023-01-15 03:30:40 +01:00
|
|
|
}
|
2020-02-19 19:42:36 +01:00
|
|
|
|
2023-01-15 03:30:40 +01:00
|
|
|
.command {
|
|
|
|
margin-top: 8px;
|
|
|
|
}
|
2020-02-19 19:42:36 +01:00
|
|
|
</style>
|