Skip to content

Commit 8326351

Browse files
authored
Update to wprs v20251101 (#24967)
1 parent a398d49 commit 8326351

File tree

7 files changed

+22
-22
lines changed

7 files changed

+22
-22
lines changed

Modules/Package.resolved

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ let package = Package(
5454
.package(url: "https://github.com/zendesk/support_sdk_ios", from: "8.0.3"),
5555
// We can't use wordpress-rs branches nor commits here. Only tags work.
5656
.package(url: "https://github.com/wordpress-mobile/GutenbergKit", from: "0.9.0"),
57-
.package(url: "https://github.com/Automattic/wordpress-rs", revision: "alpha-20251007"),
57+
.package(url: "https://github.com/Automattic/wordpress-rs", revision: "alpha-20251101"),
5858
.package(
5959
url: "https://github.com/Automattic/color-studio",
6060
revision: "bf141adc75e2769eb469a3e095bdc93dc30be8de"

Modules/Sources/Support/InternalDataProvider.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ extension SupportDataProvider {
2121
static let botConversation = BotConversation(
2222
id: 1234,
2323
title: "App Crashing on Launch",
24-
mostRecentMessageDate: Date(),
2524
messages: [
2625
BotMessage(
2726
id: 1001,
@@ -85,7 +84,6 @@ extension SupportDataProvider {
8584
BotConversation(
8685
id: 5678,
8786
title: "App Crashing on Launch",
88-
mostRecentMessageDate: Date(),
8987
messages: botConversation.messages + [
9088
BotMessage(
9189
id: 1009,

Modules/Sources/Support/Model/BotConversation.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ import Foundation
33
public struct BotConversation: Identifiable, Codable, Sendable, Hashable {
44
public let id: UInt64
55
public let title: String
6-
public let mostRecentMesageDate: Date
76
public let userWantsHumanSupport: Bool
87
public let messages: [BotMessage]
98

10-
public init(id: UInt64, title: String, mostRecentMessageDate: Date, messages: [BotMessage]) {
9+
public init(id: UInt64, title: String, messages: [BotMessage]) {
1110
self.id = id
1211
self.title = title
13-
self.mostRecentMesageDate = mostRecentMessageDate
1412
self.messages = messages
1513
self.userWantsHumanSupport = messages.contains(where: { $0.userWantsToTalkToHuman })
1614
}
@@ -19,7 +17,6 @@ public struct BotConversation: Identifiable, Codable, Sendable, Hashable {
1917
BotConversation(
2018
id: self.id,
2119
title: self.title,
22-
mostRecentMessageDate: self.mostRecentMesageDate,
2320
messages: (self.messages + newMessages).sorted(by: { lhs, rhs in
2421
lhs.date < rhs.date
2522
})

WordPress/Classes/Services/MediaServiceRemoteCoreREST.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class MediaServiceRemoteCoreREST: NSObject, MediaServiceRemote {
3030
success: ((RemoteMedia?) -> Void)?,
3131
failure: (((any Error)?) -> Void)?
3232
) {
33-
guard let localURL = media.localURL else {
34-
wpAssertionFailure("local url missing in the media")
33+
guard let params = MediaCreateParams(media: media) else {
34+
wpAssertionFailure("Invalid Media Object (local url is likely missing)")
3535
failure?(URLError(.fileDoesNotExist))
3636
return
3737
}
@@ -51,7 +51,7 @@ class MediaServiceRemoteCoreREST: NSObject, MediaServiceRemote {
5151
.assign(to: \.completedUnitCount, on: mainThreadProgress)
5252
defer { cancellable.cancel() }
5353

54-
let media = try await client.api.uploadMedia(params: .init(media: media), fromLocalFileURL: localURL, fulfilling: progress).data
54+
let media = try await client.api.uploadMedia(params: params, fulfilling: progress).data
5555
success?(.init(media: media))
5656
} catch {
5757
failure?(error)
@@ -177,7 +177,13 @@ private extension RemoteMedia {
177177
}
178178

179179
private extension MediaCreateParams {
180-
init(media: RemoteMedia) {
180+
init?(media: RemoteMedia) {
181+
182+
guard let localURL = media.localURL else {
183+
wpAssertionFailure("local url missing in the media")
184+
return nil
185+
}
186+
181187
self.init(
182188
date: nil,
183189
dateGmt: media.date,
@@ -191,7 +197,8 @@ private extension MediaCreateParams {
191197
altText: media.alt,
192198
caption: media.caption,
193199
description: media.descriptionText,
194-
postId: media.postID?.int64Value
200+
postId: media.postID?.int64Value,
201+
filePath: localURL.path()
195202
)
196203
}
197204
}

WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsViewController+Swift.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ extension SiteSettingsViewController {
1313
@objc public func showPrivacySelector() {
1414
struct SiteSettingsPrivacyPicker: View {
1515
let blog: Blog
16-
@State var selection: SiteVisibility
17-
let onChange: (SiteVisibility) -> Void
16+
@State var selection: WordPress.SiteVisibility
17+
let onChange: (WordPress.SiteVisibility) -> Void
1818

1919
var body: some View {
20-
SettingsPickerListView(selection: $selection, values: SiteVisibility.eligiblePickerValues(for: blog))
20+
SettingsPickerListView(selection: $selection, values: WordPress.SiteVisibility.eligiblePickerValues(for: blog))
2121
.onChange(of: selection, perform: onChange)
2222
}
2323
}

WordPress/Classes/ViewRelated/NewSupport/SupportDataProvider.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ actor WpBotConversationDataProvider: BotConversationDataProvider {
155155
try await self.wpcomClient
156156
.api
157157
.supportBots
158-
.getBotConverationList(botId: self.botId)
158+
.getBotConversationList(botId: self.botId, params: ListBotConversationsParams())
159159
.data
160160
.map { $0.asSupportConversation() }
161161
}, cacheKey: "bot-conversation-list")
@@ -360,7 +360,7 @@ extension SupportUser {
360360

361361
extension WordPressAPIInternal.BotConversationSummary {
362362
func asSupportConversation() -> Support.BotConversation {
363-
var summary = self.lastMessage.content
363+
var summary = self.summaryMessage.content
364364

365365
if let preview = summary.components(separatedBy: .newlines).first?.prefix(64) {
366366
summary = String(preview)
@@ -369,7 +369,6 @@ extension WordPressAPIInternal.BotConversationSummary {
369369
return BotConversation(
370370
id: self.chatId,
371371
title: summary,
372-
mostRecentMessageDate: self.lastMessage.createdAt,
373372
messages: []
374373
)
375374
}
@@ -380,7 +379,6 @@ extension WordPressAPIInternal.BotConversation {
380379
BotConversation(
381380
id: self.chatId,
382381
title: self.messages.first?.content ?? "New Bot Chat",
383-
mostRecentMessageDate: self.messages.last?.createdAt ?? self.createdAt,
384382
messages: self.messages.map { $0.asSupportMessage() }
385383
)
386384
}

0 commit comments

Comments
 (0)