From a5177b3b70a17ac1991605d2c9a10146d4920f73 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 15 Dec 2022 16:54:14 +0800 Subject: [PATCH 1/6] Try disable version check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some Mastodon instances have invalid semver 🤦‍♂️ E.g. social.treehouse.systems = v4.0.1+glitch+th --- src/app.jsx | 2 ++ src/compose.jsx | 1 + 2 files changed, 3 insertions(+) diff --git a/src/app.jsx b/src/app.jsx index bfc03417..5613c658 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -143,6 +143,7 @@ export function App() { window.masto = await login({ url: `https://${instanceURL}`, accessToken, + disableVersionCheck: true, }); const mastoAccount = await masto.accounts.verifyCredentials(); @@ -183,6 +184,7 @@ export function App() { window.masto = await login({ url: `https://${instanceURL}`, accessToken, + disableVersionCheck: true, }); setIsLoggedIn(true); } catch (e) { diff --git a/src/compose.jsx b/src/compose.jsx index 0b37f119..be5d3d4d 100644 --- a/src/compose.jsx +++ b/src/compose.jsx @@ -27,6 +27,7 @@ if (window.opener) { window.masto = await login({ url: `https://${instanceURL}`, accessToken, + disableVersionCheck: true, }); console.info('Logged in successfully.'); } catch (e) { From 95519a538ec34be59f023de03eb8057f30aee67f Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 15 Dec 2022 17:00:11 +0800 Subject: [PATCH 2/6] Some breathing space for "Show more" button --- src/pages/notifications.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/notifications.jsx b/src/pages/notifications.jsx index 7652878f..4a4c4720 100644 --- a/src/pages/notifications.jsx +++ b/src/pages/notifications.jsx @@ -338,6 +338,7 @@ export default () => { class="plain block" disabled={uiState === 'loading'} onClick={() => loadNotifications()} + style={{ marginBlockEnd: '6em' }} > {uiState === 'loading' ? : <>Show more…} From 2ddc1b80053c4d10ae3b521c215c515058518ba4 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 15 Dec 2022 17:11:15 +0800 Subject: [PATCH 3/6] Better document titles for pop-out compose window --- src/compose.jsx | 15 ++++++++++----- src/utils/useTitle.js | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/compose.jsx b/src/compose.jsx index be5d3d4d..cdf13a88 100644 --- a/src/compose.jsx +++ b/src/compose.jsx @@ -9,6 +9,7 @@ import { useEffect, useState } from 'preact/hooks'; import Compose from './components/compose'; import store from './utils/store'; +import useTitle from './utils/useTitle'; if (window.opener) { console = window.opener.console; @@ -41,11 +42,15 @@ function App() { const { editStatus, replyToStatus, draftStatus } = window.__COMPOSE__ || {}; - useEffect(() => { - if (uiState === 'closed') { - window.close(); - } - }, [uiState]); + useTitle( + editStatus + ? 'Editing source status' + : replyToStatus + ? `Replying to @${ + replyToStatus.account?.acct || replyToStatus.account?.username + }` + : 'Compose', + ); if (uiState === 'closed') { return ( diff --git a/src/utils/useTitle.js b/src/utils/useTitle.js index 86007a14..70e297cf 100644 --- a/src/utils/useTitle.js +++ b/src/utils/useTitle.js @@ -4,6 +4,6 @@ const { VITE_CLIENT_NAME: CLIENT_NAME } = import.meta.env; export default (title) => { useEffect(() => { - document.title = title ? `${title} - ${CLIENT_NAME}` : CLIENT_NAME; + document.title = title ? `${title} / ${CLIENT_NAME}` : CLIENT_NAME; }, [title]); }; From 94dd2bf6278e07725061eef3f918175b6b192067 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 15 Dec 2022 17:14:33 +0800 Subject: [PATCH 4/6] Fix spoiler content accidentally get leaked in document.title - Also add quotes - Add comment to why use 64 chars (soft) limit --- src/pages/status.jsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/pages/status.jsx b/src/pages/status.jsx index f0b3452d..1f2b8d7f 100644 --- a/src/pages/status.jsx +++ b/src/pages/status.jsx @@ -111,18 +111,25 @@ export default ({ id }) => { }, [heroStatus]); const heroContentText = useMemo(() => { if (!heroStatus) return ''; - const { content } = heroStatus; - const div = document.createElement('div'); - div.innerHTML = content; - let text = div.innerText.trim(); + const { spoilerText, content } = heroStatus; + let text; + if (spoilerText) { + text = spoilerText; + } else { + const div = document.createElement('div'); + div.innerHTML = content; + text = div.innerText.trim(); + } if (text.length > 64) { + // "The title should ideally be less than 64 characters in length" + // https://www.w3.org/Provider/Style/TITLE.html text = text.slice(0, 64) + '…'; } return text; }, [heroStatus]); useTitle( heroDisplayName && heroContentText - ? `${heroDisplayName}: ${heroContentText}` + ? `${heroDisplayName}: "${heroContentText}"` : 'Status', ); From 5314f071b29cf98bed0bf75c374c988bdeef37b1 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 15 Dec 2022 17:14:48 +0800 Subject: [PATCH 5/6] Mention which branch goes to which domains --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 82b4c7ae..7a6d3583 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ Phanpy This is an alternative web client for [Mastodon](https://joinmastodon.org/). -🔗 **Production**: https://phanpy.social
-🔗 **Development**: https://dev.phanpy.social +🔗 **Production**: https://phanpy.social (`production` branch)
+🔗 **Development**: https://dev.phanpy.social (`main` branch, may break more often) Everything is designed and engineered for my own use case, following my taste and vision. This is a personal side project for me to learn about Mastodon and experiment with new UI/UX ideas. From 332dd30c1d1473df34ee696e4353a2c3ef1bfa10 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 15 Dec 2022 17:27:28 +0800 Subject: [PATCH 6/6] Writing logic code is hard --- src/components/status.jsx | 67 ++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/src/components/status.jsx b/src/components/status.jsx index 03f0e76a..595361ba 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -662,39 +662,40 @@ function Status({ )} {' '} - {size !== 'l' && uri ? ( - - {' '} - - {createdAtDate.toLocaleString()} - - - ) : ( - - {' '} - - {createdAtDate.toLocaleString()} - - - )} + {size !== 'l' && + (uri ? ( + + {' '} + + {createdAtDate.toLocaleString()} + + + ) : ( + + {' '} + + {createdAtDate.toLocaleString()} + + + ))}