Better document titles for pop-out compose window
This commit is contained in:
parent
95519a538e
commit
2ddc1b8005
|
@ -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 (
|
||||
|
|
|
@ -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]);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue