mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-13 09:53:48 +00:00
Fixed the warning about unsaved changes appearing only by chance (#1050)
This commit is contained in:
1 parent
468d28aa94
commit
c43b52d483
11 files changed
+213
-20
No files matched your search
@@ -2106,26 +2106,26 @@ public partial class ChatComponent : MSGComponentBase
|
||||
}
|
||||
}
|
||||
|
||||
protected override Task<TResult?> ProcessIncomingMessageWithResult<TPayload, TResult>(ComponentBase? sendingComponent, Event triggeredEvent, TPayload? data) where TResult : default where TPayload : default
|
||||
protected override Task<MessageBusAnswer<TResult>> ProcessIncomingMessageWithResult<TPayload, TResult>(ComponentBase? sendingComponent, Event triggeredEvent, TPayload? data) where TPayload : default
|
||||
{
|
||||
switch (triggeredEvent)
|
||||
{
|
||||
case Event.HAS_CHAT_UNSAVED_CHANGES:
|
||||
if(this.SettingsManager.ConfigurationData.Workspace.StorageBehavior is WorkspaceStorageBehavior.STORE_CHATS_AUTOMATICALLY)
|
||||
return Task.FromResult((TResult?) (object) false);
|
||||
return Task.FromResult(new MessageBusAnswer<TResult>(true, (TResult) (object) false));
|
||||
|
||||
if (this.IsCurrentChatStreaming)
|
||||
return Task.FromResult((TResult?) (object) false);
|
||||
return Task.FromResult(new MessageBusAnswer<TResult>(true, (TResult) (object) false));
|
||||
|
||||
//
|
||||
// A message the user started counts as unsaved on its own only while there is no chat
|
||||
// to keep it. Otherwise, it is part of the chat: changing it counts as a change of the
|
||||
// chat, and a message which came back from the disk with the chat is saved already.
|
||||
//
|
||||
return Task.FromResult((TResult?)(object)(this.hasUnsavedChanges || (this.ChatThread is null && this.ComposerState.HasVisibleUserDraft)));
|
||||
return Task.FromResult(new MessageBusAnswer<TResult>(true, (TResult)(object)(this.hasUnsavedChanges || (this.ChatThread is null && this.ComposerState.HasVisibleUserDraft))));
|
||||
}
|
||||
|
||||
return Task.FromResult(default(TResult));
|
||||
|
||||
return Task.FromResult(MessageBusAnswer<TResult>.NONE);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -67,7 +67,7 @@ public abstract class MSGComponentBase : ComponentBase, IDisposable, IAsyncDispo
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<TResult?> ProcessMessageWithResult<TPayload, TResult>(ComponentBase? sendingComponent, Event triggeredEvent, TPayload? data)
|
||||
public async Task<MessageBusAnswer<TResult>> ProcessMessageWithResult<TPayload, TResult>(ComponentBase? sendingComponent, Event triggeredEvent, TPayload? data)
|
||||
{
|
||||
return await this.ProcessIncomingMessageWithResult<TPayload, TResult>(sendingComponent, triggeredEvent, data);
|
||||
}
|
||||
@@ -79,9 +79,13 @@ public abstract class MSGComponentBase : ComponentBase, IDisposable, IAsyncDispo
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected virtual Task<TResult?> ProcessIncomingMessageWithResult<TPayload, TResult>(ComponentBase? sendingComponent, Event triggeredEvent, TPayload? data)
|
||||
/// <summary>
|
||||
/// Answers a question from the message bus. Override this for the questions your component handles,
|
||||
/// and return MessageBusAnswer.NONE for every other one.
|
||||
/// </summary>
|
||||
protected virtual Task<MessageBusAnswer<TResult>> ProcessIncomingMessageWithResult<TPayload, TResult>(ComponentBase? sendingComponent, Event triggeredEvent, TPayload? data)
|
||||
{
|
||||
return Task.FromResult<TResult?>(default);
|
||||
return Task.FromResult(MessageBusAnswer<TResult>.NONE);
|
||||
}
|
||||
|
||||
protected async Task SendMessage<T>(Event triggeredEvent, T? data = default)
|
||||
|
||||
Reference in new issue
Block a user