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

58 lines
1.3 KiB
Vue
Raw Normal View History

<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-01-15 03:30:40 +01: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';
import { useStream } from '@/stream';
2022-07-20 15:24:26 +02:00
import { i18n } from '@/i18n';
2023-01-15 03:30:40 +01:00
import MkButton from '@/components/MkButton.vue';
import * as os from '@/os';
2023-04-01 06:42:40 +02:00
import { defaultStore } from '@/store';
2023-01-15 03:30:40 +01: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 03:30:40 +01:00
<style lang="scss" module>
.root {
position: fixed;
2023-01-15 03:30:40 +01:00
z-index: v-bind(zIndex);
bottom: calc(var(--minBottomSpacing) + var(--margin));
right: var(--margin);
margin: 0;
2023-01-15 03:30:40 +01:00
padding: 12px;
font-size: 0.9em;
max-width: 320px;
2023-01-15 03:30:40 +01:00
}
2023-01-15 03:30:40 +01:00
.command {
margin-top: 8px;
}
</style>