enhance(frontend): いくつかのtodoの解消 (#17154)

This commit is contained in:
かっこかり
2026-02-15 12:08:10 +09:00
committed by GitHub
parent d4bc753e72
commit 799f5ab504
2 changed files with 21 additions and 6 deletions

View File

@@ -114,7 +114,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { watch, nextTick, onMounted, defineAsyncComponent, provide, shallowRef, ref, computed, useTemplateRef, onUnmounted } from 'vue';
import { watch, nextTick, onMounted, defineAsyncComponent, provide, shallowRef, ref, computed, useTemplateRef, onUnmounted, onBeforeUnmount } from 'vue';
import * as mfm from 'mfm-js';
import * as Misskey from 'misskey-js';
import insertTextAtCursor from 'insert-text-at-cursor';
@@ -227,6 +227,10 @@ const targetChannel = shallowRef(props.channel);
const serverDraftId = ref<string | null>(null);
const postFormActions = getPluginHandlers('post_form_action');
let textAutocomplete: Autocomplete | null = null;
let cwAutocomplete: Autocomplete | null = null;
let hashtagAutocomplete: Autocomplete | null = null;
const uploader = useUploader({
multiple: true,
});
@@ -1408,10 +1412,9 @@ onMounted(() => {
});
}
// TODO: detach when unmount
if (textareaEl.value) new Autocomplete(textareaEl.value, text);
if (cwInputEl.value) new Autocomplete(cwInputEl.value, cw);
if (hashtagsInputEl.value) new Autocomplete(hashtagsInputEl.value, hashtags);
if (textareaEl.value) textAutocomplete = new Autocomplete(textareaEl.value, text);
if (cwInputEl.value) cwAutocomplete = new Autocomplete(cwInputEl.value, cw);
if (hashtagsInputEl.value) hashtagAutocomplete = new Autocomplete(hashtagsInputEl.value, hashtags);
nextTick(() => {
// 書きかけの投稿を復元
@@ -1468,6 +1471,19 @@ onMounted(() => {
});
});
onBeforeUnmount(() => {
uploader.abortAll();
if (textAutocomplete) {
textAutocomplete.detach();
}
if (cwAutocomplete) {
cwAutocomplete.detach();
}
if (hashtagAutocomplete) {
hashtagAutocomplete.detach();
}
});
async function canClose() {
if (!uploader.allItemsUploaded.value) {
const { canceled } = await os.confirm({

View File

@@ -18,7 +18,6 @@ let lastHeartbeatCall = 0;
export function useStream(): Misskey.IStream {
if (stream) return stream;
// TODO: No Websocketモードもここで判定
stream = markRaw(new Misskey.Stream(wsOrigin, $i ? {
token: $i.token,
} : null));