Skip to content
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

UI Modernization: Posts & Pages 📦 #21744

Merged
merged 180 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 142 commits
Commits
Show all changes
180 commits
Select commit Hold shift + click to select a range
203d499
Address TODOs in AbstractPostListViewController
kean Oct 10, 2023
f22ad39
update Jetpack filter bar selected color
Oct 11, 2023
4e21052
update unselected tab font to regular
Oct 11, 2023
dbeb1bc
Merge pull request #21734 from wordpress-mobile/task/21711-update-tab…
momo-ozawa Oct 12, 2023
c34ae0c
The initial native search implementation
kean Oct 12, 2023
247a25c
Merge pull request #21738 from wordpress-mobile/task/address-todos-in…
kean Oct 12, 2023
16775d5
Extract search to a separate screen
kean Oct 12, 2023
b205847
Merge pull request #21745 from wordpress-mobile/task/extract-search
kean Oct 13, 2023
57a473e
Fix an issue with search not reloading
kean Oct 13, 2023
97e25f5
Update sort descriptors
kean Oct 13, 2023
26cd066
Pass authorID to search
kean Oct 13, 2023
6f357f9
Merge branch 'trunk' into task/ui-modernization-posts-and-pages
Oct 16, 2023
a62e9ed
Merge pull request #21764 from wordpress-mobile/task/search-remaining…
kean Oct 16, 2023
3487b5d
Move authors filter button to navigation bar
kean Oct 14, 2023
c9cfffd
Authors filter now defaults to Everyone
kean Oct 16, 2023
2b95254
Remove Create Story action
kean Oct 16, 2023
b69129b
Merge pull request #21766 from wordpress-mobile/task/move-authors-filter
kean Oct 17, 2023
23000ed
Merge pull request #21794 from wordpress-mobile/task/create-new-popup
kean Oct 17, 2023
66fec0b
add new post cell files
Oct 17, 2023
c61cde3
show featured image
Oct 17, 2023
e56f447
extract labelStackView and ellipsisButton setup
Oct 17, 2023
93859ea
remove cell size switcher
Oct 17, 2023
c3b3144
register and display PostListCell
Oct 17, 2023
0989483
disable ghost table view
Oct 17, 2023
abfa744
capitalize first word for relative date strings
Oct 18, 2023
023eb10
update title font
Oct 18, 2023
9b10a54
show separator for posts list screen
Oct 18, 2023
3862d51
set background color for posts list cell
Oct 18, 2023
c96c43f
fix background color
Oct 18, 2023
a6762dc
adjust number of lines
Oct 18, 2023
a4d2c1c
combine title + snippet into a single attr string
Oct 18, 2023
4fbcc0c
Merge pull request #21804 from wordpress-mobile/task/21712-update-pos…
momo-ozawa Oct 18, 2023
67e9dbf
Use solid placeholder color for images
kean Oct 18, 2023
a0c6388
Implement fetching posts/pages list in PostRepository
crazytonyli Oct 18, 2023
4f8178a
Add API docs
crazytonyli Oct 18, 2023
fa641ec
Allow fetching post in empty range which means returning unlimited re…
crazytonyli Oct 18, 2023
ed47e2b
Update the doc to fix incorrect REST API behaviour
crazytonyli Oct 18, 2023
c980a30
Add unit tests for fetching posts list
crazytonyli Oct 18, 2023
4dac5b7
Use map instead of compactMap
crazytonyli Oct 19, 2023
2fdca5f
Merge pull request #21814 from wordpress-mobile/tonyli-simplify-post-…
crazytonyli Oct 19, 2023
d7f67ce
remove ghostable unit tests
Oct 19, 2023
9fc476d
Merge pull request #21823 from wordpress-mobile/task/solid-color-acti…
kean Oct 19, 2023
bd016b5
Add advanced filters
kean Oct 16, 2023
96a2b2b
Search all
kean Oct 16, 2023
26db2d0
Update WordPressKit
kean Oct 17, 2023
e26f2be
Use native separator
kean Oct 17, 2023
bac6644
Update design of token cells
kean Oct 17, 2023
4fe5d25
Improve scoring algorithm
kean Oct 17, 2023
61723b4
Update design of suggested tokens
kean Oct 17, 2023
c30b954
Make new search features available only for wp.com sites
kean Oct 17, 2023
e4cb9c3
Hide previous results when token is selected
kean Oct 17, 2023
71a6ce4
Fix separator display mode for tokens
kean Oct 17, 2023
039ec66
Improve how the search terms are highlighted
kean Oct 17, 2023
adc64f9
Tune suggestions
kean Oct 17, 2023
acd5b4f
Update conflicts
kean Oct 19, 2023
60739f9
Merge pull request #21806 from wordpress-mobile/task/21712-remove-cel…
momo-ozawa Oct 19, 2023
aa537e3
Merge pull request #21789 from wordpress-mobile/task/search-advanced-…
kean Oct 19, 2023
09389e1
Move highlighter to a separate file
kean Oct 19, 2023
826f8c6
Make PostListItemViewModel a class
kean Oct 19, 2023
9615bcb
Remove higlighting from PostSearchService
kean Oct 19, 2023
11445d8
Use PostItemCell in search
kean Oct 19, 2023
4f70d9d
Create search item ViewModels in PostSearchViewModel and unique them
kean Oct 19, 2023
7b8f23f
Move title creation to PostListItemViewModel
kean Oct 19, 2023
9ef7d21
Implement highlghting
kean Oct 19, 2023
3420a70
Remote top padding from sections
kean Oct 19, 2023
966f4ef
Update author filter design
kean Oct 19, 2023
2756f7c
Rename content label
kean Oct 20, 2023
9ca04a8
Merge pull request #21828 from wordpress-mobile/task/search-new-cells
kean Oct 20, 2023
451c415
Merge pull request #21837 from wordpress-mobile/task/update-author-fi…
kean Oct 20, 2023
904cafc
Remove unused code
kean Oct 19, 2023
0e37d08
Add new page cell design
kean Oct 19, 2023
b800ee3
Remove PageListTableViewCell
kean Oct 20, 2023
e07fef1
Remove the Undo button
kean Oct 20, 2023
37a4a3b
Fix crash
kean Oct 20, 2023
cebcffa
Update Homepage template cell design
kean Oct 20, 2023
8539bfa
Integrate the new page cell in search
kean Oct 20, 2023
10eacda
Simplify caching for search result items
kean Oct 20, 2023
a69c864
Fix margins and separator insets
kean Oct 23, 2023
2151deb
Merge pull request #21842 from wordpress-mobile/task/pages-new-cells
kean Oct 23, 2023
82bb44c
Merge pull request #21844 from wordpress-mobile/task/new-page-cells-i…
kean Oct 23, 2023
692c28f
add post menu helper
Oct 20, 2023
c3ccb63
show system image icons for post menu
Oct 20, 2023
183fce8
divide buttons into sections
Oct 23, 2023
2a13247
remove PostActionSheet
Oct 23, 2023
2100ace
add reverse dns key for localized strings
Oct 23, 2023
1fb9aa4
configure destructive title based on posts status
Oct 23, 2023
11ab0be
udpate menu icons
Oct 23, 2023
67b8085
make delegate weak to avoid potential retain cycle
Oct 23, 2023
1f44c50
Add indentation support
kean Oct 23, 2023
d159c14
Add subdirectory icon
kean Oct 23, 2023
4972e37
add explicit type
Oct 24, 2023
591f3c3
fix CI build errors
Oct 24, 2023
13874d4
Fix typo
kean Oct 24, 2023
63f1929
Merge pull request #21850 from wordpress-mobile/task/21717-post-conte…
momo-ozawa Oct 24, 2023
a4ddecd
Fix subdirectory color
kean Oct 24, 2023
5438098
Merge pull request #21853 from wordpress-mobile/task/pages-hierarchy
kean Oct 24, 2023
8da27c9
Remove unused search
kean Oct 24, 2023
27ac0d4
Remove section grouping from scheduled pages
kean Oct 24, 2023
44d9e64
Fix header size
kean Oct 24, 2023
4e25082
Remove windowless cell
kean Oct 24, 2023
4b8cef6
Remove ghosts
kean Oct 24, 2023
6c24bd8
Remove estimated row height
kean Oct 24, 2023
679fdfe
Fix separator insets in post cells
kean Oct 24, 2023
6271ffe
Fix post cell background color
kean Oct 24, 2023
6141e86
Revert PostListFooter change
kean Oct 24, 2023
bc08732
Remove unused updatePostWithIndex
kean Oct 24, 2023
c159b8f
Remove unneeded @objc annotations
kean Oct 24, 2023
a3657e0
Use standard footer
kean Oct 24, 2023
c00b68b
Update to use modern Swift syntax in closures
kean Oct 24, 2023
9857448
Merge pull request #21871 from wordpress-mobile/task/remove-dead-code…
kean Oct 25, 2023
b977b37
Merge pull request #21874 from wordpress-mobile/task/refactor-post-an…
kean Oct 25, 2023
608ee54
Merge branch 'trunk' into task/merge-trunk
Oct 25, 2023
80ef83a
Implement selection for posts in search
kean Oct 25, 2023
4eb2a7e
Implement context menu for posts
kean Oct 25, 2023
0f04299
Move snapshot to ViewModel
kean Oct 25, 2023
b84dfad
Implement reload
kean Oct 25, 2023
00acccf
Rework how highligher is implemented
kean Oct 25, 2023
9296091
remove obsolete test
Oct 26, 2023
d97bde9
Merge pull request #21883 from wordpress-mobile/task/merge-trunk
momo-ozawa Oct 26, 2023
998aab6
add comments action
Oct 23, 2023
98aae53
track comments action
Oct 24, 2023
5f298a3
add compression resistance / hugging priorities
Oct 23, 2023
bd48db2
Update review comments
kean Oct 26, 2023
3d81273
Merge pull request #21884 from wordpress-mobile/task/integrate-select…
kean Oct 26, 2023
0ae0e4a
Replace the eye icon
kean Oct 26, 2023
6d67bf6
Merge pull request #21899 from wordpress-mobile/task/replace-the-eye
kean Oct 26, 2023
31bae6a
add tests for post card status viewmodel buttons
Oct 25, 2023
81752c4
Merge branch 'task/ui-modernization-posts-and-pages' into task/21718-…
Oct 26, 2023
5f43a04
drop “Go to” from stats and comments actions
Oct 26, 2023
7593e15
Display post status
kean Oct 25, 2023
515e4a5
Display status with date for pages
kean Oct 26, 2023
ddb5a81
Fix spacing for excerpts
kean Oct 26, 2023
2f4cfa0
Switch to dateModified to trashed
kean Oct 26, 2023
a9c9ebf
Use attributed string for post badges
kean Oct 26, 2023
40c9e5e
Update l10n
kean Oct 26, 2023
3319127
Remove isAuthorBadgeHidden
kean Oct 26, 2023
df32811
Merge pull request #21886 from wordpress-mobile/task/21718-add-commen…
momo-ozawa Oct 27, 2023
98d5d32
Merge branch 'trunk' into task/merge-trunk-ui-mod
kean Oct 27, 2023
f8eadd2
Fix a warning
kean Oct 27, 2023
e75b291
fix move to trash toast message
Oct 27, 2023
2e6a7bc
Merge pull request #21905 from wordpress-mobile/task/merge-trunk-ui-mod
kean Oct 27, 2023
cbd8b36
Merge pull request #21898 from wordpress-mobile/task/display-post-status
kean Oct 27, 2023
b966e2e
Move post deletion to PostCoordinator
kean Oct 27, 2023
b860290
Update post cell status when post is being deleted
kean Oct 27, 2023
bdcf736
Add support for post deletion status in search
kean Oct 27, 2023
8600f2f
Animate reloads
kean Oct 27, 2023
8c85002
Show latest posts in search
kean Oct 30, 2023
cb9b4c7
Fix an issue with tags not syncing
kean Oct 30, 2023
f3a33d2
Move delegate to search VC
kean Oct 30, 2023
73cd747
Fix tokens layout issue
kean Oct 30, 2023
c08a259
extract abstract post buttons
Oct 27, 2023
64b9da7
add page menu view model
Oct 27, 2023
a2bd951
Merge pull request #21913 from wordpress-mobile/task/show-latest-post…
kean Oct 31, 2023
89936d4
Merge pull request #21918 from wordpress-mobile/task/fix-tags-not-loa…
kean Oct 31, 2023
9756363
copy page action implementation from pages list vc
Oct 30, 2023
66e8b48
track blaze entry displayed for pages
Oct 30, 2023
12c91c1
remove copy link
Oct 31, 2023
ef7db8e
add page menu view model tests
Oct 31, 2023
0ed100d
fix post card status view model tests
Oct 31, 2023
2b8e2ec
Remove Undo button
kean Oct 31, 2023
f953615
Fix an issue with footer view displaying when not needed
kean Oct 31, 2023
71b0b98
Fix an issue with footer view height
kean Oct 31, 2023
74ae213
Fix no results position
kean Oct 31, 2023
364f183
Enable page context menu in search
kean Oct 31, 2023
a2ac88a
Fix cell background in dark mode
kean Oct 31, 2023
fe60951
Fix filter bar layout in landscape
kean Oct 31, 2023
5ea26cf
Merge pull request #21907 from wordpress-mobile/task/add-deletion-loa…
kean Nov 1, 2023
f3be833
Merge pull request #21924 from wordpress-mobile/task/21873-pages-cont…
momo-ozawa Nov 1, 2023
aa04af1
Merge pull request #21926 from wordpress-mobile/task/fix-footer-view
kean Nov 1, 2023
1643aad
Merge pull request #21927 from wordpress-mobile/task/fix-no-results-p…
kean Nov 1, 2023
9f451e6
Merge pull request #21928 from wordpress-mobile/task/pages-context-me…
kean Nov 1, 2023
d971cab
Merge branch 'trunk' into task/posts-merge-trunk-43242134
kean Nov 1, 2023
7899283
configure accessiblity label for post list cells
Nov 1, 2023
b649cfd
Fix warnings after merge
kean Nov 1, 2023
e4aac98
Fix search bar placement on iPad
kean Nov 1, 2023
1495e26
Remove RestorePostTableViewCell.swift
kean Nov 1, 2023
7258351
Remove WPPickerView
kean Nov 1, 2023
7466307
Update WordPressKit to 8.10
kean Nov 1, 2023
6737579
Merge pull request #21933 from wordpress-mobile/task/add-tag-param
kean Nov 1, 2023
fe35d53
Merge branch 'trunk' into task/ui-modernization-posts-and-pages
kean Nov 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def wordpress_ui
end

