🪻 distributed transcription service thistle.dunkirk.sh

bug: fix archiving

dunkirk.sh e55cc2b8 8763fc77

verified
Changed files
+16 -6
src
+10 -1
src/components/admin-classes.ts
···
private async handleToggleArchive(classId: string) {
try {
+
// Find the class to toggle its archived state
+
const classToToggle = this.classes.find(c => c.id === classId);
+
if (!classToToggle) return;
+
const response = await fetch(`/api/classes/${classId}/archive`, {
method: "PUT",
+
headers: { "Content-Type": "application/json" },
+
body: JSON.stringify({ archived: !classToToggle.archived }),
});
if (!response.ok) {
throw new Error("Failed to update class");
}
-
await this.loadData();
+
// Update local state instead of reloading
+
this.classes = this.classes.map(c =>
+
c.id === classId ? { ...c, archived: !c.archived } : c
+
);
} catch {
this.error = "Failed to update class. Please try again.";
}
+6 -5
src/components/admin-users.ts
···
timeout: number | null;
} | null = null;
-
private handleDeleteClick(userId: number, email: string, event: Event) {
+
private handleDeleteClick(userId: number, event: Event) {
event.stopPropagation();
// If this is a different item or timeout expired, reset
···
// Third click - actually delete
if (newClicks === 3) {
this.deleteState = null;
-
this.performDeleteUser(userId, email);
+
this.performDeleteUser(userId);
return;
}
···
this.deleteState = { id: userId, type: "user", clicks: newClicks, timeout };
}
-
private async performDeleteUser(userId: number, email: string) {
+
private async performDeleteUser(userId: number) {
try {
const response = await fetch(`/api/admin/users/${userId}`, {
method: "DELETE",
···
throw new Error("Failed to delete user");
}
-
await this.loadUsers();
+
// Remove user from local array instead of reloading
+
this.users = this.users.filter(u => u.id !== userId);
this.dispatchEvent(new CustomEvent("user-deleted"));
} catch (error) {
console.error("Failed to delete user:", error);
···
>
${this.revokingSubscriptions.has(u.id) ? "Revoking..." : this.getDeleteButtonText(u.id, "revoke")}
</button>
-
<button class="delete-btn" @click=${(e: Event) => this.handleDeleteClick(u.id, u.email, e)}>
+
<button class="delete-btn" @click=${(e: Event) => this.handleDeleteClick(u.id, e)}>
${this.getDeleteButtonText(u.id, "user")}
</button>
</div>