-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Ensure current site is always displayed in Sidebar List #24277
Ensure current site is always displayed in Sidebar List #24277
Conversation
- Update `BlogListViewModel.swift` to link `sidebarViewModel` and add logic for `currentSite`. - Modify `SidebarViewController.swift` to set `blogListViewModel.sidebarViewModel` during initialization. - Refactor `topSites` logic to ensure the current site is included, recent sites are prioritized, and all sites are sorted alphabetically.
…569-ensure-current-site-is-always-displayed-in-sidebar-list
var encounteredIDs = Set(topSites.map(\.id)) | ||
for site in allSites where !encounteredIDs.contains(site.id) { | ||
if topSites.count >= SidebarView.displayedSiteLimit { | ||
var displaySites = [BlogListSiteViewModel]() |
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.
Have you tried the steps from #23569? I vaguely remember this code, but I think we opened it just in case. I doubt it's a real issue. recentSites
always has your most recently selected site as the first item of the array. It's impossible for it to not get displayed. I might be wrong – not entirely sure about this code.
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.
|
App Name | ![]() |
|
Configuration | Release-Alpha | |
Build Number | pr24277-8aeec84 | |
Version | 25.8 | |
Bundle ID | org.wordpress.alpha | |
Commit | 8aeec84 | |
App Center Build | WPiOS - One-Offs #11793 |
|
App Name | ![]() |
|
Configuration | Release-Alpha | |
Build Number | pr24277-8aeec84 | |
Version | 25.8 | |
Bundle ID | com.jetpack.alpha | |
Commit | 8aeec84 | |
App Center Build | jetpack-installable-builds #10818 |
} | ||
|
||
// Add recent sites up to the limit | ||
for site in recentSites { |
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.
(nit) you should be able to merge these two loops in one: for site in recentSites + allSites
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.
Good suggestion f802776
return nil | ||
} | ||
|
||
return allSites.first { $0.id == selectedBlogID } |
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.
(nit) I'd probably suggest using try mainContext.existingObject(with: objectID)
instead of iterating over allSites
.
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.
👍 implemented here 5bcfca3
@@ -70,4 +70,120 @@ final class BlogListViewModelTests: CoreDataTestCase { | |||
let displayedNames = viewModel.allSites.map(\.title) | |||
XCTAssertEqual(displayedNames, [".Org", "51 Zone", "A", "C"]) | |||
} | |||
|
|||
func test_topSites_includes_current_site() throws { |
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.
(nit) please use camel case. Btw, for new tests (new suites), feel free to use Swift Testing.
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.
Updated here 8aeec84 👍
…t` for improved error handling
Fixes #23569
This PR modifies the sidebar site display logic to ensure the currently selected site is always visible, regardless of its position in the recent sites list or alphabetical order.
Changes Made
Testing Instructions
On iPad/simulator
SidebarView.displayedSiteLimit
to a number smaller thanRecentSitesService.maxSiteCount
Screenshot
Regression Notes
Potential unintended areas of impact
What I did to test those areas of impact (or what existing automated tests I relied on)
What automated tests I added (or what prevented me from doing so)
PR submission checklist:
RELEASE-NOTES.txt
if necessary.Testing checklist: