diff --git a/src/actions/index.js b/src/actions/index.js
index be0c106..c5b8d75 100644
--- a/src/actions/index.js
+++ b/src/actions/index.js
@@ -567,6 +567,26 @@ export function initTimer(): ThunkAction {
};
}
+/*
+ * fullscreen means to open as modal
+ */
+export function openWindow(
+ windowType: string,
+ title: string,
+ fullscreen: boolean,
+ cloneable: boolean,
+ args: Object,
+): Action {
+ return {
+ type: 'OPEN_WINDOW',
+ windowType,
+ title,
+ fullscreen,
+ cloneable,
+ args,
+ };
+}
+
export function showModal(modalType: string, title: string): Action {
return openWindow(
modalType,
@@ -735,26 +755,6 @@ export function addToChatInputMessage(windowId: number, msg: string): Action {
};
}
-/*
- * fullscreen means to open as modal
- */
-export function openWindow(
- windowType: string,
- title: string,
- fullscreen: boolean,
- cloneable: boolean,
- args: Object,
-): Action {
- return {
- type: 'OPEN_WINDOW',
- windowType,
- title,
- fullscreen,
- cloneable,
- args,
- };
-}
-
export function closeWindow(windowId): Action {
return {
type: 'CLOSE_WINDOW',
diff --git a/src/components/ChannelDropDown.jsx b/src/components/ChannelDropDown.jsx
index f689c50..7854179 100644
--- a/src/components/ChannelDropDown.jsx
+++ b/src/components/ChannelDropDown.jsx
@@ -11,8 +11,6 @@ import { useSelector } from 'react-redux';
import { MdChat } from 'react-icons/md';
import { FaUserFriends } from 'react-icons/fa';
-import type { State } from '../reducers';
-
const ChannelDropDown = ({
setChatChannel,
chatChannel,
diff --git a/src/components/ModalRoot.jsx b/src/components/ModalRoot.jsx
index f11d919..49e70f1 100644
--- a/src/components/ModalRoot.jsx
+++ b/src/components/ModalRoot.jsx
@@ -55,7 +55,7 @@ const ModalRoot = () => {
-
{title}
+
{title}
dispatch(closeWindow(0))}
className="ModalClose"
@@ -71,8 +71,8 @@ const ModalRoot = () => {
label="restore"
title={t`Restore`}
tabIndex={-1}
- >♥
-
+ >↓
+
,
diff --git a/src/components/UserContextMenu.jsx b/src/components/UserContextMenu.jsx
index 0146a28..6d81929 100644
--- a/src/components/UserContextMenu.jsx
+++ b/src/components/UserContextMenu.jsx
@@ -17,9 +17,7 @@ import {
setChatChannel,
} from '../actions';
-const UserContextMenu = ({
- setChannel,
-}) => {
+const UserContextMenu = () => {
const wrapperRef = useRef(null);
const { xPos, yPos, args } = useSelector((state) => state.contextMenu);
diff --git a/src/components/Window.jsx b/src/components/Window.jsx
index 5987471..a9ff9f1 100644
--- a/src/components/Window.jsx
+++ b/src/components/Window.jsx
@@ -68,11 +68,31 @@ const Window = ({ id }) => {
document.removeEventListener('mousemove', resize);
document.removeEventListener('mouseup', stopResize);
document.removeEventListener('touchcancel', stopResize);
+ document.removeEventListener('touchend', stopResize);
};
document.addEventListener('mouseup', stopResize);
document.addEventListener('touchcancel', stopResize);
+ document.addEventListener('touchend', stopResize);
}, []);
+ const clone = (evt) => {
+ evt.stopPropagation();
+ evt.preventDefault();
+ dispatch(cloneWindow(id));
+ };
+
+ const maximize = (evt) => {
+ evt.stopPropagation();
+ evt.preventDefault();
+ dispatch(maximizeWindow(id));
+ };
+
+ const close = (evt) => {
+ evt.stopPropagation();
+ evt.preventDefault();
+ dispatch(closeWindow(id));
+ };
+
if (!win) {
return null;
}
@@ -101,40 +121,42 @@ const Window = ({ id }) => {
>
dispatch(cloneWindow(id))}
+ onMouseDown={clone}
>
+
{title}
dispatch(maximizeWindow(id))}
+ onMouseDown={maximize}
>
↑
dispatch(closeWindow(id))}
+ onMouseDown={close}
>
X
-
-
-
- R
+ ▨
+
+
+
);
diff --git a/src/components/windows/index.jsx b/src/components/windows/index.jsx
index 977c6b1..f92d96a 100644
--- a/src/components/windows/index.jsx
+++ b/src/components/windows/index.jsx
@@ -2,6 +2,8 @@
* @flow
*/
+import React from 'react';
+
import Help from './Help';
import Settings from './Settings';
import UserArea from './UserArea';
diff --git a/src/data/models/User.js b/src/data/models/User.js
index 553e454..04447e2 100644
--- a/src/data/models/User.js
+++ b/src/data/models/User.js
@@ -60,6 +60,8 @@ class User {
setRegUser(reguser) {
this.regUser = reguser;
this.id = reguser.id;
+ this.channels = {};
+ this.blocked = [];
if (this.regUser.isMod) {
this.userlvl = 2;
@@ -116,6 +118,12 @@ class User {
}
}
+ async reload() {
+ if (!this.regUser) return;
+ await this.regUser.reload();
+ this.setRegUser(this.regUser);
+ }
+
addChannel(cid, channelArray) {
this.channels[cid] = channelArray;
}
diff --git a/src/reducers/windows.js b/src/reducers/windows.js
index 14bfcf8..522ac49 100644
--- a/src/reducers/windows.js
+++ b/src/reducers/windows.js
@@ -211,14 +211,17 @@ export default function windows(
const {
windows: oldWindows,
} = state;
- if (!oldWindows
- || oldWindows[oldWindows.length - 1].windowId === windowId) {
+ if (oldWindows.length === 0
+ || oldWindows[oldWindows.length - 1].windowId === windowId
+ ) {
return state;
}
console.log(`focus window ${windowId}`);
const newWindows = oldWindows.filter((w) => w.windowId !== windowId);
const win = oldWindows.find((w) => w.windowId === windowId);
- newWindows.push(win);
+ if (win) {
+ newWindows.push(win);
+ }
return {
...state,
windows: newWindows,
diff --git a/src/routes/api/auth/change_name.js b/src/routes/api/auth/change_name.js
index 062d9a2..f3ee2db 100644
--- a/src/routes/api/auth/change_name.js
+++ b/src/routes/api/auth/change_name.js
@@ -6,6 +6,7 @@
import type { Request, Response } from 'express';
+import webSockets from '../../../socket/websockets';
import { RegUser } from '../../../data/models';
import { validateName } from '../../../utils/validation';
@@ -33,7 +34,8 @@ export default async (req: Request, res: Response) => {
return;
}
- const error = await validate(user.regUser.name, name);
+ const oldname = user.regUser.name;
+ const error = await validate(oldname, name);
if (error) {
res.status(400);
res.json({
@@ -44,6 +46,8 @@ export default async (req: Request, res: Response) => {
await user.regUser.update({ name });
+ webSockets.reloadUser(oldname);
+
res.json({
success: true,
});
diff --git a/src/socket/SocketServer.js b/src/socket/SocketServer.js
index 940358e..470506f 100644
--- a/src/socket/SocketServer.js
+++ b/src/socket/SocketServer.js
@@ -261,6 +261,17 @@ class SocketServer extends WebSocketEvents {
});
}
+ reloadUser(name) {
+ this.wss.clients.forEach(async (ws) => {
+ if (ws.name === name) {
+ await ws.user.reload();
+ ws.name = ws.user.getName();
+ const buffer = ChangedMe.dehydrate();
+ ws.send(buffer);
+ }
+ });
+ }
+
killOld() {
const now = Date.now();
this.wss.clients.forEach((ws) => {
diff --git a/src/socket/WebSocketEvents.js b/src/socket/WebSocketEvents.js
index fa21382..4f841c8 100644
--- a/src/socket/WebSocketEvents.js
+++ b/src/socket/WebSocketEvents.js
@@ -40,6 +40,9 @@ class WebSocketEvents {
notifyChangedMe(name: string) {
}
+ reloadUser(name: string) {
+ }
+
broadcastMinecraftTP(minecraftid: string, x: number, y: number) {
}
diff --git a/src/socket/websockets.js b/src/socket/websockets.js
index 80260a7..5593a7a 100644
--- a/src/socket/websockets.js
+++ b/src/socket/websockets.js
@@ -144,7 +144,6 @@ class WebSockets {
/*
* Notify user on websocket that he should rerequest api/message
- * Currently just used for getting minecraft link message.
*/
notifyChangedMe(name: string) {
this.listeners.forEach(
@@ -152,6 +151,15 @@ class WebSockets {
);
}
+ /*
+ * reload user on websocket to get changes
+ */
+ reloadUser(name: string) {
+ this.listeners.forEach(
+ (listener) => listener.reloadUser(name),
+ );
+ }
+
/*
* broadcast mc tp request to API
* @param minecraftid minecraftid
diff --git a/src/styles/default.css b/src/styles/default.css
index 3743409..01463c9 100644
--- a/src/styles/default.css
+++ b/src/styles/default.css
@@ -116,6 +116,13 @@ td, th {
overflow-x: hidden;
}
+h2 {
+ font-size: 22px;
+ padding-left: 5%;
+ margin-bottom: 10px;
+ margin-top: 12px;
+}
+
tr:nth-child(even) {
background-color: #dddddd;
}
@@ -140,30 +147,44 @@ tr:nth-child(even) {
border: solid black;
border-width: thin;
overflow: hidden;
+ padding: 3px;
z-index: 3;
}
.win-topbar {
display: flex;
- height: 16px;
+ height: 24px;
+ vertical-align: middle;
}
.win-title {
cursor: move;
flex-grow: 1;
+ line-height: 19px;
+ margin: 2px;
+ padding-left: 10px;
+ font-size: 15px;
}
.win-topbtn {
border: solid black;
border-width: thin;
- background-color: blue;
+ background-color: #f7f7f7;
cursor: pointer;
+ margin: 2px;
+ text-align: center;
+ height: 17px;
+ width: 17px;
+ line-height: 17px;
+ font-size: 17px;
+ font-weight: bold;
}
.win-resize {
position: absolute;
- bottom: 0;
- right: 0;
+ bottom: -3px;
+ right: -3px;
+ font-size: 22px;
cursor: se-resize;
}
@@ -172,13 +193,13 @@ tr:nth-child(even) {
display: flex;
flex-direction: column;
width: 100%;
- height: calc(100% - 4px);
+ height: calc(100% - 1px);
}
.win-content {
position: relative;
- width: 100%;
- height: calc(100% - 16px);
+ width: calc(100% - 3px);
+ height: calc(100% - 28px);
overflow-y: auto;
}
@@ -379,7 +400,6 @@ tr:nth-child(even) {
bottom: auto;
border: 1px solid rgb(204, 204, 204);
background: rgb(255, 255, 255) none repeat scroll 0% 0%;
- overflow-y: auto;
border-radius: 4px;
outline: currentcolor none medium;
transform: translate(-50%, -50%);
@@ -394,7 +414,15 @@ tr:nth-child(even) {
z-index: 5;
}
+.Modal-content {
+ position: relative;
+ width: calc(100% - 3px);
+ height: calc(100% - 50px);
+ overflow-y: auto;
+}
+
.Alert {
+ overflow-y: auto;
max-height: 100%;
padding: 15px;
text-align: center;
@@ -474,25 +502,24 @@ tr:nth-child(even) {
display: flex;
justify-content: center;
align-items: center;
- flex: 0 0 36px;
border-width: 2px;
border-style: solid;
border-radius: 50%;
- width: 36px;
- height: 36px;
+ width: 27px;
+ height: 27px;
cursor: pointer;
background-color: #f6f6f7;
border-color: #dcddde;
- top: 30px;
+ top: 11px;
z-index: 5;
}
.ModalClose {
- right: 40px;
+ right: 14px;
}
.ModalRestore {
- right: 90px;
+ right: 52px;
}
.ModalClose:hover, .ModalRestore:hover {