Skip to content

Commit 478fe49

Browse files
committed
fix: logic for drafts or scheduled only post cards
1 parent 5c1f3cd commit 478fe49

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Service/BlogDashboardService.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,12 @@ private extension BlogDashboardService {
8282
sections.append(DashboardCardSection(id: "posts", subtype: "scheduled"))
8383
items.append(DashboardCardModel(id: .posts, cellViewModel: scheduled as NSDictionary?))
8484
} else {
85+
var postsWithFlags = posts.copy() as? [String: Any]
86+
postsWithFlags?["show_drafts"] = hasDrafts
87+
postsWithFlags?["show_scheduled"] = hasScheduled
88+
8589
sections.append(DashboardCardSection(id: "posts"))
86-
items.append(DashboardCardModel(id: .posts, cellViewModel: posts))
90+
items.append(DashboardCardModel(id: .posts, cellViewModel: postsWithFlags as NSDictionary?))
8791
}
8892

8993
return (sections, items)

WordPress/WordPressTest/Dashboard/BlogDashboardServiceTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class BlogDashboardServiceTests: XCTestCase {
6565
// The item identifier id is posts
6666
XCTAssertEqual(snapshot.itemIdentifiers(inSection: draftsSection.first!).first?.id, .posts)
6767

68-
// For Drafts section, showScheduled is nil
68+
// For Drafts section, showScheduled is false
6969
XCTAssertFalse(snapshot.itemIdentifiers(inSection: draftsSection.first!).first?.cellViewModel?["show_scheduled"] as! Bool)
7070

7171
// For Drafts section, scheduled has 1 post

0 commit comments

Comments
 (0)