Skip to content

Commit 3d4d7dc

Browse files
committed
Merge branch 'trunk' into feature/media-permissions-dynamic-type
2 parents 02eea89 + 83768bb commit 3d4d7dc

29 files changed

+1452
-698
lines changed

Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def wordpress_ui
4747
end
4848

4949
def wordpress_kit
50-
pod 'WordPressKit', '~> 4.46.0-beta.1'
50+
pod 'WordPressKit', '~> 4.46.0-beta'
5151
# pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :tag => ''
5252
# pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :branch => ''
5353
# pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :commit => ''

Podfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ PODS:
465465
- WordPressKit (~> 4.18-beta)
466466
- WordPressShared (~> 1.12-beta)
467467
- WordPressUI (~> 1.7-beta)
468-
- WordPressKit (4.46.0-beta.1):
468+
- WordPressKit (4.46.0-beta.2):
469469
- Alamofire (~> 4.8.0)
470470
- CocoaLumberjack (~> 3.4)
471471
- NSObject-SafeExpectations (= 0.0.4)
@@ -569,7 +569,7 @@ DEPENDENCIES:
569569
- SVProgressHUD (= 2.2.5)
570570
- WordPress-Editor-iOS (~> 1.19.7)
571571
- WordPressAuthenticator (~> 1.43.0-beta.2)
572-
- WordPressKit (~> 4.46.0-beta.1)
572+
- WordPressKit (~> 4.46.0-beta)
573573
- WordPressMocks (~> 0.0.15)
574574
- WordPressShared (~> 1.17.0)
575575
- WordPressUI (~> 1.12.3)
@@ -581,6 +581,7 @@ DEPENDENCIES:
581581
SPEC REPOS:
582582
https://github.com/wordpress-mobile/cocoapods-specs.git:
583583
- WordPressAuthenticator
584+
- WordPressKit
584585
trunk:
585586
- Alamofire
586587
- AlamofireImage
@@ -619,7 +620,6 @@ SPEC REPOS:
619620
- UIDeviceIdentifier
620621
- WordPress-Aztec-iOS
621622
- WordPress-Editor-iOS
622-
- WordPressKit
623623
- WordPressMocks
624624
- WordPressShared
625625
- WordPressUI
@@ -833,7 +833,7 @@ SPEC CHECKSUMS:
833833
WordPress-Aztec-iOS: 144f124148079084860368dfd27cb96e0952853e
834834
WordPress-Editor-iOS: 20551d5a5e51f29832064f08faaaae8e1da7e1e2
835835
WordPressAuthenticator: 0b3423546d92a976e3ce627d2e5a0350716b1f5b
836-
WordPressKit: 52329b519bd0da6533cd4c79070424d0672ed7ee
836+
WordPressKit: e623ffb39b2b9d7730a9be63e26fa77929e6e43b
837837
WordPressMocks: 6b52b0764d9939408151367dd9c6e8a910877f4d
838838
WordPressShared: a4b0308a6345d4dda20c8f7ad9317df4246b4a00
839839
WordPressUI: 45591178e843ecb82e65e868ec766148befe9f9f
@@ -849,6 +849,6 @@ SPEC CHECKSUMS:
849849
ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba
850850
ZIPFoundation: e27423c004a5a1410c15933407747374e7c6cb6e
851851

852-
PODFILE CHECKSUM: 5061295d7316fff43e35b70aa417d40afabb0789
852+
PODFILE CHECKSUM: 2198bf3dcf133317995199bc08b6af69a74ee863
853853

854854
COCOAPODS: 1.11.2

