Better document titles for pop-out compose window
This commit is contained in:
parent
95519a538e
commit
2ddc1b8005
2 changed files with 11 additions and 6 deletions
|
@ -9,6 +9,7 @@ import { useEffect, useState } from 'preact/hooks';
|
||||||
|
|
||||||
import Compose from './components/compose';
|
import Compose from './components/compose';
|
||||||
import store from './utils/store';
|
import store from './utils/store';
|
||||||
|
import useTitle from './utils/useTitle';
|
||||||
|
|
||||||
if (window.opener) {
|
if (window.opener) {
|
||||||
console = window.opener.console;
|
console = window.opener.console;
|
||||||
|
@ -41,11 +42,15 @@ function App() {
|
||||||
|
|
||||||
const { editStatus, replyToStatus, draftStatus } = window.__COMPOSE__ || {};
|
const { editStatus, replyToStatus, draftStatus } = window.__COMPOSE__ || {};
|
||||||
|
|
||||||
useEffect(() => {
|
useTitle(
|
||||||
if (uiState === 'closed') {
|
editStatus
|
||||||
window.close();
|
? 'Editing source status'
|
||||||
}
|
: replyToStatus
|
||||||
}, [uiState]);
|
? `Replying to @${
|
||||||
|
replyToStatus.account?.acct || replyToStatus.account?.username
|
||||||
|
}`
|
||||||
|
: 'Compose',
|
||||||
|
);
|
||||||
|
|
||||||
if (uiState === 'closed') {
|
if (uiState === 'closed') {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -4,6 +4,6 @@ const { VITE_CLIENT_NAME: CLIENT_NAME } = import.meta.env;
|
||||||
|
|
||||||
export default (title) => {
|
export default (title) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.title = title ? `${title} - ${CLIENT_NAME}` : CLIENT_NAME;
|
document.title = title ? `${title} / ${CLIENT_NAME}` : CLIENT_NAME;
|
||||||
}, [title]);
|
}, [title]);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue