-
Notifications
You must be signed in to change notification settings - Fork 12
feat(instancesaves):存档搜索排序 #1785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
xrlzu
commented
Oct 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds search and sort functionality to the instance saves management page. The implementation includes a search box for filtering saves by name, sort options (by filename, creation time, or modification time), and a file system watcher to automatically refresh the saves list when changes occur.
Key Changes:
- Added search functionality with fuzzy matching for save names
- Implemented three sorting methods: filename, creation time, and modification time
- Added FileSystemWatcher for automatic refresh on file system changes
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| PageInstanceSaves.xaml.vb | Implements search/sort logic, FileSystemWatcher integration, and UI refresh handling |
| PageInstanceSaves.xaml | Adds search box UI component and sort button to the interface |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| Private Sub OnFileSystemChanged(sender As Object, e As FileSystemEventArgs) | ||
| RunInUi(Sub() | ||
| Threading.Thread.Sleep(100) |
Copilot
AI
Oct 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Thread.Sleep in a UI callback can block the UI thread. Consider using a debounce mechanism with a timer instead to batch multiple rapid file system changes and avoid potential UI freezes.
| End If | ||
| Try | ||
| If IsSearching Then | ||
| PanListBack.Title = $"搜索结果 ({_searchResult?.Count})" |
Copilot
AI
Oct 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential issue: _searchResult?.Count will return Nothing (null) when _searchResult is Nothing, which will display as empty string in the title. Use _searchResult?.Count.GetValueOrDefault(0) or handle the null case explicitly to always show a number.
| PanListBack.Title = $"搜索结果 ({_searchResult?.Count})" | |
| PanListBack.Title = $"搜索结果 ({_searchResult?.Count.GetValueOrDefault(0)})" |
| If IsSearching Then | ||
| Dim queryList As New List(Of SearchEntry(Of String)) | ||
| For Each saveFolder In saveFolders | ||
| Dim folderName = GetFolderNameFromPath(saveFolder) |
Copilot
AI
Oct 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function GetFolderNameFromPath is called but not defined in this file. Verify that this function exists and is accessible, otherwise this will cause a compilation error.
| fileSystemWatcher.Dispose() | ||
| End If | ||
|
|
||
| fileSystemWatcher = New FileSystemWatcher() |
Copilot
AI
Oct 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing validation: if WorldPath doesn't exist or is invalid, this will throw an ArgumentException. Add a check using Directory.Exists(WorldPath) before setting the Path property.
| fileSystemWatcher = New FileSystemWatcher() | |
| fileSystemWatcher = New FileSystemWatcher() | |
| If Not Directory.Exists(WorldPath) Then Directory.CreateDirectory(WorldPath) |
| searchSource.Add(New KeyValuePair(Of String, Double)(folderName, 1)) | ||
| queryList.Add(New SearchEntry(Of String) With {.Item = saveFolder, .SearchSource = searchSource}) | ||
| Next | ||
| _searchResult = Search(queryList, SearchBox.Text, MaxBlurCount:=6, MinBlurSimilarity:=0.35).Select(Function(r) r.Item).ToList() |
Copilot
AI
Oct 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The search operation executes on every TextChanged event, which could cause performance issues with large save lists. Consider implementing debouncing to delay search execution until the user stops typing.
|
? |