Better document titles for pop-out compose window

This commit is contained in:
Lim Chee Aun 2022-12-15 17:11:15 +08:00
parent 95519a538e
commit 2ddc1b8005
2 changed files with 11 additions and 6 deletions

View file

@ -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 (

View file

@ -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]);
};