fix: improve plugins functionality with server management
This commit is contained in:
@@ -4,7 +4,11 @@ import { normalizeRoomAccessControl } from '../../domains/access-control';
|
||||
import { type ServerInfo } from '../../domains/server-directory';
|
||||
import { RoomsActions } from './rooms.actions';
|
||||
import { defaultChannels } from './room-channels.defaults';
|
||||
import { isChannelNameTaken, normalizeChannelName, normalizeRoomChannels } from './room-channels.rules';
|
||||
import {
|
||||
isChannelNameTaken,
|
||||
normalizeChannelName,
|
||||
normalizeRoomChannels
|
||||
} from './room-channels.rules';
|
||||
import { pruneRoomMembers } from './room-members.helpers';
|
||||
|
||||
/** Deduplicate rooms by id, keeping the last occurrence */
|
||||
@@ -325,7 +329,8 @@ export const roomsReducer = createReducer(
|
||||
on(RoomsActions.updateRoom, (state, { roomId, changes }) => {
|
||||
const baseRoom = state.savedRooms.find((savedRoom) => savedRoom.id === roomId) || (state.currentRoom?.id === roomId ? state.currentRoom : null);
|
||||
|
||||
if (!baseRoom) return state;
|
||||
if (!baseRoom)
|
||||
return state;
|
||||
|
||||
const updatedRoom = enrichRoom({ ...baseRoom, ...changes });
|
||||
|
||||
@@ -342,7 +347,8 @@ export const roomsReducer = createReducer(
|
||||
on(RoomsActions.updateServerIconSuccess, (state, { roomId, icon, iconUpdatedAt }) => {
|
||||
const baseRoom = state.savedRooms.find((savedRoom) => savedRoom.id === roomId) || (state.currentRoom?.id === roomId ? state.currentRoom : null);
|
||||
|
||||
if (!baseRoom) return state;
|
||||
if (!baseRoom)
|
||||
return state;
|
||||
|
||||
const updatedRoom = enrichRoom({ ...baseRoom, icon, iconUpdatedAt });
|
||||
|
||||
@@ -362,7 +368,8 @@ export const roomsReducer = createReducer(
|
||||
|
||||
// Receive room update
|
||||
on(RoomsActions.receiveRoomUpdate, (state, { room }) => {
|
||||
if (!state.currentRoom) return state;
|
||||
if (!state.currentRoom)
|
||||
return state;
|
||||
|
||||
const updatedRoom = enrichRoom({ ...state.currentRoom, ...room });
|
||||
|
||||
@@ -403,7 +410,8 @@ export const roomsReducer = createReducer(
|
||||
})),
|
||||
|
||||
on(RoomsActions.addChannel, (state, { channel }) => {
|
||||
if (!state.currentRoom) return state;
|
||||
if (!state.currentRoom)
|
||||
return state;
|
||||
|
||||
const existing = state.currentRoom.channels || defaultChannels();
|
||||
const normalizedName = normalizeChannelName(channel.name);
|
||||
@@ -424,7 +432,8 @@ export const roomsReducer = createReducer(
|
||||
}),
|
||||
|
||||
on(RoomsActions.removeChannel, (state, { channelId }) => {
|
||||
if (!state.currentRoom) return state;
|
||||
if (!state.currentRoom)
|
||||
return state;
|
||||
|
||||
const existing = state.currentRoom.channels || defaultChannels();
|
||||
const updatedChannels = existing.filter((channel) => channel.id !== channelId);
|
||||
@@ -439,7 +448,8 @@ export const roomsReducer = createReducer(
|
||||
}),
|
||||
|
||||
on(RoomsActions.renameChannel, (state, { channelId, name }) => {
|
||||
if (!state.currentRoom) return state;
|
||||
if (!state.currentRoom)
|
||||
return state;
|
||||
|
||||
const existing = state.currentRoom.channels || defaultChannels();
|
||||
const normalizedName = normalizeChannelName(name);
|
||||
|
||||
Reference in New Issue
Block a user