summaryrefslogtreecommitdiff
path: root/packages/frontend/src/components/MkUrlPreview.vue
diff options
context:
space:
mode:
authorzyoshoka <107108195+zyoshoka@users.noreply.github.com>2023-12-07 14:42:09 +0900
committerGitHub <noreply@github.com>2023-12-07 14:42:09 +0900
commit406b4bdbe79b5b0b68fcdcb3c4b6e419460a0258 (patch)
treea1af1cc6102d2db40a687bc848c07cce35bd414f /packages/frontend/src/components/MkUrlPreview.vue
parentfeat: Roleに関するSchemaを追加 (#12572) (diff)
downloadmisskey-406b4bdbe79b5b0b68fcdcb3c4b6e419460a0258.tar.gz
misskey-406b4bdbe79b5b0b68fcdcb3c4b6e419460a0258.tar.bz2
misskey-406b4bdbe79b5b0b68fcdcb3c4b6e419460a0258.zip
refactor(frontend): 非推奨となったReactivity Transformを使わないように (#12539)
* refactor(frontend): 非推奨となったReactivity Transformを使わないように * refactor: 不要な括弧を除去 * fix: 不要なアノテーションを除去 * fix: Refの配列をrefしている部分の対応 * refactor: 不要な括弧を除去 * fix: lint * refactor: Ref、ShallowRef、ComputedRefの変数の宣言をletからconstに置換 * fix: type error * chore: drop reactivity transform from eslint configuration * refactor: remove unnecessary import * fix: 対応漏れ
Diffstat (limited to 'packages/frontend/src/components/MkUrlPreview.vue')
-rw-r--r--packages/frontend/src/components/MkUrlPreview.vue60
1 files changed, 30 insertions, 30 deletions
diff --git a/packages/frontend/src/components/MkUrlPreview.vue b/packages/frontend/src/components/MkUrlPreview.vue
index 2332fe9a7c..f0f1a13d0b 100644
--- a/packages/frontend/src/components/MkUrlPreview.vue
+++ b/packages/frontend/src/components/MkUrlPreview.vue
@@ -83,7 +83,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
-import { defineAsyncComponent, onUnmounted } from 'vue';
+import { defineAsyncComponent, onUnmounted, ref } from 'vue';
import type { summaly } from 'summaly';
import { url as local } from '@/config.js';
import { i18n } from '@/i18n.js';
@@ -107,36 +107,36 @@ const props = withDefaults(defineProps<{
});
const MOBILE_THRESHOLD = 500;
-const isMobile = $ref(deviceKind === 'smartphone' || window.innerWidth <= MOBILE_THRESHOLD);
+const isMobile = ref(deviceKind === 'smartphone' || window.innerWidth <= MOBILE_THRESHOLD);
const self = props.url.startsWith(local);
const attr = self ? 'to' : 'href';
const target = self ? null : '_blank';
-let fetching = $ref(true);
-let title = $ref<string | null>(null);
-let description = $ref<string | null>(null);
-let thumbnail = $ref<string | null>(null);
-let icon = $ref<string | null>(null);
-let sitename = $ref<string | null>(null);
-let sensitive = $ref<boolean>(false);
-let player = $ref({
+const fetching = ref(true);
+const title = ref<string | null>(null);
+const description = ref<string | null>(null);
+const thumbnail = ref<string | null>(null);
+const icon = ref<string | null>(null);
+const sitename = ref<string | null>(null);
+const sensitive = ref<boolean>(false);
+const player = ref({
url: null,
width: null,
height: null,
} as SummalyResult['player']);
-let playerEnabled = $ref(false);
-let tweetId = $ref<string | null>(null);
-let tweetExpanded = $ref(props.detail);
+const playerEnabled = ref(false);
+const tweetId = ref<string | null>(null);
+const tweetExpanded = ref(props.detail);
const embedId = `embed${Math.random().toString().replace(/\D/, '')}`;
-let tweetHeight = $ref(150);
-let unknownUrl = $ref(false);
+const tweetHeight = ref(150);
+const unknownUrl = ref(false);
const requestUrl = new URL(props.url);
if (!['http:', 'https:'].includes(requestUrl.protocol)) throw new Error('invalid url');
if (requestUrl.hostname === 'twitter.com' || requestUrl.hostname === 'mobile.twitter.com' || requestUrl.hostname === 'x.com' || requestUrl.hostname === 'mobile.x.com') {
const m = requestUrl.pathname.match(/^\/.+\/status(?:es)?\/(\d+)/);
- if (m) tweetId = m[1];
+ if (m) tweetId.value = m[1];
}
if (requestUrl.hostname === 'music.youtube.com' && requestUrl.pathname.match('^/(?:watch|channel)')) {
@@ -148,8 +148,8 @@ requestUrl.hash = '';
window.fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${versatileLang}`)
.then(res => {
if (!res.ok) {
- fetching = false;
- unknownUrl = true;
+ fetching.value = false;
+ unknownUrl.value = true;
return;
}
@@ -157,21 +157,21 @@ window.fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${versatileLa
})
.then((info: SummalyResult) => {
if (info.url == null) {
- fetching = false;
- unknownUrl = true;
+ fetching.value = false;
+ unknownUrl.value = true;
return;
}
- fetching = false;
- unknownUrl = false;
+ fetching.value = false;
+ unknownUrl.value = false;
- title = info.title;
- description = info.description;
- thumbnail = info.thumbnail;
- icon = info.icon;
- sitename = info.sitename;
- player = info.player;
- sensitive = info.sensitive ?? false;
+ title.value = info.title;
+ description.value = info.description;
+ thumbnail.value = info.thumbnail;
+ icon.value = info.icon;
+ sitename.value = info.sitename;
+ player.value = info.player;
+ sensitive.value = info.sensitive ?? false;
});
function adjustTweetHeight(message: any) {
@@ -180,7 +180,7 @@ function adjustTweetHeight(message: any) {
if (embed?.method !== 'twttr.private.resize') return;
if (embed?.id !== embedId) return;
const height = embed?.params[0]?.height;
- if (height) tweetHeight = height;
+ if (height) tweetHeight.value = height;
}
const openPlayer = (): void => {