mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
tgui => tgui_ch
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
import { perf } from 'common/perf';
|
||||
import { createAction } from 'common/redux';
|
||||
import { setupDrag } from './drag';
|
||||
import { globalEvents } from './events';
|
||||
import { focusMap } from './focus';
|
||||
import { createLogger } from './logging';
|
||||
import { resumeRenderer, suspendRenderer } from './renderer';
|
||||
@@ -133,10 +134,18 @@ export const backendMiddleware = (store) => {
|
||||
}
|
||||
|
||||
if (type === 'ping') {
|
||||
Byond.sendMessage('pingReply');
|
||||
Byond.sendMessage('ping/reply');
|
||||
return;
|
||||
}
|
||||
|
||||
if (type === 'byond/mousedown') {
|
||||
globalEvents.emit('byond/mousedown');
|
||||
}
|
||||
|
||||
if (type === 'byond/mouseup') {
|
||||
globalEvents.emit('byond/mouseup');
|
||||
}
|
||||
|
||||
if (type === 'backend/suspendStart' && !suspendInterval) {
|
||||
logger.log(`suspending (${Byond.windowId})`);
|
||||
// Keep sending suspend messages until it succeeds.
|
||||
@@ -213,8 +222,10 @@ export const backendMiddleware = (store) => {
|
||||
*/
|
||||
export const sendAct = (action: string, payload: object = {}) => {
|
||||
// Validate that payload is an object
|
||||
const isObject =
|
||||
typeof payload === 'object' && payload !== null && !Array.isArray(payload);
|
||||
// prettier-ignore
|
||||
const isObject = typeof payload === 'object'
|
||||
&& payload !== null
|
||||
&& !Array.isArray(payload);
|
||||
if (!isObject) {
|
||||
logger.error(`Payload for act() must be an object, got this:`, payload);
|
||||
return;
|
||||
@@ -339,13 +350,15 @@ export const useSharedState = <T>(
|
||||
return [
|
||||
sharedState,
|
||||
(nextState) => {
|
||||
// prettier-ignore
|
||||
Byond.sendMessage({
|
||||
type: 'setSharedState',
|
||||
key,
|
||||
value:
|
||||
JSON.stringify(
|
||||
typeof nextState === 'function' ? nextState(sharedState) : nextState
|
||||
) || '',
|
||||
value: JSON.stringify(
|
||||
typeof nextState === 'function'
|
||||
? nextState(sharedState)
|
||||
: nextState
|
||||
) || '',
|
||||
});
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user