diff --git a/packages/rocketchat-ui-admin/admin/rooms/adminRoomInfo.coffee b/packages/rocketchat-ui-admin/admin/rooms/adminRoomInfo.coffee index 49fba0f4b322b99d36a64122b2937c5a46e42b33..ff3d7f6308d0ccd61b62745c4d0c4e13a28a61a3 100644 --- a/packages/rocketchat-ui-admin/admin/rooms/adminRoomInfo.coffee +++ b/packages/rocketchat-ui-admin/admin/rooms/adminRoomInfo.coffee @@ -63,7 +63,7 @@ Template.adminRoomInfo.events 'keydown input[type=text]': (e, t) -> if e.keyCode is 13 e.preventDefault() - t.saveSetting() + t.saveSetting(@rid) 'click [data-edit]': (e, t) -> e.preventDefault() @@ -76,22 +76,21 @@ Template.adminRoomInfo.events 'click .save': (e, t) -> e.preventDefault() - t.saveSetting() + t.saveSetting(@rid) Template.adminRoomInfo.onCreated -> @editing = new ReactiveVar - @validateRoomType = => + @validateRoomType = (rid) => type = @$('input[name=roomType]:checked').val() if type not in ['c', 'p'] toastr.error t('Invalid_room_type', type) return true - @validateRoomName = => - rid = Template.currentData()?.rid + @validateRoomName = (rid) => room = ChatRoom.findOne rid - if not RocketChat.authz.hasAllPermission('edit-room', @rid) or room.t not in ['c', 'p'] + if not RocketChat.authz.hasAllPermission('edit-room', rid) or room.t not in ['c', 'p'] toastr.error t('Not_allowed') return false @@ -102,28 +101,28 @@ Template.adminRoomInfo.onCreated -> return true - @validateRoomTopic = => + @validateRoomTopic = (rid) => return true - @saveSetting = => + @saveSetting = (rid) => switch @editing.get() when 'roomName' - if @validateRoomName() - Meteor.call 'saveRoomSettings', @data?.rid, 'roomName', @$('input[name=roomName]').val(), (err, result) -> + if @validateRoomName(rid) + Meteor.call 'saveRoomSettings', rid, 'roomName', @$('input[name=roomName]').val(), (err, result) -> if err if err.error in [ 'duplicate-name', 'name-invalid' ] return toastr.error TAPi18n.__(err.reason, err.details.channelName) return toastr.error TAPi18n.__(err.reason) toastr.success TAPi18n.__ 'Room_name_changed_successfully' when 'roomTopic' - if @validateRoomTopic() - Meteor.call 'saveRoomSettings', @data?.rid, 'roomTopic', @$('input[name=roomTopic]').val(), (err, result) -> + if @validateRoomTopic(rid) + Meteor.call 'saveRoomSettings', rid, 'roomTopic', @$('input[name=roomTopic]').val(), (err, result) -> if err return toastr.error TAPi18n.__(err.reason) toastr.success TAPi18n.__ 'Room_topic_changed_successfully' when 'roomType' - if @validateRoomType() - Meteor.call 'saveRoomSettings', @data?.rid, 'roomType', @$('input[name=roomType]:checked').val(), (err, result) -> + if @validateRoomType(rid) + Meteor.call 'saveRoomSettings', rid, 'roomType', @$('input[name=roomType]:checked').val(), (err, result) -> if err if err.error is 'invalid-room-type' return toastr.error TAPi18n.__(err.reason, err.details.roomType) @@ -131,13 +130,13 @@ Template.adminRoomInfo.onCreated -> toastr.success TAPi18n.__ 'Room_type_changed_successfully' when 'archivationState' if @$('input[name=archivationState]:checked').val() is 'true' - if ChatRoom.findOne(@data.rid)?.archived isnt true - Meteor.call 'archiveRoom', @data?.rid, (err, results) -> + if ChatRoom.findOne(rid)?.archived isnt true + Meteor.call 'archiveRoom', rid, (err, results) -> return toastr.error err.reason if err toastr.success TAPi18n.__ 'Room_archived' else - if ChatRoom.findOne(@data.rid)?.archived is true - Meteor.call 'unarchiveRoom', @data?.rid, (err, results) -> + if ChatRoom.findOne(rid)?.archived is true + Meteor.call 'unarchiveRoom', rid, (err, results) -> return toastr.error err.reason if err toastr.success TAPi18n.__ 'Room_unarchived' @editing.set() diff --git a/packages/rocketchat-ui-admin/publications/adminRooms.js b/packages/rocketchat-ui-admin/publications/adminRooms.js index 5c973bd601410fee376735c2b5109e27b8d32740..1cc49f6ba371ce8c91cb41e0c884580562ffad14 100644 --- a/packages/rocketchat-ui-admin/publications/adminRooms.js +++ b/packages/rocketchat-ui-admin/publications/adminRooms.js @@ -19,7 +19,8 @@ Meteor.publish('adminRooms', function(filter, types, limit) { muted: 1, default: 1, topic: 1, - msgs: 1 + msgs: 1, + archived: 1 }, limit: limit, sort: { diff --git a/server/methods/archiveRoom.coffee b/server/methods/archiveRoom.coffee index e1d86612d1d6241e8c52eca265dd7a0d2dccbd5f..5f43564d4c005cb763d59aa6b02084998b5c2702 100644 --- a/server/methods/archiveRoom.coffee +++ b/server/methods/archiveRoom.coffee @@ -6,10 +6,6 @@ Meteor.methods room = RocketChat.models.Rooms.findOneById rid if room.u? and room.u._id is Meteor.userId() or RocketChat.authz.hasRole(Meteor.userId(), 'admin') - update = - $set: - archived: true - RocketChat.models.Rooms.archiveById rid for username in room.usernames