Skip to content

Commit

Permalink
提高会话加载性能 (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
Richasy authored Jul 17, 2024
1 parent 4822bad commit 166589b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,18 @@ private void Initialize(ChatSession data)
CheckChatEmpty();
CheckLastMessageTime();
CheckRegenerateButtonShown();
CalcTotalTokenCount();
RequestFocusInput?.Invoke(this, EventArgs.Empty);
}

/// <summary>
/// 在进入视图开始显示时执行.
/// </summary>
[RelayCommand]
private void EnterView()
{
CalcTotalTokenCount();
}

[RelayCommand]
private void NewSession()
{
Expand Down Expand Up @@ -158,6 +166,12 @@ private void CheckRegenerateButtonShown()
[RelayCommand]
private void CalcTotalTokenCount()
{
var pageVM = GlobalDependencies.ServiceProvider.GetService<ChatServicePageViewModel>();
if (pageVM.CurrentSession != this)
{
return;
}

CalcBaseTokenCount();
CalcUserInputTokenCount();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ partial void OnGroupPanelTypeChanged(ChatGroupPanelType value)
CheckGroupPanelType();
}

partial void OnCurrentSessionChanged(ChatSessionViewModel value)
{
if (value is null)
{
return;
}

value.EnterViewCommand.Execute(default);
}

partial void OnIsServiceColumnManualHideChanged(bool value)
=> SettingsToolkit.WriteLocalSetting(SettingNames.IsChatServicePageServiceColumnManualHide, value);

Expand Down

0 comments on commit 166589b

Please sign in to comment.