diff --git a/ts/Manager/App.tsx b/ts/Manager/App.tsx index b7f32cc..2a6dbc4 100644 --- a/ts/Manager/App.tsx +++ b/ts/Manager/App.tsx @@ -43,7 +43,7 @@ const App: React.FC = () => { const [orderBy, setOrderBy] = useState('name'); const [sortOrder, setSortOrder] = useState(SortOrder.ASC); - const rows = rooms.sort(sortRooms(orderBy, sortOrder)).map(room => ); + const rows = rooms.sort(sortRooms(orderBy, sortOrder)).map(room => ); useEffect(() => { Promise.all([ @@ -105,13 +105,18 @@ const App: React.FC = () => { function updateRoom(room: Room) { return api.updateRoom(room).then(updatedRoom => { - setRooms(rooms.map(room => { - if (room.id === updatedRoom.id) { - return updatedRoom; - } - return room; - })); + if (!rooms.find(room => room.id === updatedRoom.id)) { + setRooms(rooms.concat([updatedRoom])); + } else { + setRooms(rooms.map(room => { + if (room.id === updatedRoom.id) { + return updatedRoom; + } + + return room; + })); + } }); } @@ -121,6 +126,25 @@ const App: React.FC = () => { }); } + function cloneRoom(room: Room) { + + if (room.moderatorToken !== null) { + room.moderatorToken = 'true'; + } + + return api.createRoom(room.name, room.access, room.maxParticipants).then(newRoom => { + api.getRoomShares(room.id).then(shares => shares.forEach(share => { + api.createRoomShare(newRoom.id, share.shareType, share.shareWith, share.permission); + })); + + updateRoom({ + ...room, + uid: newRoom.uid, + id: newRoom.id, + }); + }); + } + const maxRooms = restriction?.maxRooms || 0; const quota = maxRooms < 0 ? t('bbb', 'unlimited') : rooms.filter(room => room.userId === OC.currentUser).length + ' / ' + maxRooms; @@ -151,6 +175,7 @@ const App: React.FC = () => { + diff --git a/ts/Manager/RoomRow.tsx b/ts/Manager/RoomRow.tsx index 40de45b..bc6808a 100644 --- a/ts/Manager/RoomRow.tsx +++ b/ts/Manager/RoomRow.tsx @@ -11,6 +11,7 @@ type Props = { restriction?: Restriction; updateRoom: (room: Room) => Promise; deleteRoom: (id: number) => void; + cloneRoom: (room: Room) => void; } type RecordingsNumberProps = { @@ -175,6 +176,10 @@ const RoomRow: React.FC = (props) => { return ; } + function cloneRow() { + props.cloneRoom({...props.room}); + } + const avatarUrl = OC.generateUrl('/avatar/' + encodeURIComponent(room.userId) + '/' + 24, { user: room.userId, size: 24, @@ -225,6 +230,11 @@ const RoomRow: React.FC = (props) => { + + +