def wordpress_kit
pod 'WordPressKit', '~> 8.7', '>= 8.7.1'
pod 'WordPressKit', '~> 8.8'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice that the addition of tag to PostServiceRemoteOptions in 8.8.0 was a breaking change and has been reverted via wordpress-mobile/WordPressKit-iOS#639 to unblock the 23.6 code freeze.

See also https://github.com/wordpress-mobile/WordPressKit-iOS/pull/634/files#r1375696151

# pod 'WordPressKit', git: 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', tag: ''
# pod 'WordPressKit', git: 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', branch: ''
# pod 'WordPressKit', git: 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', commit: ''
Expand Down
8 changes: 4 additions & 4 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ PODS:
- WordPressKit (~> 8.7-beta)
- WordPressShared (~> 2.1-beta)
- WordPressUI (~> 1.7-beta)
- WordPressKit (8.7.1):
- WordPressKit (8.8.0):
- Alamofire (~> 4.8.0)
- NSObject-SafeExpectations (~> 0.0.4)
- UIDeviceIdentifier (~> 2.0)
Expand Down Expand Up @@ -126,7 +126,7 @@ DEPENDENCIES:
- SwiftLint (~> 0.50)
- WordPress-Editor-iOS (~> 1.19.9)
- WordPressAuthenticator (~> 7.2.1-beta.2)
- WordPressKit (>= 8.7.1, ~> 8.7)
- WordPressKit (~> 8.8)
- WordPressShared (~> 2.2)
- WordPressUI (~> 1.15)
- WPMediaPicker (>= 1.8.10, ~> 1.8)
Expand Down Expand Up @@ -226,7 +226,7 @@ SPEC CHECKSUMS:
WordPress-Aztec-iOS: fbebd569c61baa252b3f5058c0a2a9a6ada686bb
WordPress-Editor-iOS: bda9f7f942212589b890329a0cb22547311749ef
WordPressAuthenticator: 1d73abee8fdd87032e987c40f140423a6aa0e577
WordPressKit: 33a0571389da6b40c765398a8c84da72f5514a6f
WordPressKit: df18103fb11fefcbccad6aa4df222dc7d408ade5
WordPressShared: 87f3ee89b0a3e83106106f13a8b71605fb8eb6d2
WordPressUI: a491454affda3b0fb812812e637dc5e8f8f6bd06
WPMediaPicker: 332812329cbdc672cdb385b8ac3a389f668d3012
Expand All @@ -240,6 +240,6 @@ SPEC CHECKSUMS:
ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba
ZIPFoundation: d170fa8e270b2a32bef9dcdcabff5b8f1a5deced

