misskey-awawa/packages/frontend/src/ui/_common_/stream-indicator.vue

63 lines
1.4 KiB
Vue
Raw Normal View History

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