diff --git a/package.json b/package.json
index 6787981..d36e4db 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,7 @@
"build-en": "npm run extract && npm run minify-css",
"webpack": "webpack --config ./webpack.config.web.babel.js && parallel-webpack --config ./webpack.config.client.babel.js",
"minify-css": "babel-node scripts/minifyCss.js",
- "extract": "webpack --env extract --config ./webpack.config.web.babel.js && webpack --env extract --env debug --config ./webpack.config.client.babel.js",
+ "extract": "webpack --env extract --config ./webpack.config.web.babel.js && webpack --env extract --config ./webpack.config.client.babel.js",
"babel-node": "cd $INIT_CWD && babel-node",
"lint": "cd $INIT_CWD && eslint --ext .jsx --ext .js",
"lint:src": "eslint --ext .jsx --ext .js src",
diff --git a/src/actions/index.js b/src/actions/index.js
index fc43e7f..b3a76b5 100644
--- a/src/actions/index.js
+++ b/src/actions/index.js
@@ -593,14 +593,14 @@ export function showModal(modalType: string, title: string): Action {
export function showSettingsModal(): Action {
return showModal(
'SETTINGS',
- t`Settings`,
+ '',
);
}
export function showUserAreaModal(): Action {
return showModal(
'USERAREA',
- t`User Area`,
+ '',
);
}
@@ -613,6 +613,14 @@ export function changeWindowType(windowId, windowType, args = null) {
};
}
+export function setWindowTitle(windowId, title) {
+ return {
+ type: 'SET_WINDOW_TITLE',
+ windowId,
+ title,
+ };
+}
+
export function showRegisterModal(): Action {
return showModal(
'REGISTER',
@@ -636,14 +644,14 @@ export function showHelpModal(): Action {
export function showArchiveModal(): Action {
return showModal(
'ARCHIVE',
- t`Canvas Archive`,
+ t`Look at past Canvases`,
);
}
export function showCanvasSelectionModal(): Action {
return showModal(
'CANVAS_SELECTION',
- t`Canvas Selection`,
+ '',
);
}
@@ -831,7 +839,7 @@ export function hideAllWindowTypes(
export function openChatWindow(): Action {
return openWindow(
'CHAT',
- t`Chat`,
+ '',
false,
true,
{ chatChannel: 1, inputMessage: '' },
diff --git a/src/actions/types.js b/src/actions/types.js
index 27c6c53..52f1886 100644
--- a/src/actions/types.js
+++ b/src/actions/types.js
@@ -99,6 +99,7 @@ export type Action =
windowType: number,
args: Object,
}
+ | { type: 'SET_WINDOW_TITLE', windowId: number, title: string }
| { type: 'BLOCK_USER', userId: number, userName: string }
| { type: 'UNBLOCK_USER', userId: number, userName: string }
| { type: 'SET_BLOCKING_DM', blockDm: boolean }
diff --git a/src/components/ModalRoot.jsx b/src/components/ModalRoot.jsx
index 2ea7b93..b7a698c 100644
--- a/src/components/ModalRoot.jsx
+++ b/src/components/ModalRoot.jsx
@@ -44,7 +44,7 @@ const ModalRoot = () => {
return null;
}
- const Content = COMPONENTS[windowType];
+ const [Content, name] = COMPONENTS[windowType];
return (
(render || open)
@@ -60,7 +60,7 @@ const ModalRoot = () => {
-
{title}
+
{(title) ? `${name} - ${title}` : name}
dispatch(closeWindow(0))}
className="ModalClose"
diff --git a/src/components/Window.jsx b/src/components/Window.jsx
index 7c898d5..8612cd9 100644
--- a/src/components/Window.jsx
+++ b/src/components/Window.jsx
@@ -87,7 +87,7 @@ const Window = ({ id }) => {
}, 10);
}, [open, hidden]);
- const Content = COMPONENTS[windowType];
+ const [Content, name] = COMPONENTS[windowType];
if (!render && hidden) {
return null;
@@ -123,7 +123,7 @@ const Window = ({ id }) => {
ref={titleBarRef}
title={t`Move`}
>
- {title}
+ {(title) ? `${name} - ${title}` : name}
{
event.preventDefault();
event.stopPropagation();
- startHandler && startHandler();
+ if (startHandler) startHandler();
let {
clientX: startX,
diff --git a/src/components/windows/Chat.jsx b/src/components/windows/Chat.jsx
index 395a486..61d67db 100644
--- a/src/components/windows/Chat.jsx
+++ b/src/components/windows/Chat.jsx
@@ -19,6 +19,7 @@ import {
setChatInputMessage,
fetchChatMessages,
showContextMenu,
+ setWindowTitle,
} from '../../actions';
import ProtocolClient from '../../socket/ProtocolClient';
import splitChatMessage from '../../core/chatMessageFilter';
@@ -39,9 +40,9 @@ const Chat = ({
const dispatch = useDispatch();
- const setChannel = useCallback((cid) => dispatch(
- setChatChannel(windowId, cid),
- ), [dispatch]);
+ const setChannel = useCallback((cid) => {
+ dispatch(setChatChannel(windowId, cid));
+ }, [dispatch]);
const ownName = useSelector((state) => state.user.name);
// eslint-disable-next-line max-len
@@ -61,6 +62,13 @@ const Chat = ({
dispatch(fetchChatMessages(chatChannel));
}
+ useEffect(() => {
+ if (channels[chatChannel]) {
+ const channelName = channels[chatChannel][0];
+ dispatch(setWindowTitle(windowId, `Chan: ${channelName}`));
+ }
+ }, [chatChannel]);
+
useLayoutEffect(() => {
stayScrolled();
}, [channelMessages.length]);
diff --git a/src/components/windows/index.js b/src/components/windows/index.js
new file mode 100644
index 0000000..8d997a1
--- /dev/null
+++ b/src/components/windows/index.js
@@ -0,0 +1,25 @@
+/*
+ * @flow
+ */
+import { t } from 'ttag';
+
+import Help from './Help';
+import Settings from './Settings';
+import UserArea from './UserArea';
+import Register from './Register';
+import CanvasSelect from './CanvasSelect';
+import Archive from './Archive';
+import Chat from './Chat';
+import ForgotPassword from './ForgotPassword';
+
+export default {
+ HELP: [Help, t`Help`],
+ SETTINGS: [Settings, t`Settings`],
+ USERAREA: [UserArea, t`User Area`],
+ REGISTER: [Register, t`Registration`],
+ FORGOT_PASSWORD: [ForgotPassword, t`Forgot Password`],
+ CHAT: [Chat, t`Chat`],
+ CANVAS_SELECTION: [CanvasSelect, t`Canvas Selection`],
+ ARCHIVE: [Archive, t`Canvas Archive`],
+ /* other windows */
+};
diff --git a/src/components/windows/index.jsx b/src/components/windows/index.jsx
deleted file mode 100644
index fb7b36b..0000000
--- a/src/components/windows/index.jsx
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * @flow
- */
-import Help from './Help';
-import Settings from './Settings';
-import UserArea from './UserArea';
-import Register from './Register';
-import CanvasSelect from './CanvasSelect';
-import Archive from './Archive';
-import Chat from './Chat';
-import ForgotPassword from './ForgotPassword';
-
-export default {
- NONE: null,
- HELP: Help,
- SETTINGS: Settings,
- USERAREA: UserArea,
- REGISTER: Register,
- FORGOT_PASSWORD: ForgotPassword,
- CHAT: Chat,
- CANVAS_SELECTION: CanvasSelect,
- ARCHIVE: Archive,
- /* other windows */
-};
diff --git a/src/reducers/windows.js b/src/reducers/windows.js
index 44ab288..2e1377c 100644
--- a/src/reducers/windows.js
+++ b/src/reducers/windows.js
@@ -199,7 +199,7 @@ export default function windows(
}
const windowId = generateWindowId(state);
const newZMax = state.zMax + 1;
- let newWindows = [
+ const newWindows = [
...state.windows,
{
windowId,
@@ -378,6 +378,7 @@ export default function windows(
modal: {
...state.modal,
windowType,
+ title: '',
},
};
}
@@ -386,6 +387,7 @@ export default function windows(
return {
...win,
windowType,
+ title: '',
};
});
return {
@@ -403,7 +405,7 @@ export default function windows(
windows: oldWindows, zMax,
} = state;
- let newWindows = [];
+ const newWindows = [];
for (let i = 0; i < oldWindows.length; i += 1) {
const win = oldWindows[i];
@@ -628,6 +630,24 @@ export default function windows(
};
}
+ case 'SET_WINDOW_TITLE': {
+ const {
+ windowId,
+ title,
+ } = action;
+ const newWindows = state.windows.map((win) => {
+ if (win.windowId !== windowId) return win;
+ return {
+ ...win,
+ title,
+ };
+ });
+ return {
+ ...state,
+ windows: newWindows,
+ };
+ }
+
/*
* args specific actions
*/