unify postHeight

This commit is contained in:
kakkokari-gtyih 2024-11-19 09:09:15 +09:00
parent 6df2a74747
commit 23610e8c32

View file

@ -32,7 +32,7 @@ SPDX-License-Identifier: AGPL-3.0-only
allow="fullscreen;web-share" allow="fullscreen;web-share"
sandbox="allow-popups allow-popups-to-escape-sandbox allow-scripts allow-same-origin" sandbox="allow-popups allow-popups-to-escape-sandbox allow-scripts allow-same-origin"
scrolling="no" scrolling="no"
:style="{ position: 'relative', width: '100%', height: `${tweetHeight}px`, border: 0 }" :style="{ position: 'relative', width: '100%', height: `${postHeight}px`, border: 0 }"
:src="`https://platform.twitter.com/embed/index.html?embedId=${embedId}&hideCard=false&hideThread=false&lang=en&theme=${defaultStore.state.darkMode ? 'dark' : 'light'}&id=${tweetId}`" :src="`https://platform.twitter.com/embed/index.html?embedId=${embedId}&hideCard=false&hideThread=false&lang=en&theme=${defaultStore.state.darkMode ? 'dark' : 'light'}&id=${tweetId}`"
></iframe> ></iframe>
</div> </div>
@ -48,7 +48,7 @@ SPDX-License-Identifier: AGPL-3.0-only
allow="fullscreen;web-share" allow="fullscreen;web-share"
sandbox="allow-popups allow-popups-to-escape-sandbox allow-scripts allow-same-origin" sandbox="allow-popups allow-popups-to-escape-sandbox allow-scripts allow-same-origin"
scrolling="no" scrolling="no"
:style="{ position: 'relative', width: '100%', height: `${bskyPostHeight}px`, border: 0 }" :style="{ position: 'relative', width: '100%', height: `${postHeight}px`, border: 0 }"
:src="`https://embed.bsky.app/embed/${bskyDid}/app.bsky.feed.post/${bskyPostRecordKey}?id=${embedId}`" :src="`https://embed.bsky.app/embed/${bskyDid}/app.bsky.feed.post/${bskyPostRecordKey}?id=${embedId}`"
></iframe> ></iframe>
</div> </div>
@ -149,14 +149,13 @@ const playerEnabled = ref(false);
const embedId = `embed${Math.random().toString().replace(/\D/, '')}`; const embedId = `embed${Math.random().toString().replace(/\D/, '')}`;
const postExpanded = ref(props.detail); const postExpanded = ref(props.detail);
const postHeight = ref(150);
const tweetId = ref<string | null>(null); const tweetId = ref<string | null>(null);
const tweetHeight = ref(150);
const bskyHandleOrDid = ref<string | null>(null); const bskyHandleOrDid = ref<string | null>(null);
const bskyDid = ref<string | null>(null); const bskyDid = ref<string | null>(null);
const bskyPostRecordKey = ref<string | null>(null); const bskyPostRecordKey = ref<string | null>(null);
const bskyPostHeight = ref(150);
const unknownUrl = ref(false); const unknownUrl = ref(false);
@ -255,12 +254,12 @@ function adjustSocialsEmbedHeight(message: MessageEvent) {
const embed = message.data?.['twttr.embed']; const embed = message.data?.['twttr.embed'];
if (embed?.method === 'twttr.private.resize' && embed?.id === embedId) { if (embed?.method === 'twttr.private.resize' && embed?.id === embedId) {
const height = embed?.params[0]?.height; const height = embed?.params[0]?.height;
if (height) tweetHeight.value = height; if (height) postHeight.value = height;
} }
} else if (message.origin === 'https://embed.bsky.app') { } else if (message.origin === 'https://embed.bsky.app') {
if (message.data?.id === embedId) { if (message.data?.id === embedId) {
const height = message.data?.height; const height = message.data?.height;
if (height) bskyPostHeight.value = height; if (height) postHeight.value = height;
} }
} }
} }