From e0688afdfc566760fbedb407219f11c928636454 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 16 Mar 2023 00:33:58 +0800 Subject: [PATCH 1/3] Need a default view mode selection if null --- src/components/shortcuts-settings.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/shortcuts-settings.jsx b/src/components/shortcuts-settings.jsx index 77bdbf0b..15334e39 100644 --- a/src/components/shortcuts-settings.jsx +++ b/src/components/shortcuts-settings.jsx @@ -235,7 +235,11 @@ function ShortcutsSettings() { type="radio" name="shortcuts-view-mode" value={value} - checked={snapStates.settings.shortcutsViewMode === value} + checked={ + snapStates.settings.shortcutsViewMode === value || + (value === 'float-button' && + !snapStates.settings.shortcutsViewMode) + } onChange={(e) => { states.settings.shortcutsViewMode = e.target.value; }} From bc4dfaf62f800c222a9332c3674ab6113f88185d Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 16 Mar 2023 13:02:46 +0800 Subject: [PATCH 2/3] Add previewMode --- src/components/compose.jsx | 4 ++-- src/components/status.jsx | 7 +++++-- src/utils/handle-content-links.js | 32 ++++++++++++++++--------------- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/components/compose.jsx b/src/components/compose.jsx index 76f595c6..981516b2 100644 --- a/src/components/compose.jsx +++ b/src/components/compose.jsx @@ -633,7 +633,7 @@ function Compose({ {!!replyToStatus && (
- +
Replying to @ {replyToStatus.account.acct || replyToStatus.account.username} @@ -643,7 +643,7 @@ function Compose({ )} {!!editStatus && (
- +
Editing source status
)} diff --git a/src/components/status.jsx b/src/components/status.jsx index 8494538b..edbed593 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -70,6 +70,7 @@ function Status({ readOnly, contentTextWeight, enableTranslate, + previewMode, }) { if (skeleton) { return ( @@ -578,6 +579,7 @@ function Status({ onContextMenu={(e) => { if (size === 'l') return; if (e.metaKey) return; + if (previewMode) return; // console.log('context menu', e); const link = e.target.closest('a'); if (link && /^https?:\/\//.test(link.getAttribute('href'))) return; @@ -662,7 +664,7 @@ function Status({ )} */} {/* */}{' '} {size !== 'l' && - (url ? ( + (url && !previewMode ? ( { let { target } = e; target = target.closest('a'); @@ -35,20 +35,22 @@ function handleContentLinks(opts) { instance, }; } - } else if (target.classList.contains('hashtag')) { - e.preventDefault(); - e.stopPropagation(); - const tag = target.innerText.replace(/^#/, '').trim(); - const hashURL = instance ? `#/${instance}/t/${tag}` : `#/t/${tag}`; - console.log({ hashURL }); - location.hash = hashURL; - } else if (states.unfurledLinks[target.href]?.url) { - e.preventDefault(); - e.stopPropagation(); - states.prevLocation = { - pathname: location.hash.replace(/^#/, ''), - }; - location.hash = `#${states.unfurledLinks[target.href].url}`; + } else if (!previewMode) { + if (target.classList.contains('hashtag')) { + e.preventDefault(); + e.stopPropagation(); + const tag = target.innerText.replace(/^#/, '').trim(); + const hashURL = instance ? `#/${instance}/t/${tag}` : `#/t/${tag}`; + console.log({ hashURL }); + location.hash = hashURL; + } else if (states.unfurledLinks[target.href]?.url) { + e.preventDefault(); + e.stopPropagation(); + states.prevLocation = { + pathname: location.hash.replace(/^#/, ''), + }; + location.hash = `#${states.unfurledLinks[target.href].url}`; + } } }; } From 16c52ad3ea928e34ed9975d385dfe595595fa381 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 16 Mar 2023 16:16:15 +0800 Subject: [PATCH 3/3] Possible fix for weird truncation bug --- src/components/status.jsx | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/components/status.jsx b/src/components/status.jsx index edbed593..92d83af3 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -211,10 +211,14 @@ function Status({ onResize: () => { if (spoilerContentRef.current) { const { scrollHeight, clientHeight } = spoilerContentRef.current; - spoilerContentRef.current.classList.toggle( - 'truncated', - scrollHeight > clientHeight, - ); + if (scrollHeight < window.innerHeight * 0.4) { + spoilerContentRef.current.classList.remove('truncated'); + } else { + spoilerContentRef.current.classList.toggle( + 'truncated', + scrollHeight > clientHeight, + ); + } } }, }); @@ -224,10 +228,14 @@ function Status({ onResize: () => { if (contentRef.current) { const { scrollHeight, clientHeight } = contentRef.current; - contentRef.current.classList.toggle( - 'truncated', - scrollHeight > clientHeight, - ); + if (scrollHeight < window.innerHeight * 0.4) { + contentRef.current.classList.remove('truncated'); + } else { + contentRef.current.classList.toggle( + 'truncated', + scrollHeight > clientHeight, + ); + } } }, });