add align prop to contextmenu
This commit is contained in:
parent
715c6ff1cc
commit
98766e9da4
|
@ -13,7 +13,7 @@ export const types = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const ContextMenu = ({
|
const ContextMenu = ({
|
||||||
type, x, y, args, close,
|
type, x, y, args, close, align,
|
||||||
}) => {
|
}) => {
|
||||||
const wrapperRef = useRef(null);
|
const wrapperRef = useRef(null);
|
||||||
|
|
||||||
|
@ -23,16 +23,37 @@ const ContextMenu = ({
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const style = {};
|
||||||
|
switch (align) {
|
||||||
|
case 'tr': {
|
||||||
|
style.right = window.innerWidth - x;
|
||||||
|
style.top = y;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'br': {
|
||||||
|
style.right = window.innerWidth - x;
|
||||||
|
style.bottom = window.innerHeight - y;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'bl': {
|
||||||
|
style.left = x;
|
||||||
|
style.bottom = window.innerHeight - y;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
// also 'tl'
|
||||||
|
style.left = x;
|
||||||
|
style.top = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const Content = types[type];
|
const Content = types[type];
|
||||||
|
|
||||||
return ReactDOM.createPortal((
|
return ReactDOM.createPortal((
|
||||||
<div
|
<div
|
||||||
ref={wrapperRef}
|
ref={wrapperRef}
|
||||||
className={`contextmenu ${type}`}
|
className={`contextmenu ${type}`}
|
||||||
style={{
|
style={style}
|
||||||
left: x,
|
|
||||||
top: y,
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Content close={close} args={args} />
|
<Content close={close} args={args} />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -162,6 +162,7 @@ const Chat = () => {
|
||||||
y={cmArgs.y}
|
y={cmArgs.y}
|
||||||
args={cmArgs.args}
|
args={cmArgs.args}
|
||||||
close={closeCm}
|
close={closeCm}
|
||||||
|
align={cmArgs.align}
|
||||||
/>
|
/>
|
||||||
<ul
|
<ul
|
||||||
className="chatarea"
|
className="chatarea"
|
||||||
|
@ -265,6 +266,7 @@ const Chat = () => {
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
args: { cid: chatChannel },
|
args: { cid: chatChannel },
|
||||||
|
align: 'tr',
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
role="button"
|
role="button"
|
||||||
|
|
4
src/rep.sh
Executable file
4
src/rep.sh
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
grep -rli "${1}" * | xargs -i@ sed -i "s/${1}/s\/${1}/g" @
|
||||||
|
|
|
@ -79,6 +79,7 @@ class APISocketServer {
|
||||||
logger.warn(`API ws request from ${ip} not authenticated`);
|
logger.warn(`API ws request from ${ip} not authenticated`);
|
||||||
socket.write('HTTP/1.1 401 Unauthorized\r\n\r\n');
|
socket.write('HTTP/1.1 401 Unauthorized\r\n\r\n');
|
||||||
socket.destroy();
|
socket.destroy();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
logger.warn(`API ws request from ${ip} successfully authenticated`);
|
logger.warn(`API ws request from ${ip} successfully authenticated`);
|
||||||
|
|
||||||
|
|
|
@ -263,7 +263,7 @@ export function receiveMe(
|
||||||
me,
|
me,
|
||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
type: 'REC_ME',
|
type: 's/REC_ME',
|
||||||
...me,
|
...me,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ export function requestPlacePixels(i, j, pixels) {
|
||||||
export function logoutUser(
|
export function logoutUser(
|
||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
type: 'LOGOUT',
|
type: 's/LOGOUT',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ export function loginUser(
|
||||||
me,
|
me,
|
||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
type: 'LOGIN',
|
type: 's/LOGIN',
|
||||||
...me,
|
...me,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -354,7 +354,7 @@ export function setName(
|
||||||
name,
|
name,
|
||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
type: 'SET_NAME',
|
type: 's/SET_NAME',
|
||||||
name,
|
name,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -363,7 +363,7 @@ export function setMailreg(
|
||||||
mailreg,
|
mailreg,
|
||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
type: 'SET_MAILREG',
|
type: 's/SET_MAILREG',
|
||||||
mailreg,
|
mailreg,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -372,7 +372,7 @@ export function remFromMessages(
|
||||||
message,
|
message,
|
||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
type: 'REM_FROM_MESSAGES',
|
type: 's/REM_FROM_MESSAGES',
|
||||||
message,
|
message,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -437,7 +437,7 @@ export function addChatChannel(channel) {
|
||||||
|
|
||||||
export function blockUser(userId, userName) {
|
export function blockUser(userId, userName) {
|
||||||
return {
|
return {
|
||||||
type: 'BLOCK_USER',
|
type: 's/BLOCK_USER',
|
||||||
userId,
|
userId,
|
||||||
userName,
|
userName,
|
||||||
};
|
};
|
||||||
|
@ -445,7 +445,7 @@ export function blockUser(userId, userName) {
|
||||||
|
|
||||||
export function unblockUser(userId, userName) {
|
export function unblockUser(userId, userName) {
|
||||||
return {
|
return {
|
||||||
type: 'UNBLOCK_USER',
|
type: 's/UNBLOCK_USER',
|
||||||
userId,
|
userId,
|
||||||
userName,
|
userName,
|
||||||
};
|
};
|
||||||
|
@ -453,7 +453,7 @@ export function unblockUser(userId, userName) {
|
||||||
|
|
||||||
export function blockingDm(blockDm) {
|
export function blockingDm(blockDm) {
|
||||||
return {
|
return {
|
||||||
type: 'SET_BLOCKING_DM',
|
type: 's/SET_BLOCKING_DM',
|
||||||
blockDm,
|
blockDm,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -531,7 +531,7 @@ export function propagateMe(state) {
|
||||||
dailyTotalPixels,
|
dailyTotalPixels,
|
||||||
} = state.ranks;
|
} = state.ranks;
|
||||||
return {
|
return {
|
||||||
type: 'REC_ME',
|
type: 's/REC_ME',
|
||||||
blockDm,
|
blockDm,
|
||||||
blocked,
|
blocked,
|
||||||
canvases,
|
canvases,
|
||||||
|
|
|
@ -8,7 +8,7 @@ export default (store) => (next) => (action) => {
|
||||||
try {
|
try {
|
||||||
if (!document.hasFocus()) {
|
if (!document.hasFocus()) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'REC_ME': {
|
case 's/REC_ME': {
|
||||||
if (window.Notification
|
if (window.Notification
|
||||||
&& Notification.permission !== 'granted'
|
&& Notification.permission !== 'granted'
|
||||||
&& Notification.permission !== 'denied'
|
&& Notification.permission !== 'denied'
|
||||||
|
|
|
@ -49,7 +49,7 @@ export default (store) => (next) => (action) => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'RELOAD_URL':
|
case 'RELOAD_URL':
|
||||||
case 's/SELECT_CANVAS':
|
case 's/SELECT_CANVAS':
|
||||||
case 'REC_ME': {
|
case 's/REC_ME': {
|
||||||
const renderer = getRenderer();
|
const renderer = getRenderer();
|
||||||
const { is3D } = state.canvas;
|
const { is3D } = state.canvas;
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,9 @@ export default (store) => (next) => (action) => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'SET_NAME':
|
case 's/SET_NAME':
|
||||||
case 'LOGIN':
|
case 's/LOGIN':
|
||||||
case 'LOGOUT': {
|
case 's/LOGOUT': {
|
||||||
SocketClient.reconnect();
|
SocketClient.reconnect();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ export default (store) => (next) => (action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'RELOAD_URL':
|
case 'RELOAD_URL':
|
||||||
case 's/SELECT_CANVAS':
|
case 's/SELECT_CANVAS':
|
||||||
case 'REC_ME': {
|
case 's/REC_ME': {
|
||||||
const state = store.getState();
|
const state = store.getState();
|
||||||
const { canvasId } = state.canvas;
|
const { canvasId } = state.canvas;
|
||||||
SocketClient.setCanvas(canvasId);
|
SocketClient.setCanvas(canvasId);
|
||||||
|
|
|
@ -12,9 +12,9 @@ export default () => (next) => (action) => {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'SET_NAME':
|
case 's/SET_NAME':
|
||||||
case 'LOGIN':
|
case 's/LOGIN':
|
||||||
case 'LOGOUT': {
|
case 's/LOGOUT': {
|
||||||
SocketClient.reconnect();
|
SocketClient.reconnect();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ export default (store) => (next) => (action) => {
|
||||||
|
|
||||||
|
|
||||||
case 's/SELECT_CANVAS':
|
case 's/SELECT_CANVAS':
|
||||||
case 'REC_ME':
|
case 's/REC_ME':
|
||||||
case 'RELOAD_URL':
|
case 'RELOAD_URL':
|
||||||
case 'ON_VIEW_FINISH_CHANGE': {
|
case 'ON_VIEW_FINISH_CHANGE': {
|
||||||
const state = store.getState();
|
const state = store.getState();
|
||||||
|
|
|
@ -344,7 +344,7 @@ export default function canvasReducer(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'REC_ME': {
|
case 's/REC_ME': {
|
||||||
const { canvases } = action;
|
const { canvases } = action;
|
||||||
let { canvasIdent, scale, view } = state;
|
let { canvasIdent, scale, view } = state;
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,8 @@ export default function chat(
|
||||||
action,
|
action,
|
||||||
) {
|
) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'REC_ME':
|
case 's/REC_ME':
|
||||||
case 'LOGIN': {
|
case 's/LOGIN': {
|
||||||
// making sure object keys are numbers
|
// making sure object keys are numbers
|
||||||
const channels = {};
|
const channels = {};
|
||||||
const channelsJson = action.channels;
|
const channelsJson = action.channels;
|
||||||
|
@ -49,7 +49,7 @@ export default function chat(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'LOGOUT': {
|
case 's/LOGOUT': {
|
||||||
const channels = { ...state.channels };
|
const channels = { ...state.channels };
|
||||||
const messages = { ...state.messages };
|
const messages = { ...state.messages };
|
||||||
const keys = Object.keys(channels);
|
const keys = Object.keys(channels);
|
||||||
|
@ -68,7 +68,7 @@ export default function chat(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'BLOCK_USER': {
|
case 's/BLOCK_USER': {
|
||||||
const { userId, userName } = action;
|
const { userId, userName } = action;
|
||||||
const blocked = [
|
const blocked = [
|
||||||
...state.blocked,
|
...state.blocked,
|
||||||
|
@ -96,7 +96,7 @@ export default function chat(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'UNBLOCK_USER': {
|
case 's/UNBLOCK_USER': {
|
||||||
const { userId } = action;
|
const { userId } = action;
|
||||||
const blocked = state.blocked.filter((bl) => (bl[0] !== userId));
|
const blocked = state.blocked.filter((bl) => (bl[0] !== userId));
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -23,8 +23,8 @@ export default function chatRead(
|
||||||
action,
|
action,
|
||||||
) {
|
) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'REC_ME':
|
case 's/REC_ME':
|
||||||
case 'LOGIN': {
|
case 's/LOGIN': {
|
||||||
const { channels } = action;
|
const { channels } = action;
|
||||||
const cids = Object.keys(channels);
|
const cids = Object.keys(channels);
|
||||||
const readTs = {};
|
const readTs = {};
|
||||||
|
|
|
@ -49,8 +49,8 @@ export default function ranks(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'REC_ME':
|
case 's/REC_ME':
|
||||||
case 'LOGIN': {
|
case 's/LOGIN': {
|
||||||
const {
|
const {
|
||||||
totalPixels,
|
totalPixels,
|
||||||
dailyTotalPixels,
|
dailyTotalPixels,
|
||||||
|
|
|
@ -85,8 +85,8 @@ export default function user(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'REC_ME':
|
case 's/REC_ME':
|
||||||
case 'LOGIN': {
|
case 's/LOGIN': {
|
||||||
const {
|
const {
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
|
@ -106,7 +106,7 @@ export default function user(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'LOGOUT': {
|
case 's/LOGOUT': {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
id: null,
|
id: null,
|
||||||
|
@ -118,7 +118,7 @@ export default function user(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'SET_NAME': {
|
case 's/SET_NAME': {
|
||||||
const { name } = action;
|
const { name } = action;
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
@ -126,7 +126,7 @@ export default function user(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'SET_BLOCKING_DM': {
|
case 's/SET_BLOCKING_DM': {
|
||||||
const { blockDm } = action;
|
const { blockDm } = action;
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
@ -148,7 +148,7 @@ export default function user(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'REM_FROM_MESSAGES': {
|
case 's/REM_FROM_MESSAGES': {
|
||||||
const { message } = action;
|
const { message } = action;
|
||||||
const messages = [...state.messages];
|
const messages = [...state.messages];
|
||||||
const index = messages.indexOf(message);
|
const index = messages.indexOf(message);
|
||||||
|
@ -161,7 +161,7 @@ export default function user(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'SET_MAILREG': {
|
case 's/SET_MAILREG': {
|
||||||
const { mailreg } = action;
|
const { mailreg } = action;
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user