Skip to content

Commit

Permalink
struct has been renamed on the sdk
Browse files Browse the repository at this point in the history
so I renamed it also on the app side
  • Loading branch information
Velin92 committed Dec 13, 2024
1 parent 48cbf77 commit 58000f3
Show file tree
Hide file tree
Showing 26 changed files with 696 additions and 696 deletions.
1,068 changes: 534 additions & 534 deletions ElementX/Sources/Mocks/Generated/GeneratedMocks.swift

Large diffs are not rendered by default.

56 changes: 28 additions & 28 deletions ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7938,7 +7938,7 @@ open class InReplyToDetailsSDKMock: MatrixRustSDK.InReplyToDetails {
}
}
}
open class JoinRequestActionsSDKMock: MatrixRustSDK.JoinRequestActions {
open class KnockRequestActionsSDKMock: MatrixRustSDK.KnockRequestActions {
init() {
super.init(noPointer: .init())
}
Expand Down Expand Up @@ -14201,78 +14201,78 @@ open class RoomSDKMock: MatrixRustSDK.Room {
}
}

//MARK: - subscribeToJoinRequests
//MARK: - subscribeToKnockRequests

open var subscribeToJoinRequestsListenerThrowableError: Error?
var subscribeToJoinRequestsListenerUnderlyingCallsCount = 0
open var subscribeToJoinRequestsListenerCallsCount: Int {
open var subscribeToKnockRequestsListenerThrowableError: Error?
var subscribeToKnockRequestsListenerUnderlyingCallsCount = 0
open var subscribeToKnockRequestsListenerCallsCount: Int {
get {
if Thread.isMainThread {
return subscribeToJoinRequestsListenerUnderlyingCallsCount
return subscribeToKnockRequestsListenerUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = subscribeToJoinRequestsListenerUnderlyingCallsCount
returnValue = subscribeToKnockRequestsListenerUnderlyingCallsCount
}

return returnValue!
}
}
set {
if Thread.isMainThread {
subscribeToJoinRequestsListenerUnderlyingCallsCount = newValue
subscribeToKnockRequestsListenerUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
subscribeToJoinRequestsListenerUnderlyingCallsCount = newValue
subscribeToKnockRequestsListenerUnderlyingCallsCount = newValue
}
}
}
}
open var subscribeToJoinRequestsListenerCalled: Bool {
return subscribeToJoinRequestsListenerCallsCount > 0
open var subscribeToKnockRequestsListenerCalled: Bool {
return subscribeToKnockRequestsListenerCallsCount > 0
}
open var subscribeToJoinRequestsListenerReceivedListener: JoinRequestsListener?
open var subscribeToJoinRequestsListenerReceivedInvocations: [JoinRequestsListener] = []
open var subscribeToKnockRequestsListenerReceivedListener: KnockRequestsListener?
open var subscribeToKnockRequestsListenerReceivedInvocations: [KnockRequestsListener] = []

var subscribeToJoinRequestsListenerUnderlyingReturnValue: TaskHandle!
open var subscribeToJoinRequestsListenerReturnValue: TaskHandle! {
var subscribeToKnockRequestsListenerUnderlyingReturnValue: TaskHandle!
open var subscribeToKnockRequestsListenerReturnValue: TaskHandle! {
get {
if Thread.isMainThread {
return subscribeToJoinRequestsListenerUnderlyingReturnValue
return subscribeToKnockRequestsListenerUnderlyingReturnValue
} else {
var returnValue: TaskHandle? = nil
DispatchQueue.main.sync {
returnValue = subscribeToJoinRequestsListenerUnderlyingReturnValue
returnValue = subscribeToKnockRequestsListenerUnderlyingReturnValue
}

return returnValue!
}
}
set {
if Thread.isMainThread {
subscribeToJoinRequestsListenerUnderlyingReturnValue = newValue
subscribeToKnockRequestsListenerUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
subscribeToJoinRequestsListenerUnderlyingReturnValue = newValue
subscribeToKnockRequestsListenerUnderlyingReturnValue = newValue
}
}
}
}
open var subscribeToJoinRequestsListenerClosure: ((JoinRequestsListener) async throws -> TaskHandle)?
open var subscribeToKnockRequestsListenerClosure: ((KnockRequestsListener) async throws -> TaskHandle)?

open override func subscribeToJoinRequests(listener: JoinRequestsListener) async throws -> TaskHandle {
if let error = subscribeToJoinRequestsListenerThrowableError {
open override func subscribeToKnockRequests(listener: KnockRequestsListener) async throws -> TaskHandle {
if let error = subscribeToKnockRequestsListenerThrowableError {
throw error
}
subscribeToJoinRequestsListenerCallsCount += 1
subscribeToJoinRequestsListenerReceivedListener = listener
subscribeToKnockRequestsListenerCallsCount += 1
subscribeToKnockRequestsListenerReceivedListener = listener
DispatchQueue.main.async {
self.subscribeToJoinRequestsListenerReceivedInvocations.append(listener)
self.subscribeToKnockRequestsListenerReceivedInvocations.append(listener)
}
if let subscribeToJoinRequestsListenerClosure = subscribeToJoinRequestsListenerClosure {
return try await subscribeToJoinRequestsListenerClosure(listener)
if let subscribeToKnockRequestsListenerClosure = subscribeToKnockRequestsListenerClosure {
return try await subscribeToKnockRequestsListenerClosure(listener)
} else {
return subscribeToJoinRequestsListenerReturnValue
return subscribeToKnockRequestsListenerReturnValue
}
}

Expand Down
4 changes: 2 additions & 2 deletions ElementX/Sources/Mocks/JoinedRoomProxyMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct JoinedRoomProxyMockConfiguration {
var timelineStartReached = false

var members: [RoomMemberProxyMock] = .allMembers
var joinRequestsState: JoinRequestsState = .loaded([])
var knockRequestsState: KnockRequestsState = .loaded([])
var ownUserID = RoomMemberProxyMock.mockMe.userID
var inviter: RoomMemberProxyProtocol?

Expand Down Expand Up @@ -58,7 +58,7 @@ extension JoinedRoomProxyMock {

infoPublisher = CurrentValueSubject(.init(roomInfo: .init(configuration))).asCurrentValuePublisher()
membersPublisher = CurrentValueSubject(configuration.members).asCurrentValuePublisher()
joinRequestsStatePublisher = CurrentValueSubject(configuration.joinRequestsState).asCurrentValuePublisher()
knockRequestsStatePublisher = CurrentValueSubject(configuration.knockRequestsState).asCurrentValuePublisher()
typingMembersPublisher = CurrentValueSubject([]).asCurrentValuePublisher()
identityStatusChangesPublisher = CurrentValueSubject([]).asCurrentValuePublisher()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

struct JoinRequestProxyMockConfiguration {
struct KnockRequestProxyMockConfiguration {
let eventID: String
let userID: String
var displayName: String?
Expand All @@ -17,8 +17,8 @@ struct JoinRequestProxyMockConfiguration {
var isSeen = false
}

extension JoinRequestProxyMock {
convenience init(_ configuration: JoinRequestProxyMockConfiguration) {
extension KnockRequestProxyMock {
convenience init(_ configuration: KnockRequestProxyMockConfiguration) {
self.init()
eventID = configuration.eventID
userID = configuration.userID
Expand Down
18 changes: 9 additions & 9 deletions ElementX/Sources/Mocks/RoomSummaryProviderMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ extension Array where Element == RoomSummary {
static let mockRooms: [Element] = [
RoomSummary(roomListItem: RoomListItemSDKMock(),
id: "1",
joinRequestType: nil,
knockRequestType: nil,
name: "Foundation 🔭🪐🌌",
isDirect: false,
avatarURL: nil,
Expand All @@ -88,7 +88,7 @@ extension Array where Element == RoomSummary {
isFavourite: false),
RoomSummary(roomListItem: RoomListItemSDKMock(),
id: "2",
joinRequestType: nil,
knockRequestType: nil,
name: "Foundation and Empire",
isDirect: false,
avatarURL: .mockMXCAvatar,
Expand All @@ -105,7 +105,7 @@ extension Array where Element == RoomSummary {
isFavourite: false),
RoomSummary(roomListItem: RoomListItemSDKMock(),
id: "3",
joinRequestType: nil,
knockRequestType: nil,
name: "Second Foundation",
isDirect: false,
avatarURL: nil,
Expand All @@ -122,7 +122,7 @@ extension Array where Element == RoomSummary {
isFavourite: false),
RoomSummary(roomListItem: RoomListItemSDKMock(),
id: "4",
joinRequestType: nil,
knockRequestType: nil,
name: "Foundation's Edge",
isDirect: false,
avatarURL: nil,
Expand All @@ -139,7 +139,7 @@ extension Array where Element == RoomSummary {
isFavourite: false),
RoomSummary(roomListItem: RoomListItemSDKMock(),
id: "5",
joinRequestType: nil,
knockRequestType: nil,
name: "Foundation and Earth",
isDirect: true,
avatarURL: nil,
Expand All @@ -156,7 +156,7 @@ extension Array where Element == RoomSummary {
isFavourite: false),
RoomSummary(roomListItem: RoomListItemSDKMock(),
id: "6",
joinRequestType: nil,
knockRequestType: nil,
name: "Prelude to Foundation",
isDirect: true,
avatarURL: nil,
Expand All @@ -173,7 +173,7 @@ extension Array where Element == RoomSummary {
isFavourite: false),
RoomSummary(roomListItem: RoomListItemSDKMock(),
id: "0",
joinRequestType: nil,
knockRequestType: nil,
name: "Unknown",
isDirect: false,
avatarURL: nil,
Expand Down Expand Up @@ -223,7 +223,7 @@ extension Array where Element == RoomSummary {
static let mockInvites: [Element] = [
RoomSummary(roomListItem: RoomListItemSDKMock(),
id: "someAwesomeRoomId1",
joinRequestType: .invite(inviter: RoomMemberProxyMock.mockCharlie),
knockRequestType: .invite(inviter: RoomMemberProxyMock.mockCharlie),
name: "First room",
isDirect: false,
avatarURL: .mockMXCAvatar,
Expand All @@ -240,7 +240,7 @@ extension Array where Element == RoomSummary {
isFavourite: false),
RoomSummary(roomListItem: RoomListItemSDKMock(),
id: "someAwesomeRoomId2",
joinRequestType: .invite(inviter: RoomMemberProxyMock.mockCharlie),
knockRequestType: .invite(inviter: RoomMemberProxyMock.mockCharlie),
name: "Second room",
isDirect: true,
avatarURL: nil,
Expand Down
6 changes: 3 additions & 3 deletions ElementX/Sources/Screens/HomeScreen/HomeScreenModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,13 @@ extension HomeScreenRoom {

let hasUnreadMessages = hideUnreadMessagesBadge ? false : summary.hasUnreadMessages

let isDotShown = hasUnreadMessages || summary.hasUnreadMentions || summary.hasUnreadNotifications || summary.isMarkedUnread || summary.joinRequestType?.isKnock == true
let isDotShown = hasUnreadMessages || summary.hasUnreadMentions || summary.hasUnreadNotifications || summary.isMarkedUnread || summary.knockRequestType?.isKnock == true
let isMentionShown = summary.hasUnreadMentions && !summary.isMuted
let isMuteShown = summary.isMuted
let isCallShown = summary.hasOngoingCall
let isHighlighted = summary.isMarkedUnread || (!summary.isMuted && (summary.hasUnreadNotifications || summary.hasUnreadMentions)) || summary.joinRequestType?.isKnock == true
let isHighlighted = summary.isMarkedUnread || (!summary.isMuted && (summary.hasUnreadNotifications || summary.hasUnreadMentions)) || summary.knockRequestType?.isKnock == true

let type: HomeScreenRoom.RoomType = switch summary.joinRequestType {
let type: HomeScreenRoom.RoomType = switch summary.knockRequestType {
case .invite(let inviter): .invite(inviterDetails: inviter.map(RoomInviterDetails.init))
case .knock: .knock
case .none: .room
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private extension HomeScreenRoom {

let summary = RoomSummary(roomListItem: RoomListItemSDKMock(),
id: "@someone:somewhere.com",
joinRequestType: .invite(inviter: inviter),
knockRequestType: .invite(inviter: inviter),
name: "Some Guy",
isDirect: true,
avatarURL: nil,
Expand All @@ -205,7 +205,7 @@ private extension HomeScreenRoom {

let summary = RoomSummary(roomListItem: RoomListItemSDKMock(),
id: "@someone:somewhere.com",
joinRequestType: .invite(inviter: inviter),
knockRequestType: .invite(inviter: inviter),
name: "Awesome Room",
isDirect: false,
avatarURL: avatarURL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private extension HomeScreenRoom {

let summary = RoomSummary(roomListItem: RoomListItemSDKMock(),
id: "@someone:somewhere.com",
joinRequestType: .invite(inviter: inviter),
knockRequestType: .invite(inviter: inviter),
name: "Some Guy",
isDirect: true,
avatarURL: nil,
Expand All @@ -179,7 +179,7 @@ private extension HomeScreenRoom {

let summary = RoomSummary(roomListItem: RoomListItemSDKMock(),
id: "@someone:somewhere.com",
joinRequestType: .invite(inviter: inviter),
knockRequestType: .invite(inviter: inviter),
name: "Awesome Room",
isDirect: false,
avatarURL: avatarURL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
enum KnockRequestsListScreenViewModelAction { }

struct KnockRequestsListScreenViewState: BindableState {
var requestsState: KnockRequestsState = .loading
var requestsState: KnockRequestsListState = .loading

var displayedRequests: [KnockRequestCellInfo] {
guard case let .loaded(requests) = requestsState else {
Expand Down Expand Up @@ -72,11 +72,11 @@ enum KnockRequestsListScreenViewAction {
case ban(eventID: String)
}

enum KnockRequestsState: Equatable {
enum KnockRequestsListState: Equatable {
case loading
case loaded([KnockRequestCellInfo])

init(from state: JoinRequestsState) {
init(from state: KnockRequestsState) {
switch state {
case .loading:
self = .loading
Expand All @@ -87,7 +87,7 @@ enum KnockRequestsState: Equatable {
}

private extension KnockRequestCellInfo {
init(from proxy: JoinRequestProxyProtocol) {
init(from proxy: KnockRequestProxyProtocol) {
self.init(eventID: proxy.eventID,
userID: proxy.userID,
displayName: proxy.displayName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ class KnockRequestsListScreenViewModel: KnockRequestsListScreenViewModelType, Kn

// MARK: - Private

private func getRequest(eventID: String) -> JoinRequestProxyProtocol? {
guard case let .loaded(requests) = roomProxy.joinRequestsStatePublisher.value,
private func getRequest(eventID: String) -> KnockRequestProxyProtocol? {
guard case let .loaded(requests) = roomProxy.knockRequestsStatePublisher.value,
let request = requests.first(where: { $0.eventID == eventID }) else {
return nil
}
return request
}

private func accept(request: JoinRequestProxyProtocol) {
private func accept(request: KnockRequestProxyProtocol) {
showLoadingIndicator(title: L10n.screenKnockRequestsListAcceptLoadingTitle)

let eventID = request.eventID
Expand All @@ -106,7 +106,7 @@ class KnockRequestsListScreenViewModel: KnockRequestsListScreenViewModelType, Kn
}
}

private func decline(request: JoinRequestProxyProtocol) {
private func decline(request: KnockRequestProxyProtocol) {
showLoadingIndicator(title: L10n.screenKnockRequestsListDeclineLoadingTitle)

let eventID = request.eventID
Expand All @@ -128,7 +128,7 @@ class KnockRequestsListScreenViewModel: KnockRequestsListScreenViewModelType, Kn
}
}

private func declineAndBan(request: JoinRequestProxyProtocol) {
private func declineAndBan(request: KnockRequestProxyProtocol) {
showLoadingIndicator(title: L10n.screenKnockRequestsListBanLoadingTitle)

let eventID = request.eventID
Expand All @@ -151,14 +151,14 @@ class KnockRequestsListScreenViewModel: KnockRequestsListScreenViewModelType, Kn
}

private func acceptAll() {
guard case let .loaded(requests) = roomProxy.joinRequestsStatePublisher.value else {
guard case let .loaded(requests) = roomProxy.knockRequestsStatePublisher.value else {
return
}
showLoadingIndicator(title: L10n.screenKnockRequestsListAcceptAllLoadingTitle)
state.handledEventIDs.formUnion(Set(requests.map(\.eventID)))

Task {
let failedIDs = await withTaskGroup(of: (String, Result<Void, JoinRequestProxyError>).self) { group in
let failedIDs = await withTaskGroup(of: (String, Result<Void, KnockRequestProxyError>).self) { group in
for request in requests {
group.addTask {
await (request.eventID, request.accept())
Expand Down Expand Up @@ -193,8 +193,8 @@ class KnockRequestsListScreenViewModel: KnockRequestsListScreenViewModelType, Kn
}
.store(in: &cancellables)

roomProxy.joinRequestsStatePublisher
.map(KnockRequestsState.init)
roomProxy.knockRequestsStatePublisher
.map(KnockRequestsListState.init)
.removeDuplicates()
.throttle(for: .milliseconds(100), scheduler: DispatchQueue.main, latest: true)
.weakAssign(to: \.state.requestsState, on: self)
Expand Down
Loading

0 comments on commit 58000f3

Please sign in to comment.