RELEASE-NOTES.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* [*] Signup: Fixed bug where username selection screen could be pushed twice. [#17624]
44
* [**] Threaded comments: comments can now be moderated via a drop-down menu on each comment. [#17758]
55
* [**] Reader post details Comments snippet: added ability to manage conversation subscription and notifications. [#17749]
6-
* [**] Accessibility: VoiceOver improvements on Activity Log and Schedule Post calendars [#17756, #17761]
6+
* [**] Accessibility: VoiceOver and Dynamic Type improvements on Activity Log and Schedule Post calendars [#17756, #17761, #17780]
77
* [*] Weekly Roundup: Fix a crash which was preventing weekly roundup notifications from appearing [#17765]
88
* [*] Self-hosted login: Improved error messages. [#17724]
99
* [*] Share Sheet from Photos: Fix an issue where certain filenames would not upload or render in Post [#16773]
@@ -17,6 +17,7 @@
1717
* [*] Block editor: Fix cut-off setting labels by properly wrapping the text [https://github.com/wordpress-mobile/gutenberg-mobile/pull/4475]
1818
* [*] Block editor: Highlight text: fix applying formatting for non-selected text [https://github.com/wordpress-mobile/gutenberg-mobile/pull/4471]
1919
* [**] Block editor: Fix Android handling of Hebrew and Indonesian translations [https://github.com/wordpress-mobile/gutenberg-mobile/pull/4397]
20+
* [***] Self-hosted sites: Fixed a crash when saving media and no Internet connection was available. [#17759]
2021

2122
19.0
2223
-----

WordPress/Classes/Models/Media.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,18 @@ - (BOOL)hasRemote {
261261
return self.mediaID.intValue != 0;
262262
}
263263

264+
- (void)setError:(NSError *)error
265+
{
266+
if (error != nil) {
267+
// Cherry pick keys that support secure coding. NSErrors thrown from the OS can
268+
// contain types that don't adopt NSSecureCoding, leading to a Core Data exception and crash.
269+
NSDictionary *userInfo = @{NSLocalizedDescriptionKey: error.localizedDescription};
270+
error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo];
271+
}
272+
273+
[self willChangeValueForKey:@"error"];
274+
[self setPrimitiveValue:error forKey:@"error"];
275+
[self didChangeValueForKey:@"error"];
276+
}
277+
264278
@end

WordPress/Classes/Services/MediaService.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ - (NSError *)customMediaUploadError:(NSError *)error remote:(id <MediaServiceRem
425425
case NSURLErrorNetworkConnectionLost:
426426
case NSURLErrorNotConnectedToInternet:
427427
// Clear lack of device internet connection, notify the user
428-
customErrorMessage = NSLocalizedString(@"The internet connection appears to be offline.", @"Error message shown when a media upload fails because the user isn't connected to the internet.");
428+
customErrorMessage = NSLocalizedString(@"The Internet connection appears to be offline.", @"Error message shown when a media upload fails because the user isn't connected to the Internet.");
429429
break;
430430
default:
431431
// Default NSURL error messaging, probably server-side, encourage user to try again
@@ -434,11 +434,13 @@ - (NSError *)customMediaUploadError:(NSError *)error remote:(id <MediaServiceRem
434434
}
435435
}
436436
}
437+
437438
if (customErrorMessage) {
438-
NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];
439+
NSMutableDictionary *userInfo = [error.userInfo mutableCopy];
439440
userInfo[NSLocalizedDescriptionKey] = customErrorMessage;
440-
error = [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:userInfo];
441+
error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo];
441442
}
443+
442444
return error;
443445
}
444446

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/BlogDashboardViewController.swift

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ import UIKit
22

33
final class BlogDashboardViewController: UIViewController {
44

5+
var blog: Blog?
6+
57
enum Section: CaseIterable {
68
case quickLinks
9+
case posts
710
}
811

912
// FIXME: temporary placeholder
1013
private let quickLinks = ["Quick Links"]
14+
private let posts = ["Posts"]
1115

1216
typealias DataSource = UICollectionViewDiffableDataSource<Section, String>
1317
typealias Snapshot = NSDiffableDataSourceSnapshot<Section, String>
@@ -20,22 +24,38 @@ final class BlogDashboardViewController: UIViewController {
2024
}()
2125

2226
private lazy var dataSource: DataSource = {
23-
return DataSource(collectionView: collectionView) { collectionView, indexPath, identifier in
24-
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: QuickLinksHostCell.defaultReuseID, for: indexPath) as? QuickLinksHostCell
25-
cell?.hostedView = QuickLinksView(title: self.quickLinks[indexPath.item])
26-
return cell
27+
return DataSource(collectionView: collectionView) { [unowned self] collectionView, indexPath, identifier in
28+
switch identifier {
29+
case self.quickLinks.first:
30+
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: QuickLinksHostCell.defaultReuseID, for: indexPath) as? QuickLinksHostCell
31+
cell?.hostedView = QuickLinksView(title: self.quickLinks[indexPath.item])
32+
return cell
33+
case self.posts.first:
34+
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: DashboardPostsCardCell.defaultReuseID, for: indexPath) as? DashboardPostsCardCell
35+
cell?.configure(self, blog: self.blog!)
36+
return cell
37+
default:
38+
break
39+
}
40+
return UICollectionViewCell()
2741
}
2842
}()
2943

44+
deinit {
45+
NotificationCenter.default.removeObserver(self)
46+
}
47+
3048
override func viewDidLoad() {
3149
super.viewDidLoad()
3250
setupCollectionView()
3351
applySnapshotForInitialData()
52+
addHeightObservers()
3453
}
3554

3655
private func setupCollectionView() {
3756
collectionView.backgroundColor = .listBackground
3857
collectionView.register(QuickLinksHostCell.self, forCellWithReuseIdentifier: QuickLinksHostCell.defaultReuseID)
58+
collectionView.register(DashboardPostsCardCell.self, forCellWithReuseIdentifier: DashboardPostsCardCell.defaultReuseID)
3959

4060
view.addSubview(collectionView)
4161
view.pinSubviewToAllEdges(collectionView)
@@ -45,8 +65,17 @@ final class BlogDashboardViewController: UIViewController {
4565
var snapshot = Snapshot()
4666
snapshot.appendSections(Section.allCases)
4767
snapshot.appendItems(quickLinks, toSection: Section.quickLinks)
68+
snapshot.appendItems(posts, toSection: Section.posts)
4869
dataSource.apply(snapshot, animatingDifferences: false)
4970
}
71+
72+
private func addHeightObservers() {
73+
NotificationCenter.default.addObserver(self, selector: #selector(self.updateCollectionViewHeight(notification:)), name: .postCardTableViewSizeChanged, object: nil)
74+
}
75+
76+
@objc private func updateCollectionViewHeight(notification: Notification) {
77+
collectionView.collectionViewLayout.invalidateLayout()
78+
}
5079
}
5180

5281
// MARK: - Collection view layout
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import UIKit
2+
3+
class DashboardPostsCardCell: UICollectionViewCell, Reusable {
4+
func configure(_ viewController: UIViewController, blog: Blog) {
5+
let postsViewController = PostsCardViewController(blog: blog)
6+
viewController.addChild(postsViewController)
7+
contentView.addSubview(postsViewController.view)
8+
postsViewController.view.translatesAutoresizingMaskIntoConstraints = false
9+
contentView.pinSubviewToAllEdges(postsViewController.view)
10+
postsViewController.didMove(toParent: viewController)
11+
}
12+
}

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Posts/PostsCardViewController.swift

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import UIKit
77
@objc class PostsCardViewController: UIViewController {
88
var blog: Blog
99

10-
let tableView: UITableView = IntrinsicTableView()
10+
let tableView: UITableView = PostCardTableView()
1111

1212
private var viewModel: PostsCardViewModel!
1313
private var ghostableTableView: UITableView?
@@ -125,3 +125,26 @@ extension PostsCardViewController: EditorAnalyticsProperties {
125125
return properties
126126
}
127127
}
128+
129+
// MARK: - PostCardTableView
130+
131+
extension NSNotification.Name {
132+
/// Fired when a PostCardTableView changes its size
133+
static let postCardTableViewSizeChanged = NSNotification.Name("IntrinsicContentSizeUpdated")
134+
}
135+
136+
private class PostCardTableView: UITableView {
137+
override var contentSize: CGSize {
138+
didSet {
139+
self.invalidateIntrinsicContentSize()
140+
}
141+
}
142+
143+
/// Emits a notification when the intrinsicContentSize changes
144+
/// This allows subscribers to update their layouts (ie.: UICollectionViews)
145+
override var intrinsicContentSize: CGSize {
146+
layoutIfNeeded()
147+
NotificationCenter.default.post(name: .postCardTableViewSizeChanged, object: nil)
148+
return CGSize(width: UIView.noIntrinsicMetric, height: contentSize.height)
149+
}
150+
}

WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController+Header.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import Gridicons
22
import WordPressFlux
33

44
extension BlogDetailsViewController {
5-
@objc func configureHeaderView() -> BlogDetailHeader {
5+
@objc func configureHeaderView() -> BlogDetailHeaderView {
66

77
let actionItems = createActionItems()
88

9-
return NewBlogDetailHeaderView(items: actionItems)
9+
return BlogDetailHeaderView(items: actionItems)
1010
}
1111

1212
@objc

WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ typedef NS_ENUM(NSUInteger, BlogDetailsNavigationSource) {
137137
@property (nonatomic, strong) id<ScenePresenter> _Nonnull meScenePresenter;
138138
@property (nonatomic, strong, readonly) CreateButtonCoordinator * _Nullable createButtonCoordinator;
139139
@property (nonatomic, strong, readwrite) UITableView * _Nonnull tableView;
140-
@property (nonatomic, strong, readonly) id<BlogDetailHeader> _Nonnull headerView;
140+
@property (nonatomic, strong, readonly) BlogDetailHeaderView * _Nonnull headerView;
141141
@property (nonatomic) BOOL shouldScrollToViewSite;
142142

143143
- (id _Nonnull)initWithMeScenePresenter:(id<ScenePresenter> _Nonnull)meScenePresenter;
@@ -157,4 +157,5 @@ typedef NS_ENUM(NSUInteger, BlogDetailsNavigationSource) {
157157
- (void)toggleSpotlightOnHeaderView;
158158
- (void)uploadDroppedSiteIcon:(nonnull UIImage *)image onCompletion:(nullable void(^)(void))completion;
159159
- (void)updateTableViewAndHeader;
160+
- (void)preloadMetadata;
160161
@end

0 commit comments

Comments
 (0)