mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Allow copying blocked user id (#6071)
This commit is contained in:
@@ -14,6 +14,7 @@ PRs must follow rules. Prefer Xcode MCP tools over terminal commands.
|
|||||||
- **SwiftLint** (.swiftlint.yml) + **SwiftFormat** (.swiftformat) enforce style on build. Warnings show in Xcode. Build before **XcodeRefreshCodeIssuesInFile**.
|
- **SwiftLint** (.swiftlint.yml) + **SwiftFormat** (.swiftformat) enforce style on build. Warnings show in Xcode. Build before **XcodeRefreshCodeIssuesInFile**.
|
||||||
- Follow [Swift API Design Guidelines](https://www.swift.org/documentation/api-design-guidelines/) everywhere, Rust SDK wrappers too (`ID` not `Id`, `URL` not `Url`, `configuration` not `config` or `cfg`).
|
- Follow [Swift API Design Guidelines](https://www.swift.org/documentation/api-design-guidelines/) everywhere, Rust SDK wrappers too (`ID` not `Id`, `URL` not `Url`, `configuration` not `config` or `cfg`).
|
||||||
- File headers live in `IDETemplateMacros.plist`.
|
- File headers live in `IDETemplateMacros.plist`.
|
||||||
|
- **Import `SwiftUI`, not `UIKit`** — need `UIPasteboard` etc, `SwiftUI` bring it. `SwiftUI` re-export `Foundation` too, so no `import Foundation` beside it.
|
||||||
|
|
||||||
### Comments
|
### Comments
|
||||||
|
|
||||||
@@ -52,6 +53,7 @@ PRs must follow rules. Prefer Xcode MCP tools over terminal commands.
|
|||||||
|
|
||||||
## Pull Request Guidelines
|
## Pull Request Guidelines
|
||||||
|
|
||||||
|
- New branch from `develop` must not track `develop`.
|
||||||
- Sentence-style titles (no conventional commits).
|
- Sentence-style titles (no conventional commits).
|
||||||
- Exactly one `pr-` label (see `.github/release.yml`).
|
- Exactly one `pr-` label (see `.github/release.yml`).
|
||||||
- Title = changelog entry — descriptive, no "Fixes #…".
|
- Title = changelog entry — descriptive, no "Fixes #…".
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ struct BlockedUsersScreenViewStateBindings {
|
|||||||
|
|
||||||
enum BlockedUsersScreenViewAction {
|
enum BlockedUsersScreenViewAction {
|
||||||
case unblockUser(UserProfile)
|
case unblockUser(UserProfile)
|
||||||
|
case copyUserID(UserProfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
enum BlockedUsersScreenViewStateAlertType: Hashable {
|
enum BlockedUsersScreenViewStateAlertType: Hashable {
|
||||||
|
|||||||
@@ -51,6 +51,12 @@ class BlockedUsersScreenViewModel: BlockedUsersScreenViewModelType, BlockedUsers
|
|||||||
self?.unblockUser(user)
|
self?.unblockUser(user)
|
||||||
},
|
},
|
||||||
secondaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil))
|
secondaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil))
|
||||||
|
case .copyUserID(let user):
|
||||||
|
UIPasteboard.general.string = user.id
|
||||||
|
userIndicatorController.submitIndicator(UserIndicator(id: Self.copiedIndicatorIdentifier,
|
||||||
|
type: .toast,
|
||||||
|
title: L10n.commonCopiedToClipboard,
|
||||||
|
icon: \.check))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,6 +114,7 @@ class BlockedUsersScreenViewModel: BlockedUsersScreenViewModelType, BlockedUsers
|
|||||||
// MARK: Loading indicator
|
// MARK: Loading indicator
|
||||||
|
|
||||||
private static let loadingIndicatorIdentifier = "\(BlockedUsersScreenViewModel.self)-Loading"
|
private static let loadingIndicatorIdentifier = "\(BlockedUsersScreenViewModel.self)-Loading"
|
||||||
|
private static let copiedIndicatorIdentifier = "\(BlockedUsersScreenViewModel.self)-Copied"
|
||||||
|
|
||||||
private func showLoadingIndicator() {
|
private func showLoadingIndicator() {
|
||||||
userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier,
|
userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier,
|
||||||
|
|||||||
@@ -38,6 +38,13 @@ struct BlockedUsersScreen: View {
|
|||||||
icon: avatar(for: user)),
|
icon: avatar(for: user)),
|
||||||
details: .isWaiting(context.viewState.processingUserID == user.id),
|
details: .isWaiting(context.viewState.processingUserID == user.id),
|
||||||
kind: .button { context.send(viewAction: .unblockUser(user)) })
|
kind: .button { context.send(viewAction: .unblockUser(user)) })
|
||||||
|
.contextMenu {
|
||||||
|
Button {
|
||||||
|
context.send(viewAction: .copyUserID(user))
|
||||||
|
} label: {
|
||||||
|
Label(L10n.actionCopy, icon: \.copy)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import Combine
|
import Combine
|
||||||
@testable import ElementX
|
@testable import ElementX
|
||||||
import Foundation
|
import SwiftUI
|
||||||
import Testing
|
import Testing
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
@@ -42,4 +42,22 @@ struct BlockedUsersScreenViewModelTests {
|
|||||||
#expect(!viewModel.context.viewState.blockedUsers.isEmpty)
|
#expect(!viewModel.context.viewState.blockedUsers.isEmpty)
|
||||||
#expect(clientProxy.profileForCalled)
|
#expect(clientProxy.profileForCalled)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
func copyUserID() throws {
|
||||||
|
let clientProxy = ClientProxyMock(.init(userID: RoomMemberProxyMock.mockMe.userID))
|
||||||
|
let userIndicatorController = UserIndicatorControllerMock()
|
||||||
|
|
||||||
|
let viewModel = BlockedUsersScreenViewModel(hideProfiles: true,
|
||||||
|
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||||
|
userIndicatorController: userIndicatorController)
|
||||||
|
|
||||||
|
let user = try #require(viewModel.context.viewState.blockedUsers.first)
|
||||||
|
UIPasteboard.general.string = ""
|
||||||
|
|
||||||
|
viewModel.context.send(viewAction: .copyUserID(user))
|
||||||
|
|
||||||
|
#expect(UIPasteboard.general.string == user.id)
|
||||||
|
#expect(userIndicatorController.submitIndicatorDelayReceivedArguments?.indicator.title == L10n.commonCopiedToClipboard)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user