PODFILE CHECKSUM: fe27477bb386333975be481e9f9718ea47ec4e29
PODFILE CHECKSUM: 9859c4a7e3c33bfba28627d1a7509f2f1182f08e

COCOAPODS: 1.12.1
207 changes: 207 additions & 0 deletions WordPress/Classes/Services/PostRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,210 @@ final class PostRepository {
}

}

// MARK: - Posts/Pages List

private final class PostRepositoryPostsSerivceRemoteOptions: NSObject, PostServiceRemoteOptions {
struct Options {
var statuses: [String]?
var number: Int = 100
var offset: Int = 0
var order: PostServiceResultsOrder = .descending
var orderBy: PostServiceResultsOrdering = .byDate
var authorID: NSNumber?
var search: String?
var meta: String? = "autosave"
var tag: String?
}

var options: Options

init(options: Options) {
self.options = options
}

func statuses() -> [String]? {
options.statuses
}

func number() -> NSNumber {
NSNumber(value: options.number)
}

func offset() -> NSNumber {
NSNumber(value: options.offset)
}

func order() -> PostServiceResultsOrder {
options.order
}

func orderBy() -> PostServiceResultsOrdering {
options.orderBy
}

func authorID() -> NSNumber? {
options.authorID
}

func search() -> String? {
options.search
}

func meta() -> String? {
options.meta
}

func tag() -> String! {
options.tag
}
}

