Stop starting a new chat when the deletion did not happen

This commit is contained in:
Thorsten Sommer committed 2026-09-22 17:18:48 +02:00
1 parent 48ea2576f4
commit 9e91260720
1 file changed
+16 -27
@@ -1219,37 +1219,26 @@ public partial class ChatComponent : MSGComponentBase
if (this.ChatThread is not null && deletePreviousChat) if (this.ChatThread is not null && deletePreviousChat)
{ {
// //
// A deleted chat cannot be restored. The check above never covers this case, because // A deleted chat cannot be restored, and the check above never covers this path: it
// this path exists only while chats are stored automatically. So we ask here, with the // exists only while chats are stored automatically, while that check runs only while
// same question the chat list asks: // they are stored manually. So we let the deletion itself ask, with the question the
// chat list asks. When it reports the chat is still there, the user declined or the
// chat is busy, and we stop before the reset below takes it out of view:
// //
var workspaceName = await WorkspaceBehaviour.LoadWorkspaceNameAsync(this.ChatThread.WorkspaceId); bool chatIsGone;
var deleteDialogParameters = new DialogParameters<ConfirmDialog> if (this.Workspaces is null)
chatIsGone = await WorkspaceBehaviour.DeleteChatAsync(this.DialogService, this.ChatThread.WorkspaceId, this.ChatThread.ChatId);
else
{ {
{ var chatPath = this.ChatThread.WorkspaceId == Guid.Empty
x => x.Message, (this.ChatThread.WorkspaceId == Guid.Empty) switch ? Path.Join(SettingsManager.DataDirectory, "tempChats", this.ChatThread.ChatId.ToString())
{ : Path.Join(SettingsManager.DataDirectory, "workspaces", this.ChatThread.WorkspaceId.ToString(), this.ChatThread.ChatId.ToString());
true => string.Format(this.T("Are you sure you want to delete the temporary chat '{0}'?"), this.ChatThread.Name),
false => string.Format(this.T("Are you sure you want to delete the chat '{0}' in the workspace '{1}'?"), this.ChatThread.Name, workspaceName),
}
},
};
var deleteDialogReference = await this.DialogService.ShowAsync<ConfirmDialog>(this.T("Delete Chat"), deleteDialogParameters, DialogOptions.FULLSCREEN); chatIsGone = await this.Workspaces.DeleteChatAsync(chatPath, unloadChat: true);
var deleteDialogResult = await deleteDialogReference.Result; }
if (deleteDialogResult is null || deleteDialogResult.Canceled)
if (!chatIsGone)
return; return;
string chatPath;
if (this.ChatThread.WorkspaceId == Guid.Empty)
chatPath = Path.Join(SettingsManager.DataDirectory, "tempChats", this.ChatThread.ChatId.ToString());
else
chatPath = Path.Join(SettingsManager.DataDirectory, "workspaces", this.ChatThread.WorkspaceId.ToString(), this.ChatThread.ChatId.ToString());
if(this.Workspaces is null)
await WorkspaceBehaviour.DeleteChatAsync(this.DialogService, this.ChatThread.WorkspaceId, this.ChatThread.ChatId, askForConfirmation: false);
else
await this.Workspaces.DeleteChatAsync(chatPath, askForConfirmation: false, unloadChat: true);
} }
// //