From fb43b93c749a5b8bf325a59ae224a7197f89bbd8 Mon Sep 17 00:00:00 2001 From: kean Date: Fri, 26 Apr 2024 09:18:19 -0400 Subject: [PATCH] Rename PostMediaUploadsView --- WordPress/Classes/Models/Blog+Quota.swift | 3 +++ ...sView.swift => PostMediaUploadsView.swift} | 10 ++++---- ....swift => PostMediaUploadsViewModel.swift} | 8 +++---- .../PrepublishingViewController.swift | 6 ++--- WordPress/WordPress.xcodeproj/project.pbxproj | 24 +++++++++---------- 5 files changed, 27 insertions(+), 24 deletions(-) rename WordPress/Classes/ViewRelated/Post/{PostMediaUploadStatusView.swift => PostMediaUploadsView.swift} (93%) rename WordPress/Classes/ViewRelated/Post/{PostMediaUploadViewModel.swift => PostMediaUploadsViewModel.swift} (96%) diff --git a/WordPress/Classes/Models/Blog+Quota.swift b/WordPress/Classes/Models/Blog+Quota.swift index dcec2c9527d6..81be3765dcfe 100644 --- a/WordPress/Classes/Models/Blog+Quota.swift +++ b/WordPress/Classes/Models/Blog+Quota.swift @@ -56,6 +56,9 @@ extension Blog { /// Returns the maximum upload byte size supported for a media file on the site. @objc var maxUploadSize: NSNumber? { + #warning("TEMP") + return NSNumber(value: 1024 * 1024) + guard let maxUploadSize = getOptionValue("max_upload_size") as? NSNumber else { return nil } diff --git a/WordPress/Classes/ViewRelated/Post/PostMediaUploadStatusView.swift b/WordPress/Classes/ViewRelated/Post/PostMediaUploadsView.swift similarity index 93% rename from WordPress/Classes/ViewRelated/Post/PostMediaUploadStatusView.swift rename to WordPress/Classes/ViewRelated/Post/PostMediaUploadsView.swift index c819574334b8..0d53cca07541 100644 --- a/WordPress/Classes/ViewRelated/Post/PostMediaUploadStatusView.swift +++ b/WordPress/Classes/ViewRelated/Post/PostMediaUploadsView.swift @@ -2,8 +2,8 @@ import Foundation import SwiftUI /// Displays upload progress for the media for the given post. -struct PostMediaUploadStatusView: View { - @ObservedObject var viewModel: PostMediaUploadViewModel +struct PostMediaUploadsView: View { + @ObservedObject var viewModel: PostMediaUploadsViewModel var body: some View { contents @@ -30,7 +30,7 @@ struct PostMediaUploadStatusView: View { } else { List { ForEach(viewModel.uploads) { - MediaUploadStatusView(viewModel: $0) + PostMediaUploadItemView(viewModel: $0) } } .listStyle(.plain) @@ -38,8 +38,8 @@ struct PostMediaUploadStatusView: View { } } -private struct MediaUploadStatusView: View { - @ObservedObject var viewModel: MediaUploadViewModel +private struct PostMediaUploadItemView: View { + @ObservedObject var viewModel: PostMediaUploadItemViewModel var body: some View { HStack(alignment: .center, spacing: 16) { diff --git a/WordPress/Classes/ViewRelated/Post/PostMediaUploadViewModel.swift b/WordPress/Classes/ViewRelated/Post/PostMediaUploadsViewModel.swift similarity index 96% rename from WordPress/Classes/ViewRelated/Post/PostMediaUploadViewModel.swift rename to WordPress/Classes/ViewRelated/Post/PostMediaUploadsViewModel.swift index 7d7615c1bb41..5676c0a3c5ba 100644 --- a/WordPress/Classes/ViewRelated/Post/PostMediaUploadViewModel.swift +++ b/WordPress/Classes/ViewRelated/Post/PostMediaUploadsViewModel.swift @@ -3,8 +3,8 @@ import SwiftUI import Combine /// Manages media upload for the given revision of the post. -final class PostMediaUploadViewModel: ObservableObject { - private(set) var uploads: [MediaUploadViewModel] +final class PostMediaUploadsViewModel: ObservableObject { + private(set) var uploads: [PostMediaUploadItemViewModel] @Published private(set) var totalFileSize: Int64 = 0 @Published private(set) var fractionCompleted = 0.0 @@ -27,7 +27,7 @@ final class PostMediaUploadViewModel: ObservableObject { self.uploads = Array(post.media).filter(\.isUploadNeeded).sorted { ($0.creationDate ?? .now) < ($1.creationDate ?? .now) }.map { - MediaUploadViewModel(media: $0, coordinator: coordinator) + PostMediaUploadItemViewModel(media: $0, coordinator: coordinator) } coordinator.uploadMedia(for: post) @@ -68,7 +68,7 @@ final class PostMediaUploadViewModel: ObservableObject { } /// Manages individual media upload. -final class MediaUploadViewModel: ObservableObject, Identifiable { +final class PostMediaUploadItemViewModel: ObservableObject, Identifiable { @Published private(set) var state: State = .uploading private let media: Media diff --git a/WordPress/Classes/ViewRelated/Post/Prepublishing/PrepublishingViewController.swift b/WordPress/Classes/ViewRelated/Post/Prepublishing/PrepublishingViewController.swift index abb52f435374..4f4a1a37a0f9 100644 --- a/WordPress/Classes/ViewRelated/Post/Prepublishing/PrepublishingViewController.swift +++ b/WordPress/Classes/ViewRelated/Post/Prepublishing/PrepublishingViewController.swift @@ -43,7 +43,7 @@ final class PrepublishingViewController: UIViewController, UITableViewDataSource private weak var mediaPollingTimer: Timer? private let isStandalone: Bool - private let uploadsViewModel: PostMediaUploadViewModel + private let uploadsViewModel: PostMediaUploadsViewModel private var cancellables: [AnyCancellable] = [] @@ -58,7 +58,7 @@ final class PrepublishingViewController: UIViewController, UITableViewDataSource self.post = isStandalone ? post._createRevision() : post self.isStandalone = isStandalone self.viewModel = PrepublishingViewModel(post: self.post) - self.uploadsViewModel = PostMediaUploadViewModel(post: post) + self.uploadsViewModel = PostMediaUploadsViewModel(post: post) self.completion = completion self.coreDataStack = coreDataStack self.persistentStore = persistentStore @@ -450,7 +450,7 @@ final class PrepublishingViewController: UIViewController, UITableViewDataSource } private func buttonShowUploadInfoTapped() { - let view = PostMediaUploadStatusView(viewModel: uploadsViewModel) + let view = PostMediaUploadsView(viewModel: uploadsViewModel) let host = UIHostingController(rootView: view) navigationController?.pushViewController(host, animated: true) } diff --git a/WordPress/WordPress.xcodeproj/project.pbxproj b/WordPress/WordPress.xcodeproj/project.pbxproj index 6a6548d694f3..a40d7c96272a 100644 --- a/WordPress/WordPress.xcodeproj/project.pbxproj +++ b/WordPress/WordPress.xcodeproj/project.pbxproj @@ -581,10 +581,10 @@ 0CD9FB892AFA71C2009D9C7A /* DGCharts in Frameworks */ = {isa = PBXBuildFile; productRef = 0CD9FB882AFA71C2009D9C7A /* DGCharts */; }; 0CD9FB8B2AFADAFE009D9C7A /* SiteMediaPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CD9FB8A2AFADAFE009D9C7A /* SiteMediaPageViewController.swift */; }; 0CD9FB8C2AFADAFE009D9C7A /* SiteMediaPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CD9FB8A2AFADAFE009D9C7A /* SiteMediaPageViewController.swift */; }; - 0CDA09032BD022130032D123 /* PostMediaUploadStatusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CDA09022BD022130032D123 /* PostMediaUploadStatusView.swift */; }; - 0CDA09042BD022130032D123 /* PostMediaUploadStatusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CDA09022BD022130032D123 /* PostMediaUploadStatusView.swift */; }; - 0CDA090C2BD04B270032D123 /* PostMediaUploadViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CDA090B2BD04B270032D123 /* PostMediaUploadViewModel.swift */; }; - 0CDA090D2BD04B270032D123 /* PostMediaUploadViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CDA090B2BD04B270032D123 /* PostMediaUploadViewModel.swift */; }; + 0CDA09032BD022130032D123 /* PostMediaUploadsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CDA09022BD022130032D123 /* PostMediaUploadsView.swift */; }; + 0CDA09042BD022130032D123 /* PostMediaUploadsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CDA09022BD022130032D123 /* PostMediaUploadsView.swift */; }; + 0CDA090C2BD04B270032D123 /* PostMediaUploadsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CDA090B2BD04B270032D123 /* PostMediaUploadsViewModel.swift */; }; + 0CDA090D2BD04B270032D123 /* PostMediaUploadsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CDA090B2BD04B270032D123 /* PostMediaUploadsViewModel.swift */; }; 0CDEC40C2A2FAF0500BB3A91 /* DashboardBlazeCampaignsCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CDEC40B2A2FAF0500BB3A91 /* DashboardBlazeCampaignsCardView.swift */; }; 0CDEC40D2A2FAF0500BB3A91 /* DashboardBlazeCampaignsCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CDEC40B2A2FAF0500BB3A91 /* DashboardBlazeCampaignsCardView.swift */; }; 0CE538CA2B0D6E0000834BA2 /* ExternalMediaDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CE538C92B0D6E0000834BA2 /* ExternalMediaDataSource.swift */; }; @@ -6353,8 +6353,8 @@ 0CD9CCA22AD831590044A33C /* PostSearchViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostSearchViewModel.swift; sourceTree = ""; }; 0CD9FB7D2AF9C4DB009D9C7A /* UIBarButtonItem+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIBarButtonItem+Extensions.swift"; sourceTree = ""; }; 0CD9FB8A2AFADAFE009D9C7A /* SiteMediaPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteMediaPageViewController.swift; sourceTree = ""; }; - 0CDA09022BD022130032D123 /* PostMediaUploadStatusView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostMediaUploadStatusView.swift; sourceTree = ""; }; - 0CDA090B2BD04B270032D123 /* PostMediaUploadViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostMediaUploadViewModel.swift; sourceTree = ""; }; + 0CDA09022BD022130032D123 /* PostMediaUploadsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostMediaUploadsView.swift; sourceTree = ""; }; + 0CDA090B2BD04B270032D123 /* PostMediaUploadsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostMediaUploadsViewModel.swift; sourceTree = ""; }; 0CDEC40B2A2FAF0500BB3A91 /* DashboardBlazeCampaignsCardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardBlazeCampaignsCardView.swift; sourceTree = ""; }; 0CE538C92B0D6E0000834BA2 /* ExternalMediaDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalMediaDataSource.swift; sourceTree = ""; }; 0CE538CF2B0E317000834BA2 /* StockPhotosWelcomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StockPhotosWelcomeView.swift; sourceTree = ""; }; @@ -12906,8 +12906,8 @@ FA141F262AEC1D9E00C9A653 /* PageMenuViewModel.swift */, FAA5C90E2B7FC74C002E073B /* PostSyncStateViewModel.swift */, FACA34CD2BAACE3500163B21 /* ResolveConflictView.swift */, - 0CDA09022BD022130032D123 /* PostMediaUploadStatusView.swift */, - 0CDA090B2BD04B270032D123 /* PostMediaUploadViewModel.swift */, + 0CDA09022BD022130032D123 /* PostMediaUploadsView.swift */, + 0CDA090B2BD04B270032D123 /* PostMediaUploadsViewModel.swift */, ); name = Views; sourceTree = ""; @@ -22452,7 +22452,7 @@ B5EFB1C21B31B98E007608A3 /* NotificationSettingsService.swift in Sources */, 011896A829D5BBB400D34BA9 /* DomainsDashboardFactory.swift in Sources */, 011F52BD2A15327700B04114 /* BaseDashboardDomainsCardCell.swift in Sources */, - 0CDA090C2BD04B270032D123 /* PostMediaUploadViewModel.swift in Sources */, + 0CDA090C2BD04B270032D123 /* PostMediaUploadsViewModel.swift in Sources */, F45EB5012B865AF4004E9053 /* NotificationTableViewCell.swift in Sources */, 1717139F265FE59700F3A022 /* ButtonStyles.swift in Sources */, C3FF78E828354A91008FA600 /* SiteDesignSectionLoader.swift in Sources */, @@ -22601,7 +22601,7 @@ 8BDC4C39249BA5CA00DE0A2D /* ReaderCSS.swift in Sources */, 8352AC712B2A185A00F8492C /* ReaderNavigationButton.swift in Sources */, 80EF672527F3D63B0063B138 /* DashboardStatsStackView.swift in Sources */, - 0CDA09032BD022130032D123 /* PostMediaUploadStatusView.swift in Sources */, + 0CDA09032BD022130032D123 /* PostMediaUploadsView.swift in Sources */, E1D0D81616D3B86800E33F4C /* SafariActivity.m in Sources */, E603C7701BC94AED00AD49D7 /* WordPress-37-38.xcmappingmodel in Sources */, 808D102E2B881BE20082E64F /* String+Truncate.swift in Sources */, @@ -24716,7 +24716,7 @@ FABB21D52602FC2C00C8785C /* SiteDesignContentCollectionViewController.swift in Sources */, C31466CC2939950900D62FC7 /* MigrationLoadWordPressViewController.swift in Sources */, FABB21D62602FC2C00C8785C /* PlanComparisonViewController.swift in Sources */, - 0CDA09042BD022130032D123 /* PostMediaUploadStatusView.swift in Sources */, + 0CDA09042BD022130032D123 /* PostMediaUploadsView.swift in Sources */, FABB21D72602FC2C00C8785C /* Routes+Stats.swift in Sources */, 8BF1C81B27BC00AF00F1C203 /* BlogDashboardCardFrameView.swift in Sources */, FABB21D92602FC2C00C8785C /* SearchIdentifierGenerator.swift in Sources */, @@ -26046,7 +26046,7 @@ DC76668626FD9AC9009254DD /* TimeZoneTableViewCell.swift in Sources */, 01DC4CD92B5FC8CE000110E5 /* SiteStatsPeriodTableViewControllerDeprecated.swift in Sources */, FABB25862602FC2C00C8785C /* WordPress-11-12.xcmappingmodel in Sources */, - 0CDA090D2BD04B270032D123 /* PostMediaUploadViewModel.swift in Sources */, + 0CDA090D2BD04B270032D123 /* PostMediaUploadsViewModel.swift in Sources */, C3C21EBA28385EC8002296E2 /* RemoteSiteDesigns.swift in Sources */, FABB25872602FC2C00C8785C /* DiffAbstractValue.swift in Sources */, 9822A8422624CFB900FD8A03 /* UserProfileSiteCell.swift in Sources */,