1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-24 12:44:04 +02:00

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

View File

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