-
Notifications
You must be signed in to change notification settings - Fork 30
fix: several bugs around collection displaying & editing #285
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1d7c2b5
fix: invalid collection type
baiyuanneko 129d112
fix: incomplete track list in Mix
baiyuanneko db8f3c8
fix: incomplete track list in Mix studio
baiyuanneko 8260479
fix: optimize display effect
baiyuanneko 221c00c
chore: remove unused logs
baiyuanneko ca37035
chore: remove unused debug logs
baiyuanneko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -48,11 +48,45 @@ class QueryTrackListViewState extends State<QueryTrackListView> { | |||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| Future<void> _initializeData() async { | ||||||||||||||||||||||||||||||||||||
| // Pre-load first page before marking as initialized | ||||||||||||||||||||||||||||||||||||
| await _loadPageForInitialization(0); | ||||||||||||||||||||||||||||||||||||
| setState(() { | ||||||||||||||||||||||||||||||||||||
| _isInitialized = true; | ||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||
| // Pre-load first page | ||||||||||||||||||||||||||||||||||||
| _loadPage(0); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
50
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (performance): Blocking initialization on data load may impact perceived performance. Initializing the UI before loading data and displaying a loading indicator can enhance responsiveness, especially on slow networks.
Suggested change
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| Future<void> _loadPageForInitialization(int cursor) async { | ||||||||||||||||||||||||||||||||||||
| if (_loadingIndices.contains(cursor) || _reachedEnd) return; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| _loadingIndices.add(cursor); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||
| final newItems = await queryMixTracks(widget.queries, cursor, _pageSize); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if (!mounted) return; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| for (var i = 0; i < newItems.length; i++) { | ||||||||||||||||||||||||||||||||||||
| _loadedItems[cursor + i] = newItems[i]; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| _loadingIndices.remove(cursor); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // Check if we've reached the end | ||||||||||||||||||||||||||||||||||||
| if (newItems.length < _pageSize) { | ||||||||||||||||||||||||||||||||||||
| _reachedEnd = true; | ||||||||||||||||||||||||||||||||||||
| _totalCount = cursor + newItems.length; | ||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||
| final loadedCount = cursor + newItems.length; | ||||||||||||||||||||||||||||||||||||
| _totalCount = loadedCount + _pageSize; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| Timer( | ||||||||||||||||||||||||||||||||||||
| Duration(milliseconds: gridAnimationDelay), | ||||||||||||||||||||||||||||||||||||
| () => widget.layoutManager.playAnimations(), | ||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||
| if (!mounted) return; | ||||||||||||||||||||||||||||||||||||
| _loadingIndices.remove(cursor); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| Future<void> _loadPage(int cursor) async { | ||||||||||||||||||||||||||||||||||||
|
|
@@ -80,16 +114,15 @@ class QueryTrackListViewState extends State<QueryTrackListView> { | |||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| _loadingIndices.remove(cursor); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // Update total count | ||||||||||||||||||||||||||||||||||||
| final newTotal = cursor + newItems.length; | ||||||||||||||||||||||||||||||||||||
| if (newTotal > _totalCount) { | ||||||||||||||||||||||||||||||||||||
| _totalCount = newTotal; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // Check if we've reached the end | ||||||||||||||||||||||||||||||||||||
| if (newItems.length < _pageSize) { | ||||||||||||||||||||||||||||||||||||
| _reachedEnd = true; | ||||||||||||||||||||||||||||||||||||
| _totalCount = cursor + newItems.length; | ||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||
| // If we haven't reached the end, assume there's at least one more page | ||||||||||||||||||||||||||||||||||||
| // This allows the UI to scroll and trigger loading the next page | ||||||||||||||||||||||||||||||||||||
| final loadedCount = cursor + newItems.length; | ||||||||||||||||||||||||||||||||||||
| _totalCount = loadedCount + _pageSize; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
suggestion: Info-level logging for every query may be excessive in production.
Consider lowering the log level or adding log sampling to prevent excessive logging if this function is called often.
Suggested implementation:
If you want to implement log sampling (e.g., only log every Nth call), you would need to introduce a counter or use a sampling library. If you want this, let me know and I can provide a code example.