Fix delete room

This commit is contained in:
N-Pex 2025-06-19 12:12:40 +02:00
parent 422e856cd9
commit 10b4c8ac35
2 changed files with 30 additions and 41 deletions

View file

@ -7,16 +7,14 @@
scroll-strategy="none" scroll-strategy="none"
> >
<div v-if="timeout == -1" class="dialog-content text-center"> <div v-if="timeout == -1" class="dialog-content text-center">
<template> <v-icon size="28">$vuetify.icons.trash_black</v-icon>
<v-icon size="28">$vuetify.icons.trash_black</v-icon> <h2 class="dialog-title">{{ $t("purge_room.title") }}</h2>
<h2 class="dialog-title">{{ $t("purge_room.title") }}</h2> <div class="dialog-text">
<div class="dialog-text"> {{ $t("purge_room.info") }}
{{ $t("purge_room.info") }} </div>
</div> <div class="dialog-text">
<div class="dialog-text"> {{ status }}
{{ status }} </div>
</div>
</template>
<v-container fluid> <v-container fluid>
<v-row cols="12"> <v-row cols="12">
<v-col cols="6"> <v-col cols="6">
@ -48,18 +46,15 @@
<!-- Timer --> <!-- Timer -->
<div v-if="timeout >= 0 && !isPurging" class="dialog-content text-center"> <div v-if="timeout >= 0 && !isPurging" class="dialog-content text-center">
<template> <v-icon size="20" class="d-inline-block me-2">$vuetify.icons.timer</v-icon>
<v-icon size="20" {{ $t("purge_room.n_seconds", { seconds: timeout }) }}
class="d-inline-block me-2">$vuetify.icons.timer</v-icon> <h2 class="dialog-title mb-0">{{ $t("purge_room.self_destruct") }}</h2>
{{ $t("purge_room.n_seconds", { seconds: timeout }) }} <div class="dialog-text text-center mb-5">
<h2 class="dialog-title mb-0">{{ $t("purge_room.self_destruct") }}</h2> {{ $t("purge_room.notified") }}
<div class="dialog-text text-center mb-5"> </div>
{{ $t("purge_room.notified") }} <div class="dialog-text">
</div> {{ status }}
<div class="dialog-text"> </div>
{{ status }}
</div>
</template>
<v-container fluid> <v-container fluid>
<v-row cols="12"> <v-row cols="12">
<v-col cols="6"> <v-col cols="6">
@ -107,7 +102,7 @@ export default {
}; };
}, },
methods: { methods: {
onOpenDialog() { onOpenDialog() {
// Showing, reset // Showing, reset
this.status = null; this.status = null;
}, },
@ -119,21 +114,17 @@ export default {
this.timeout = -1; this.timeout = -1;
// Cancel the state event for deletion // Cancel the state event for deletion
this.$matrix.matrixClient.sendStateEvent( this.$matrix.matrixClient.sendStateEvent(this.room.roomId, STATE_EVENT_ROOM_DELETION_NOTICE, {
this.room.roomId, status: "cancel",
STATE_EVENT_ROOM_DELETION_NOTICE, });
{ status: "cancel" }
);
this.showDialog = false; this.showDialog = false;
}, },
onPurgeRoom() { onPurgeRoom() {
// Send custom state event! // Send custom state event!
this.$matrix.matrixClient.sendStateEvent( this.$matrix.matrixClient.sendStateEvent(this.room.roomId, STATE_EVENT_ROOM_DELETION_NOTICE, {
this.room.roomId, status: "delete",
STATE_EVENT_ROOM_DELETION_NOTICE, });
{ status: "delete" }
);
this.timeout = 7; this.timeout = 7;
this.timeoutTimer = setInterval(() => { this.timeoutTimer = setInterval(() => {
@ -144,7 +135,7 @@ export default {
}, 1000); }, 1000);
}, },
onDoPurgeRoom() { onDoPurgeRoom() {
this.timeout = 0 this.timeout = 0;
clearInterval(this.timeoutTimer); clearInterval(this.timeoutTimer);
this.timeoutTimer = null; this.timeoutTimer = null;
this.isPurging = true; this.isPurging = true;

View file

@ -860,7 +860,6 @@ export default {
}); });
}; };
const oldGlobalErrorSetting = this.matrixClient.getGlobalErrorOnUnknownDevices();
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const room = this.getRoom(roomId); const room = this.getRoom(roomId);
if (!room) { if (!room) {
@ -925,8 +924,6 @@ export default {
.then(() => { .then(() => {
//console.log("Purge: redact events"); //console.log("Purge: redact events");
statusCallback(this.$t("room.purge_redacting_events")); statusCallback(this.$t("room.purge_redacting_events"));
// First ignore unknown device errors
this.matrixClient.setGlobalErrorOnUnknownDevices(false);
const allEvents = timelineWindow.getEvents().filter((event) => { const allEvents = timelineWindow.getEvents().filter((event) => {
return ( return (
!event.isRedacted() && !event.isRedacted() &&
@ -1004,7 +1001,6 @@ export default {
}) })
.then(() => { .then(() => {
statusCallback(null); statusCallback(null);
this.matrixClient.setGlobalErrorOnUnknownDevices(oldGlobalErrorSetting);
return withRetry(() => this.leaveRoom(roomId)); return withRetry(() => this.leaveRoom(roomId));
}) })
.then(() => { .then(() => {
@ -1014,7 +1010,6 @@ export default {
.catch((err) => { .catch((err) => {
console.error("Error purging room", err); console.error("Error purging room", err);
this.currentRoomBeingPurged = false; this.currentRoomBeingPurged = false;
this.matrixClient.setGlobalErrorOnUnknownDevices(oldGlobalErrorSetting);
reject(err); reject(err);
}); });
}); });
@ -1363,13 +1358,16 @@ export default {
}, },
render: () => {} render: () => {}
}); });
const t = options.i18n.global.t;
matrixService.config.globalProperties.$store = store; matrixService.config.globalProperties.$store = store;
matrixService.config.globalProperties.$config = app.$config; matrixService.config.globalProperties.$config = app.$config;
matrixService.config.globalProperties.$t = app.$t; matrixService.config.globalProperties.$t = t;
matrixService.config.globalProperties.$navigation = app.$navigation; matrixService.config.globalProperties.$navigation = app.$navigation;
matrixService.$store = store; matrixService.$store = store;
matrixService.$config = app.$config; matrixService.$config = app.$config;
matrixService.$t = app.$t; matrixService.$t = t;
matrixService.$navigation = app.$navigation; matrixService.$navigation = app.$navigation;
const instance = matrixService.mount("#app2"); const instance = matrixService.mount("#app2");
app.config.globalProperties.$matrix = instance; app.config.globalProperties.$matrix = instance;