private extension PostServiceRemote {

func getPosts(ofType type: String, options: PostRepositoryPostsSerivceRemoteOptions) async throws -> [RemotePost] {
try await withCheckedThrowingContinuation { continuation in
self.getPostsOfType(type, options: self.dictionary(with: options), success: {
continuation.resume(returning: $0 ?? [])
}, failure: {
continuation.resume(throwing: $0!)
})
}
}
}

extension PostRepository {

/// Fetch posts or pages from the given site page by page. All fetched posts are saved to the local database.
///
/// - Parameters:
/// - type: `Post.self` and `Page.self` are the only acceptable types.
/// - statuses: Filter posts or pages with given status.
/// - authorUserID: Filter posts or pages that are authored by given user.
/// - offset: The position of the paginated request. Pass 0 for the first page and count of already fetched results for following pages.
/// - number: Number of posts or pages should be fetched.
/// - blogID: The blog from which to fetch posts or pages
/// - Returns: Object identifiers of the fetched posts.
/// - SeeAlso: https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/posts/
func paginate<P: AbstractPost>(
type: P.Type = P.self,
statuses: [BasePost.Status],
authorUserID: NSNumber? = nil,
offset: Int,
number: Int,
in blogID: TaggedManagedObjectID<Blog>
) async throws -> [TaggedManagedObjectID<P>] {
try await fetch(
type: type,
statuses: statuses,
authorUserID: authorUserID,
range: offset..<(offset + max(number, 0)),
orderBy: .byDate,
descending: true,
// Only delete other local posts if the current call is the first pagination request.
deleteOtherLocalPosts: offset == 0,
in: blogID
)
}

/// Search posts or pages in the given site. All fetched posts are saved to the local database.
///
/// - Parameters:
/// - type: `Post.self` and `Page.self` are the only acceptable types.
/// - input: The text input from user. Or `nil` for searching all posts or pages.
/// - statuses: Filter posts or pages with given status.
/// - authorUserID: Filter posts or pages that are authored by given user.
/// - limit: Number of posts or pages should be fetched.
/// - orderBy: The property by which to sort posts or pages.
/// - descending: Whether to sort the results in descending order.
/// - blogID: The blog from which to search posts or pages
/// - Returns: Object identifiers of the search result.
/// - SeeAlso: https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/posts/
func search<P: AbstractPost>(
type: P.Type = P.self,
input: String?,
statuses: [BasePost.Status],
authorUserID: NSNumber? = nil,
limit: Int,
orderBy: PostServiceResultsOrdering,
descending: Bool,
in blogID: TaggedManagedObjectID<Blog>
) async throws -> [TaggedManagedObjectID<P>] {
try await fetch(
type: type,
searchInput: input,
statuses: statuses,
authorUserID: authorUserID,
range: 0..<max(limit, 0),
orderBy: orderBy,
descending: descending,
deleteOtherLocalPosts: false,
in: blogID
)
}

private func fetch<P: AbstractPost>(
type: P.Type,
searchInput: String? = nil,
statuses: [BasePost.Status]?,
authorUserID: NSNumber?,
range: Range<Int>,
orderBy: PostServiceResultsOrdering = .byDate,
descending: Bool = true,
deleteOtherLocalPosts: Bool,
in blogID: TaggedManagedObjectID<Blog>
) async throws -> [TaggedManagedObjectID<P>] {
assert(type == Post.self || type == Page.self, "Only support fetching Post or Page")
assert(range.lowerBound >= 0)

let postType: String
if type == Post.self {
postType = "post"
} else if type == Page.self {
postType = "page"
} else {
// There is an assertion above to ensure the app doesn't fall into this case.
return []
}

let remote = try await coreDataStack.performQuery { [remoteFactory] context in
let blog = try context.existingObject(with: blogID)
return remoteFactory.forBlog(blog)
}
guard let remote else {
throw PostRepository.Error.remoteAPIUnavailable
}

let options = PostRepositoryPostsSerivceRemoteOptions(options: .init(
statuses: statuses?.strings,
number: range.count,
offset: range.lowerBound,
order: descending ? .descending : .ascending,
orderBy: orderBy,
authorID: authorUserID,
search: searchInput
))
let remotePosts = try await remote.getPosts(ofType: postType, options: options)

let updatedPosts = try await coreDataStack.performAndSave { context in
let updatedPosts = PostHelper.merge(
remotePosts,
ofType: postType,
withStatuses: statuses?.strings,
byAuthor: authorUserID,
for: try context.existingObject(with: blogID),
purgeExisting: deleteOtherLocalPosts,
in: context
)
return updatedPosts.map {
guard let post = $0 as? P else {
fatalError("Expecting a \(postType) as \(type), but got \($0)")
}
return TaggedManagedObjectID(post)
}
}

return updatedPosts
}

}
1 change: 1 addition & 0 deletions WordPress/Classes/Services/PostServiceOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
@property (nonatomic, strong) NSNumber *authorID;
@property (nonatomic, copy) NSString *search;
@property (nonatomic, copy) NSString *meta;
@property (nonatomic, copy) NSString *tag;

