mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Structure change (#4220)
* Structure change * Remove duplicate folders from previous structure * Cleanup websocket protocol * Updating from based off PR * Fixup - remove wrong files during conflict and get the websocket working * renaming tsx to ts Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
This commit is contained in:
parent
a0deb73df6
commit
1ddc9cc929
123 changed files with 424 additions and 228 deletions
|
|
@ -1,44 +0,0 @@
|
|||
export class NormalizeService {
|
||||
// Flatten room gameTypes into map object
|
||||
static normalizeRoomInfo(roomInfo) {
|
||||
roomInfo.gametypeMap = {};
|
||||
|
||||
const { gametypeList, gametypeMap, gameList } = roomInfo;
|
||||
|
||||
gametypeList.reduce((map, type) => {
|
||||
map[type.gameTypeId] = type.description;
|
||||
return map;
|
||||
}, gametypeMap);
|
||||
|
||||
gameList.forEach((game) => NormalizeService.normalizeGameObject(game, gametypeMap));
|
||||
}
|
||||
|
||||
// Flatten gameTypes[] into gameType field
|
||||
// Default sortable values ("" || 0 || -1)
|
||||
static normalizeGameObject(game, gametypeMap) {
|
||||
const { gameTypes, description } = game;
|
||||
const hasType = gameTypes && gameTypes.length;
|
||||
game.gameType = hasType ? gametypeMap[gameTypes[0]] : "";
|
||||
|
||||
game.description = description || "";
|
||||
}
|
||||
|
||||
// Flatten logs[] into object mapped by targetType (room, game, chat)
|
||||
static normalizeLogs(logs) {
|
||||
return logs.reduce((obj, log) => {
|
||||
const { targetType } = log;
|
||||
obj[targetType] = obj[targetType] || [];
|
||||
obj[targetType].push(log);
|
||||
return obj;
|
||||
}, {});
|
||||
}
|
||||
|
||||
// messages sent by current user dont have their username prepended
|
||||
static normalizeUserMessage(message) {
|
||||
const { name } = message;
|
||||
|
||||
if (name) {
|
||||
message.message = `${name}: ${message.message}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue