Skip to content

Commit

Permalink
Pin/Unpin Logic (#3084)
Browse files Browse the repository at this point in the history
  • Loading branch information
Velin92 authored Jul 26, 2024
1 parent 5a4d21a commit 0da2d49
Show file tree
Hide file tree
Showing 24 changed files with 659 additions and 69 deletions.
2 changes: 1 addition & 1 deletion ElementX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7501,7 +7501,7 @@
repositoryURL = "https://github.com/element-hq/matrix-rust-components-swift";
requirement = {
kind = exactVersion;
version = 1.0.28;
version = 1.0.29;
};
};
701C7BEF8F70F7A83E852DCC /* XCRemoteSwiftPackageReference "GZIP" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/element-hq/matrix-rust-components-swift",
"state" : {
"revision" : "1a1cbc9d9d43a188d9b07fe00a141d02f7c43c7c",
"version" : "1.0.28"
"revision" : "d0226f669526e908d45bf9b5682f372d84cf9ffe",
"version" : "1.0.29"
}
},
{
Expand Down
9 changes: 5 additions & 4 deletions ElementX/Resources/Localizations/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"action_ok" = "OK";
"action_open_settings" = "Settings";
"action_open_with" = "Open with";
"action_pin" = "Pin";
"action_quick_reply" = "Quick reply";
"action_quote" = "Quote";
"action_react" = "React";
Expand Down Expand Up @@ -99,10 +100,10 @@
"action_take_photo" = "Take photo";
"action_tap_for_options" = "Tap for options";
"action_try_again" = "Try again";
"action_unpin" = "Unpin";
"action_view_source" = "View source";
"action_yes" = "Yes";
"action.load_more" = "Load more";
"action.pin" = "Pin";
"common_about" = "About";
"common_acceptable_use_policy" = "Acceptable use policy";
"common_advanced_settings" = "Advanced settings";
Expand Down Expand Up @@ -313,9 +314,9 @@
"screen_advanced_settings_element_call_base_url_description" = "Set a custom base URL for Element Call.";
"screen_advanced_settings_element_call_base_url_validation_error" = "Invalid URL, please make sure you include the protocol (http/https) and the correct address.";
"screen_room_mentions_at_room_subtitle" = "Notify the whole room";
"screen.room.pinned_banner_indicator" = "%1$@ of %2$@";
"screen.room.pinned_banner_indicator_description" = "%1$@ Pinned messages";
"screen.room.pinned_banner_view_all_button_title" = "View All";
"screen_room_pinned_banner_indicator" = "%1$@ of %2$@";
"screen_room_pinned_banner_indicator_description" = "%1$@ Pinned messages";
"screen_room_pinned_banner_view_all_button_title" = "View All";
"screen_account_provider_change" = "Change account provider";
"screen_account_provider_form_hint" = "Homeserver address";
"screen_account_provider_form_notice" = "Enter a search term or a domain address.";
Expand Down
31 changes: 14 additions & 17 deletions ElementX/Sources/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ internal enum L10n {
internal static var actionOpenSettings: String { return L10n.tr("Localizable", "action_open_settings") }
/// Open with
internal static var actionOpenWith: String { return L10n.tr("Localizable", "action_open_with") }
/// Pin
internal static var actionPin: String { return L10n.tr("Localizable", "action_pin") }
/// Quick reply
internal static var actionQuickReply: String { return L10n.tr("Localizable", "action_quick_reply") }
/// Quote
Expand Down Expand Up @@ -232,6 +234,8 @@ internal enum L10n {
internal static var actionTapForOptions: String { return L10n.tr("Localizable", "action_tap_for_options") }
/// Try again
internal static var actionTryAgain: String { return L10n.tr("Localizable", "action_try_again") }
/// Unpin
internal static var actionUnpin: String { return L10n.tr("Localizable", "action_unpin") }
/// View source
internal static var actionViewSource: String { return L10n.tr("Localizable", "action_view_source") }
/// Yes
Expand Down Expand Up @@ -1629,6 +1633,16 @@ internal enum L10n {
internal static var screenRoomNotificationSettingsModeMentionsAndKeywords: String { return L10n.tr("Localizable", "screen_room_notification_settings_mode_mentions_and_keywords") }
/// In this room, notify me for
internal static var screenRoomNotificationSettingsRoomCustomSettingsTitle: String { return L10n.tr("Localizable", "screen_room_notification_settings_room_custom_settings_title") }
/// %1$@ of %2$@
internal static func screenRoomPinnedBannerIndicator(_ p1: Any, _ p2: Any) -> String {
return L10n.tr("Localizable", "screen_room_pinned_banner_indicator", String(describing: p1), String(describing: p2))
}
/// %1$@ Pinned messages
internal static func screenRoomPinnedBannerIndicatorDescription(_ p1: Any) -> String {
return L10n.tr("Localizable", "screen_room_pinned_banner_indicator_description", String(describing: p1))
}
/// View All
internal static var screenRoomPinnedBannerViewAllButtonTitle: String { return L10n.tr("Localizable", "screen_room_pinned_banner_view_all_button_title") }
/// Send again
internal static var screenRoomRetrySendMenuSendAgainAction: String { return L10n.tr("Localizable", "screen_room_retry_send_menu_send_again_action") }
/// Your message failed to send
Expand Down Expand Up @@ -2229,8 +2243,6 @@ internal enum L10n {
internal enum Action {
/// Load more
internal static var loadMore: String { return L10n.tr("Localizable", "action.load_more") }
/// Pin
internal static var pin: String { return L10n.tr("Localizable", "action.pin") }
}

internal enum Common {
Expand All @@ -2241,21 +2253,6 @@ internal enum L10n {
/// Send to
internal static var sendTo: String { return L10n.tr("Localizable", "common.send_to") }
}

internal enum Screen {
internal enum Room {
/// %1$@ of %2$@
internal static func pinnedBannerIndicator(_ p1: Any, _ p2: Any) -> String {
return L10n.tr("Localizable", "screen.room.pinned_banner_indicator", String(describing: p1), String(describing: p2))
}
/// %1$@ Pinned messages
internal static func pinnedBannerIndicatorDescription(_ p1: Any) -> String {
return L10n.tr("Localizable", "screen.room.pinned_banner_indicator_description", String(describing: p1))
}
/// View All
internal static var pinnedBannerViewAllButtonTitle: String { return L10n.tr("Localizable", "screen.room.pinned_banner_view_all_button_title") }
}
}
}
// swiftlint:enable explicit_type_interface function_parameter_count identifier_name line_length
// swiftlint:enable nesting type_body_length type_name vertical_whitespace_opening_braces
Expand Down
227 changes: 227 additions & 0 deletions ElementX/Sources/Mocks/Generated/GeneratedMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8251,6 +8251,23 @@ class RoomProxyMock: RoomProxyProtocol {
}
var underlyingIsFavourite: Bool!
var isFavouriteClosure: (() async -> Bool)?
var pinnedEventIDsCallsCount = 0
var pinnedEventIDsCalled: Bool {
return pinnedEventIDsCallsCount > 0
}

var pinnedEventIDs: [String] {
get async {
pinnedEventIDsCallsCount += 1
if let pinnedEventIDsClosure = pinnedEventIDsClosure {
return await pinnedEventIDsClosure()
} else {
return underlyingPinnedEventIDs
}
}
}
var underlyingPinnedEventIDs: [String]!
var pinnedEventIDsClosure: (() async -> [String])?
var membership: Membership {
get { return underlyingMembership }
set(value) { underlyingMembership = value }
Expand Down Expand Up @@ -10406,6 +10423,76 @@ class RoomProxyMock: RoomProxyProtocol {
return canUserTriggerRoomNotificationUserIDReturnValue
}
}
//MARK: - canUserPinOrUnpin

var canUserPinOrUnpinUserIDUnderlyingCallsCount = 0
var canUserPinOrUnpinUserIDCallsCount: Int {
get {
if Thread.isMainThread {
return canUserPinOrUnpinUserIDUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = canUserPinOrUnpinUserIDUnderlyingCallsCount
}

return returnValue!
}
}
set {
if Thread.isMainThread {
canUserPinOrUnpinUserIDUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
canUserPinOrUnpinUserIDUnderlyingCallsCount = newValue
}
}
}
}
var canUserPinOrUnpinUserIDCalled: Bool {
return canUserPinOrUnpinUserIDCallsCount > 0
}
var canUserPinOrUnpinUserIDReceivedUserID: String?
var canUserPinOrUnpinUserIDReceivedInvocations: [String] = []

var canUserPinOrUnpinUserIDUnderlyingReturnValue: Result<Bool, RoomProxyError>!
var canUserPinOrUnpinUserIDReturnValue: Result<Bool, RoomProxyError>! {
get {
if Thread.isMainThread {
return canUserPinOrUnpinUserIDUnderlyingReturnValue
} else {
var returnValue: Result<Bool, RoomProxyError>? = nil
DispatchQueue.main.sync {
returnValue = canUserPinOrUnpinUserIDUnderlyingReturnValue
}

return returnValue!
}
}
set {
if Thread.isMainThread {
canUserPinOrUnpinUserIDUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
canUserPinOrUnpinUserIDUnderlyingReturnValue = newValue
}
}
}
}
var canUserPinOrUnpinUserIDClosure: ((String) async -> Result<Bool, RoomProxyError>)?

func canUserPinOrUnpin(userID: String) async -> Result<Bool, RoomProxyError> {
canUserPinOrUnpinUserIDCallsCount += 1
canUserPinOrUnpinUserIDReceivedUserID = userID
DispatchQueue.main.async {
self.canUserPinOrUnpinUserIDReceivedInvocations.append(userID)
}
if let canUserPinOrUnpinUserIDClosure = canUserPinOrUnpinUserIDClosure {
return await canUserPinOrUnpinUserIDClosure(userID)
} else {
return canUserPinOrUnpinUserIDReturnValue
}
}
//MARK: - kickUser

var kickUserUnderlyingCallsCount = 0
Expand Down Expand Up @@ -12527,6 +12614,146 @@ class TimelineProxyMock: TimelineProxyProtocol {
return redactReasonReturnValue
}
}
//MARK: - pin

var pinEventIDUnderlyingCallsCount = 0
var pinEventIDCallsCount: Int {
get {
if Thread.isMainThread {
return pinEventIDUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = pinEventIDUnderlyingCallsCount
}

return returnValue!
}
}
set {
if Thread.isMainThread {
pinEventIDUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
pinEventIDUnderlyingCallsCount = newValue
}
}
}
}
var pinEventIDCalled: Bool {
return pinEventIDCallsCount > 0
}
var pinEventIDReceivedEventID: String?
var pinEventIDReceivedInvocations: [String] = []

var pinEventIDUnderlyingReturnValue: Result<Bool, TimelineProxyError>!
var pinEventIDReturnValue: Result<Bool, TimelineProxyError>! {
get {
if Thread.isMainThread {
return pinEventIDUnderlyingReturnValue
} else {
var returnValue: Result<Bool, TimelineProxyError>? = nil
DispatchQueue.main.sync {
returnValue = pinEventIDUnderlyingReturnValue
}

return returnValue!
}
}
set {
if Thread.isMainThread {
pinEventIDUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
pinEventIDUnderlyingReturnValue = newValue
}
}
}
}
var pinEventIDClosure: ((String) async -> Result<Bool, TimelineProxyError>)?

func pin(eventID: String) async -> Result<Bool, TimelineProxyError> {
pinEventIDCallsCount += 1
pinEventIDReceivedEventID = eventID
DispatchQueue.main.async {
self.pinEventIDReceivedInvocations.append(eventID)
}
if let pinEventIDClosure = pinEventIDClosure {
return await pinEventIDClosure(eventID)
} else {
return pinEventIDReturnValue
}
}
//MARK: - unpin

var unpinEventIDUnderlyingCallsCount = 0
var unpinEventIDCallsCount: Int {
get {
if Thread.isMainThread {
return unpinEventIDUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = unpinEventIDUnderlyingCallsCount
}

return returnValue!
}
}
set {
if Thread.isMainThread {
unpinEventIDUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
unpinEventIDUnderlyingCallsCount = newValue
}
}
}
}
var unpinEventIDCalled: Bool {
return unpinEventIDCallsCount > 0
}
var unpinEventIDReceivedEventID: String?
var unpinEventIDReceivedInvocations: [String] = []

var unpinEventIDUnderlyingReturnValue: Result<Bool, TimelineProxyError>!
var unpinEventIDReturnValue: Result<Bool, TimelineProxyError>! {
get {
if Thread.isMainThread {
return unpinEventIDUnderlyingReturnValue
} else {
var returnValue: Result<Bool, TimelineProxyError>? = nil
DispatchQueue.main.sync {
returnValue = unpinEventIDUnderlyingReturnValue
}

return returnValue!
}
}
set {
if Thread.isMainThread {
unpinEventIDUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
unpinEventIDUnderlyingReturnValue = newValue
}
}
}
}
var unpinEventIDClosure: ((String) async -> Result<Bool, TimelineProxyError>)?

func unpin(eventID: String) async -> Result<Bool, TimelineProxyError> {
unpinEventIDCallsCount += 1
unpinEventIDReceivedEventID = eventID
DispatchQueue.main.async {
self.unpinEventIDReceivedInvocations.append(eventID)
}
if let unpinEventIDClosure = unpinEventIDClosure {
return await unpinEventIDClosure(eventID)
} else {
return unpinEventIDReturnValue
}
}
//MARK: - sendAudio

var sendAudioUrlAudioInfoProgressSubjectRequestHandleUnderlyingCallsCount = 0
Expand Down
Loading

0 comments on commit 0da2d49

Please sign in to comment.