parent
e324355b63
commit
d39357401b
8 changed files with 193 additions and 60 deletions
|
|
@ -303,6 +303,7 @@ export default {
|
|||
client.on("Room", this.onRoom);
|
||||
client.on("Session.logged_out", this.onSessionLoggedOut);
|
||||
client.on("Room.myMembership", this.onRoomMyMembership);
|
||||
client.on("RoomMember.membership", this.onRoomMemberMembership);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -312,6 +313,7 @@ export default {
|
|||
client.off("Room", this.onRoom);
|
||||
client.off("Session.logged_out", this.onSessionLoggedOut);
|
||||
client.off("Room.myMembership", this.onRoomMyMembership);
|
||||
client.off("RoomMember.membership", this.onRoomMemberMembership);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -351,6 +353,17 @@ export default {
|
|||
}
|
||||
},
|
||||
|
||||
onRoomMemberMembership(event, member, ignoredoldMembership) {
|
||||
if (member.userId == this.currentUserId && member.isKicked()) {
|
||||
if (this.currentRoomId == event.getRoomId()) {
|
||||
// We were kicked! Look at "reason", maybe a purge?
|
||||
const reason = event.getContent().reason || "";
|
||||
const roomWasPurged = (reason == "Room Deleted");
|
||||
this.$navigation.push({ name: "Goodbye", params: { roomWasPurged: roomWasPurged } }, -1);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onSessionLoggedOut() {
|
||||
console.log("Logged out!");
|
||||
if (this.matrixClient) {
|
||||
|
|
@ -502,7 +515,7 @@ export default {
|
|||
);
|
||||
const self = this;
|
||||
|
||||
console.log("Purge: set invite only");
|
||||
//console.log("Purge: set invite only");
|
||||
statusCallback(this.$t('room.purge_set_room_state'));
|
||||
this.matrixClient.sendStateEvent(
|
||||
roomId,
|
||||
|
|
@ -511,7 +524,7 @@ export default {
|
|||
""
|
||||
)
|
||||
.then(() => {
|
||||
console.log("Purge: forbid guest access");
|
||||
//console.log("Purge: forbid guest access");
|
||||
return this.matrixClient.sendStateEvent(
|
||||
roomId,
|
||||
"m.room.guest_access",
|
||||
|
|
@ -520,20 +533,20 @@ export default {
|
|||
);
|
||||
})
|
||||
.then(() => {
|
||||
console.log("Purge: set history visibility to 'joined'");
|
||||
//console.log("Purge: set history visibility to 'joined'");
|
||||
return this.matrixClient.sendStateEvent(roomId, "m.room.history_visibility", {
|
||||
history_visibility: "joined",
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
console.log("Purge: create timeline");
|
||||
//console.log("Purge: create timeline");
|
||||
return timelineWindow.load(null, 100)
|
||||
})
|
||||
.then(() => {
|
||||
const getMoreIfAvailable = function _getMoreIfAvailable() {
|
||||
if (timelineWindow.canPaginate(EventTimeline.BACKWARDS)
|
||||
) {
|
||||
console.log("Purge: page back");
|
||||
//console.log("Purge: page back");
|
||||
return timelineWindow
|
||||
.paginate(EventTimeline.BACKWARDS, 100, true, 5)
|
||||
.then((ignoredsuccess) => {
|
||||
|
|
@ -546,7 +559,7 @@ export default {
|
|||
return getMoreIfAvailable();
|
||||
})
|
||||
.then(() => {
|
||||
console.log("Purge: redact events");
|
||||
//console.log("Purge: redact events");
|
||||
statusCallback(this.$t('room.purge_redacting_events'));
|
||||
// First ignore unknown device errors
|
||||
this.matrixClient.setGlobalErrorOnUnknownDevices(false);
|
||||
|
|
@ -560,7 +573,7 @@ export default {
|
|||
return Promise.all(redactionPromises);
|
||||
})
|
||||
.then(() => {
|
||||
console.log("Purge: kick members");
|
||||
//console.log("Purge: kick members");
|
||||
statusCallback(this.$t('room.purge_removing_members'));
|
||||
var joined = room.getMembersWithMembership("join");
|
||||
var invited = room.getMembersWithMembership("invite");
|
||||
|
|
@ -577,6 +590,9 @@ export default {
|
|||
.then(() => {
|
||||
statusCallback(null);
|
||||
this.matrixClient.setGlobalErrorOnUnknownDevices(oldGlobalErrorSetting);
|
||||
return this.leaveRoom(roomId);
|
||||
})
|
||||
.then(() => {
|
||||
resolve(true); // Done!
|
||||
})
|
||||
.catch((err) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue