mirror of
https://mau.dev/maunium/synapse.git
synced 2024-08-27 20:52:30 +00:00
When opening this page, do not join a room already joined
This commit is contained in:
parent
7c99ebdbd1
commit
c44293db2f
@ -282,7 +282,7 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput', 'mUtilities'])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (room_id_or_alias && '!' === room_id_or_alias[0]) {
|
if (room_id_or_alias && '!' === room_id_or_alias[0]) {
|
||||||
// Yes. We can start right now
|
// Yes. We can go on right now
|
||||||
$scope.room_id = room_id_or_alias;
|
$scope.room_id = room_id_or_alias;
|
||||||
$scope.room_alias = matrixService.getRoomIdToAliasMapping($scope.room_id);
|
$scope.room_alias = matrixService.getRoomIdToAliasMapping($scope.room_id);
|
||||||
onInit2();
|
onInit2();
|
||||||
@ -313,7 +313,7 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput', 'mUtilities'])
|
|||||||
$scope.room_id = response.data.room_id;
|
$scope.room_id = response.data.room_id;
|
||||||
console.log(" -> Room ID: " + $scope.room_id);
|
console.log(" -> Room ID: " + $scope.room_id);
|
||||||
|
|
||||||
// Now, we can start
|
// Now, we can go on
|
||||||
onInit2();
|
onInit2();
|
||||||
},
|
},
|
||||||
function () {
|
function () {
|
||||||
@ -325,34 +325,59 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput', 'mUtilities'])
|
|||||||
};
|
};
|
||||||
|
|
||||||
var onInit2 = function() {
|
var onInit2 = function() {
|
||||||
eventHandlerService.reInitRoom($scope.room_id);
|
console.log("onInit2");
|
||||||
|
|
||||||
// Make recents highlight the current room
|
// Make sure the initialSync has been before going further
|
||||||
$scope.recentsSelectedRoomID = $scope.room_id;
|
eventHandlerService.waitForInitialSyncCompletion().then(
|
||||||
|
function() {
|
||||||
|
var needsToJoin = true;
|
||||||
|
|
||||||
// Join the room
|
// The room members is available in the data fetched by initialSync
|
||||||
|
if ($rootScope.events.rooms[$scope.room_id]) {
|
||||||
|
var members = $rootScope.events.rooms[$scope.room_id].members;
|
||||||
|
|
||||||
|
// Update the member list
|
||||||
|
for (var i in members) {
|
||||||
|
var member = members[i];
|
||||||
|
updateMemberList(member);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the user has already join the room
|
||||||
|
if ($scope.state.user_id in members) {
|
||||||
|
if ("join" === members[$scope.state.user_id].membership) {
|
||||||
|
needsToJoin = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do we to join the room before starting?
|
||||||
|
if (needsToJoin) {
|
||||||
matrixService.join($scope.room_id).then(
|
matrixService.join($scope.room_id).then(
|
||||||
function() {
|
function() {
|
||||||
console.log("Joined room "+$scope.room_id);
|
console.log("Joined room "+$scope.room_id);
|
||||||
|
onInit3();
|
||||||
// Get the current member list
|
|
||||||
matrixService.getMemberList($scope.room_id).then(
|
|
||||||
function(response) {
|
|
||||||
for (var i = 0; i < response.data.chunk.length; i++) {
|
|
||||||
var chunk = response.data.chunk[i];
|
|
||||||
updateMemberList(chunk);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function(error) {
|
|
||||||
$scope.feedback = "Failed get member list: " + error.data.error;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
paginate(MESSAGES_PER_PAGINATION);
|
|
||||||
},
|
},
|
||||||
function(reason) {
|
function(reason) {
|
||||||
$scope.feedback = "Can't join room: " + reason;
|
$scope.feedback = "Can't join room: " + reason;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
onInit3();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
var onInit3 = function() {
|
||||||
|
console.log("onInit3");
|
||||||
|
|
||||||
|
// TODO: We should be able to keep them
|
||||||
|
eventHandlerService.resetRoomMessages($scope.room_id);
|
||||||
|
|
||||||
|
// Make recents highlight the current room
|
||||||
|
$scope.recentsSelectedRoomID = $scope.room_id;
|
||||||
|
|
||||||
|
paginate(MESSAGES_PER_PAGINATION);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.inviteUser = function(user_id) {
|
$scope.inviteUser = function(user_id) {
|
||||||
|
Loading…
Reference in New Issue
Block a user