From 2ddc1b80053c4d10ae3b521c215c515058518ba4 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 15 Dec 2022 17:11:15 +0800 Subject: [PATCH] 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]); };