@end
1 change: 0 additions & 1 deletion WordPress/Classes/System/WordPress-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

#import "NSObject+Helpers.h"

#import "PageListTableViewCell.h"
#import "PageSettingsViewController.h"
#import "PostContentProvider.h"
#import "PostCategory.h"
Expand Down
5 changes: 5 additions & 0 deletions WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ import Foundation

// Post List
case postListShareAction
case postListCommentsAction
case postListSetAsPostsPageAction
case postListSetHomePageAction

Expand Down Expand Up @@ -960,6 +961,8 @@ import Foundation
// Post List
case .postListShareAction:
return "post_list_button_pressed"
case .postListCommentsAction:
return "post_list_button_pressed"
case .postListSetAsPostsPageAction:
return "post_list_button_pressed"
case .postListSetHomePageAction:
Expand Down Expand Up @@ -1415,6 +1418,8 @@ import Foundation
return ["via": "tenor"]
case .postListShareAction:
return ["button": "share"]
case .postListCommentsAction:
return ["button": "comments"]
case .postListSetAsPostsPageAction:
return ["button": "set_posts_page"]
case .postListSetHomePageAction:
Expand Down
23 changes: 17 additions & 6 deletions WordPress/Classes/Utility/Media/ImageLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import AutomatticTracks
// MARK: Private Fields

