wip
This commit is contained in:
parent
ed86b1706d
commit
0a4642addd
packages/frontend/src
|
@ -82,39 +82,6 @@ export async function mainBoot() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const stream = useStream();
|
|
||||||
|
|
||||||
let reloadDialogShowing = false;
|
|
||||||
stream.on('_disconnected_', async () => {
|
|
||||||
if (prefer.s.serverDisconnectedBehavior === 'reload') {
|
|
||||||
window.location.reload();
|
|
||||||
} else if (prefer.s.serverDisconnectedBehavior === 'dialog') {
|
|
||||||
if (reloadDialogShowing) return;
|
|
||||||
reloadDialogShowing = true;
|
|
||||||
const { canceled } = await confirm({
|
|
||||||
type: 'warning',
|
|
||||||
title: i18n.ts.disconnectedFromServer,
|
|
||||||
text: i18n.ts.reloadConfirm,
|
|
||||||
});
|
|
||||||
reloadDialogShowing = false;
|
|
||||||
if (!canceled) {
|
|
||||||
window.location.reload();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
stream.on('emojiAdded', emojiData => {
|
|
||||||
addCustomEmoji(emojiData.emoji);
|
|
||||||
});
|
|
||||||
|
|
||||||
stream.on('emojiUpdated', emojiData => {
|
|
||||||
updateCustomEmojis(emojiData.emojis);
|
|
||||||
});
|
|
||||||
|
|
||||||
stream.on('emojiDeleted', emojiData => {
|
|
||||||
removeCustomEmojis(emojiData.emojis);
|
|
||||||
});
|
|
||||||
|
|
||||||
launchPlugins();
|
launchPlugins();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -172,8 +139,6 @@ export async function mainBoot() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stream.on('announcementCreated', onAnnouncementCreated);
|
|
||||||
|
|
||||||
if ($i.isDeleted) {
|
if ($i.isDeleted) {
|
||||||
alert({
|
alert({
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
|
@ -351,6 +316,42 @@ export async function mainBoot() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (store.s.realtimeMode) {
|
||||||
|
const stream = useStream();
|
||||||
|
|
||||||
|
let reloadDialogShowing = false;
|
||||||
|
stream.on('_disconnected_', async () => {
|
||||||
|
if (prefer.s.serverDisconnectedBehavior === 'reload') {
|
||||||
|
window.location.reload();
|
||||||
|
} else if (prefer.s.serverDisconnectedBehavior === 'dialog') {
|
||||||
|
if (reloadDialogShowing) return;
|
||||||
|
reloadDialogShowing = true;
|
||||||
|
const { canceled } = await confirm({
|
||||||
|
type: 'warning',
|
||||||
|
title: i18n.ts.disconnectedFromServer,
|
||||||
|
text: i18n.ts.reloadConfirm,
|
||||||
|
});
|
||||||
|
reloadDialogShowing = false;
|
||||||
|
if (!canceled) {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
stream.on('emojiAdded', emojiData => {
|
||||||
|
addCustomEmoji(emojiData.emoji);
|
||||||
|
});
|
||||||
|
|
||||||
|
stream.on('emojiUpdated', emojiData => {
|
||||||
|
updateCustomEmojis(emojiData.emojis);
|
||||||
|
});
|
||||||
|
|
||||||
|
stream.on('emojiDeleted', emojiData => {
|
||||||
|
removeCustomEmojis(emojiData.emojis);
|
||||||
|
});
|
||||||
|
|
||||||
|
stream.on('announcementCreated', onAnnouncementCreated);
|
||||||
|
|
||||||
const main = markRaw(stream.useChannel('main', null, 'System'));
|
const main = markRaw(stream.useChannel('main', null, 'System'));
|
||||||
|
|
||||||
// 自分の情報が更新されたとき
|
// 自分の情報が更新されたとき
|
||||||
|
@ -396,6 +397,7 @@ export async function mainBoot() {
|
||||||
signout();
|
signout();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// shortcut
|
// shortcut
|
||||||
const keymap = {
|
const keymap = {
|
||||||
|
|
|
@ -36,6 +36,7 @@ import { i18n } from '@/i18n.js';
|
||||||
import { infoImageUrl } from '@/instance.js';
|
import { infoImageUrl } from '@/instance.js';
|
||||||
import MkPullToRefresh from '@/components/MkPullToRefresh.vue';
|
import MkPullToRefresh from '@/components/MkPullToRefresh.vue';
|
||||||
import { prefer } from '@/preferences.js';
|
import { prefer } from '@/preferences.js';
|
||||||
|
import { store } from '@/store.js';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
excludeTypes?: typeof notificationTypes[number][];
|
excludeTypes?: typeof notificationTypes[number][];
|
||||||
|
@ -60,8 +61,10 @@ const pagination = computed(() => prefer.r.useGroupedNotifications.value ? {
|
||||||
function onNotification(notification) {
|
function onNotification(notification) {
|
||||||
const isMuted = props.excludeTypes ? props.excludeTypes.includes(notification.type) : false;
|
const isMuted = props.excludeTypes ? props.excludeTypes.includes(notification.type) : false;
|
||||||
if (isMuted || window.document.visibilityState === 'visible') {
|
if (isMuted || window.document.visibilityState === 'visible') {
|
||||||
|
if (store.s.realtimeMode) {
|
||||||
useStream().send('readNotification');
|
useStream().send('readNotification');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!isMuted) {
|
if (!isMuted) {
|
||||||
pagingComponent.value?.prepend(notification);
|
pagingComponent.value?.prepend(notification);
|
||||||
|
@ -76,19 +79,22 @@ function reload() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let connection: Misskey.ChannelConnection<Misskey.Channels['main']>;
|
let connection: Misskey.ChannelConnection<Misskey.Channels['main']> | null = null;
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
if (store.s.realtimeMode) {
|
||||||
connection = useStream().useChannel('main');
|
connection = useStream().useChannel('main');
|
||||||
connection.on('notification', onNotification);
|
connection.on('notification', onNotification);
|
||||||
connection.on('notificationFlushed', reload);
|
connection.on('notificationFlushed', reload);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onActivated(() => {
|
onActivated(() => {
|
||||||
pagingComponent.value?.reload();
|
if (store.s.realtimeMode) {
|
||||||
connection = useStream().useChannel('main');
|
connection = useStream().useChannel('main');
|
||||||
connection.on('notification', onNotification);
|
connection.on('notification', onNotification);
|
||||||
connection.on('notificationFlushed', reload);
|
connection.on('notificationFlushed', reload);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
|
|
@ -28,6 +28,7 @@ import * as sound from '@/utility/sound.js';
|
||||||
import { $i } from '@/i.js';
|
import { $i } from '@/i.js';
|
||||||
import { instance } from '@/instance.js';
|
import { instance } from '@/instance.js';
|
||||||
import { prefer } from '@/preferences.js';
|
import { prefer } from '@/preferences.js';
|
||||||
|
import { store } from '@/store.js';
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
src: BasicTimelineType | 'mentions' | 'directs' | 'list' | 'antenna' | 'channel' | 'role';
|
src: BasicTimelineType | 'mentions' | 'directs' | 'list' | 'antenna' | 'channel' | 'role';
|
||||||
|
@ -94,7 +95,7 @@ let connection: Misskey.ChannelConnection | null = null;
|
||||||
let connection2: Misskey.ChannelConnection | null = null;
|
let connection2: Misskey.ChannelConnection | null = null;
|
||||||
let paginationQuery: Paging | null = null;
|
let paginationQuery: Paging | null = null;
|
||||||
|
|
||||||
const stream = useStream();
|
const stream = store.s.realtimeMode ? useStream() : null;
|
||||||
|
|
||||||
function connectChannel() {
|
function connectChannel() {
|
||||||
if (props.src === 'antenna') {
|
if (props.src === 'antenna') {
|
||||||
|
@ -239,7 +240,7 @@ function updatePaginationQuery() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshEndpointAndChannel() {
|
function refreshEndpointAndChannel() {
|
||||||
if (!prefer.s.disableStreamingTimeline) {
|
if (!prefer.s.disableStreamingTimeline && store.s.realtimeMode) {
|
||||||
disconnectChannel();
|
disconnectChannel();
|
||||||
connectChannel();
|
connectChannel();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ import { $i } from '@/i.js';
|
||||||
import { misskeyApi } from '@/utility/misskey-api.js';
|
import { misskeyApi } from '@/utility/misskey-api.js';
|
||||||
import { get, set } from '@/utility/idb-proxy.js';
|
import { get, set } from '@/utility/idb-proxy.js';
|
||||||
import { store } from '@/store.js';
|
import { store } from '@/store.js';
|
||||||
import { useStream } from '@/stream.js';
|
|
||||||
import { deepClone } from '@/utility/clone.js';
|
import { deepClone } from '@/utility/clone.js';
|
||||||
import { deepMerge } from '@/utility/merge.js';
|
import { deepMerge } from '@/utility/merge.js';
|
||||||
|
|
||||||
|
@ -129,25 +128,6 @@ export class Pizzax<T extends StateDef> {
|
||||||
if (where === 'deviceAccount' && !($i && userId !== $i.id)) return;
|
if (where === 'deviceAccount' && !($i && userId !== $i.id)) return;
|
||||||
this.r[key].value = this.s[key] = value;
|
this.r[key].value = this.s[key] = value;
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($i) {
|
|
||||||
const connection = useStream().useChannel('main');
|
|
||||||
|
|
||||||
// streamingのuser storage updateイベントを監視して更新
|
|
||||||
connection.on('registryUpdated', ({ scope, key, value }: { scope?: string[], key: keyof T, value: T[typeof key]['default'] }) => {
|
|
||||||
if (!scope || scope.length !== 2 || scope[0] !== 'client' || scope[1] !== this.key || this.s[key] === value) return;
|
|
||||||
|
|
||||||
this.r[key].value = this.s[key] = value;
|
|
||||||
|
|
||||||
this.addIdbSetJob(async () => {
|
|
||||||
const cache = await get(this.registryCacheKeyName);
|
|
||||||
if (cache[key] !== value) {
|
|
||||||
cache[key] = value;
|
|
||||||
await set(this.registryCacheKeyName, cache);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private load(): Promise<void> {
|
private load(): Promise<void> {
|
||||||
|
|
|
@ -76,6 +76,10 @@ export const store = markRaw(new Pizzax('base', {
|
||||||
where: 'device',
|
where: 'device',
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
realtimeMode: {
|
||||||
|
where: 'device',
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
recentlyUsedEmojis: {
|
recentlyUsedEmojis: {
|
||||||
where: 'device',
|
where: 'device',
|
||||||
default: [] as string[],
|
default: [] as string[],
|
||||||
|
|
|
@ -58,6 +58,7 @@ import { useStream } from '@/stream.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { prefer } from '@/preferences.js';
|
import { prefer } from '@/preferences.js';
|
||||||
import { globalEvents } from '@/events.js';
|
import { globalEvents } from '@/events.js';
|
||||||
|
import { store } from '@/store.js';
|
||||||
|
|
||||||
const XStreamIndicator = defineAsyncComponent(() => import('./stream-indicator.vue'));
|
const XStreamIndicator = defineAsyncComponent(() => import('./stream-indicator.vue'));
|
||||||
const XUpload = defineAsyncComponent(() => import('./upload.vue'));
|
const XUpload = defineAsyncComponent(() => import('./upload.vue'));
|
||||||
|
@ -70,8 +71,10 @@ function onNotification(notification: Misskey.entities.Notification, isClient =
|
||||||
if (window.document.visibilityState === 'visible') {
|
if (window.document.visibilityState === 'visible') {
|
||||||
if (!isClient && notification.type !== 'test') {
|
if (!isClient && notification.type !== 'test') {
|
||||||
// サーバーサイドのテスト通知の際は自動で既読をつけない(テストできないので)
|
// サーバーサイドのテスト通知の際は自動で既読をつけない(テストできないので)
|
||||||
|
if (store.s.realtimeMode) {
|
||||||
useStream().send('readNotification');
|
useStream().send('readNotification');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
notifications.value.unshift(notification);
|
notifications.value.unshift(notification);
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
|
@ -87,8 +90,10 @@ function onNotification(notification: Misskey.entities.Notification, isClient =
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($i) {
|
if ($i) {
|
||||||
|
if (store.s.realtimeMode) {
|
||||||
const connection = useStream().useChannel('main', null, 'UI');
|
const connection = useStream().useChannel('main', null, 'UI');
|
||||||
connection.on('notification', onNotification);
|
connection.on('notification', onNotification);
|
||||||
|
}
|
||||||
globalEvents.on('clientNotification', notification => onNotification(notification, true));
|
globalEvents.on('clientNotification', notification => onNotification(notification, true));
|
||||||
|
|
||||||
//#region Listen message from SW
|
//#region Listen message from SW
|
||||||
|
|
|
@ -20,6 +20,7 @@ import { i18n } from '@/i18n.js';
|
||||||
import MkButton from '@/components/MkButton.vue';
|
import MkButton from '@/components/MkButton.vue';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
import { prefer } from '@/preferences.js';
|
import { prefer } from '@/preferences.js';
|
||||||
|
import { store } from '@/store.js';
|
||||||
|
|
||||||
const zIndex = os.claimZIndex('high');
|
const zIndex = os.claimZIndex('high');
|
||||||
|
|
||||||
|
@ -37,11 +38,13 @@ function reload() {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
useStream().on('_disconnected_', onDisconnected);
|
if (store.s.realtimeMode) {
|
||||||
|
useStream().on('_disconnected_', onDisconnected);
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
useStream().off('_disconnected_', onDisconnected);
|
useStream().off('_disconnected_', onDisconnected);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" module>
|
<style lang="scss" module>
|
||||||
|
|
|
@ -4,10 +4,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { onUnmounted } from 'vue';
|
import { onUnmounted } from 'vue';
|
||||||
import type { Ref, ShallowRef } from 'vue';
|
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
|
import type { Ref, ShallowRef } from 'vue';
|
||||||
import { useStream } from '@/stream.js';
|
import { useStream } from '@/stream.js';
|
||||||
import { $i } from '@/i.js';
|
import { $i } from '@/i.js';
|
||||||
|
import { store } from '@/store.js';
|
||||||
|
|
||||||
export function useNoteCapture(props: {
|
export function useNoteCapture(props: {
|
||||||
rootEl: ShallowRef<HTMLElement | undefined>;
|
rootEl: ShallowRef<HTMLElement | undefined>;
|
||||||
|
@ -17,7 +18,7 @@ export function useNoteCapture(props: {
|
||||||
}) {
|
}) {
|
||||||
const note = props.note;
|
const note = props.note;
|
||||||
const pureNote = props.pureNote;
|
const pureNote = props.pureNote;
|
||||||
const connection = $i ? useStream() : null;
|
const connection = $i && store.s.realtimeMode ? useStream() : null;
|
||||||
|
|
||||||
function onStreamNoteUpdated(noteData): void {
|
function onStreamNoteUpdated(noteData): void {
|
||||||
const { type, id, body } = noteData;
|
const { type, id, body } = noteData;
|
||||||
|
|
Loading…
Reference in New Issue