private unowned let imageView: CachedAnimatedImageView
private let loadingIndicator: CircularProgressView
private let loadingIndicator: ActivityIndicatorType

private var successHandler: ImageLoaderSuccessBlock?
private var errorHandler: ImageLoaderFailureBlock?
Expand All @@ -47,17 +47,28 @@ import AutomatticTracks
return requestOptions
}()

@objc init(imageView: CachedAnimatedImageView, gifStrategy: GIFStrategy = .mediumGIFs) {
@objc convenience init(imageView: CachedAnimatedImageView, gifStrategy: GIFStrategy = .mediumGIFs) {
self.init(imageView: imageView, gifStrategy: gifStrategy, loadingIndicator: nil)
}

init(imageView: CachedAnimatedImageView, gifStrategy: GIFStrategy = .mediumGIFs, loadingIndicator: ActivityIndicatorType?) {
self.imageView = imageView
imageView.gifStrategy = gifStrategy
loadingIndicator = CircularProgressView(style: .primary)

if let loadingIndicator {
self.loadingIndicator = loadingIndicator
} else {
let loadingIndicator = CircularProgressView(style: .primary)
WPStyleGuide.styleProgressViewWhite(loadingIndicator)
self.loadingIndicator = loadingIndicator
}

super.init()

WPStyleGuide.styleProgressViewWhite(loadingIndicator)
imageView.addLoadingIndicator(loadingIndicator, style: .fullView)
imageView.addLoadingIndicator(self.loadingIndicator, style: .fullView)
}


/// Removes the gif animation and prevents it from animate again.
/// Call this in a table/collection cell's `prepareForReuse()`.
///
Expand Down Expand Up @@ -298,7 +309,7 @@ import AutomatticTracks
}

if self.imageView.shouldShowLoadingIndicator {
self.loadingIndicator.state = .error
(self.loadingIndicator as? CircularProgressView)?.state = .error
}

self.errorHandler?(error)
Expand Down
Loading