mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Re-enable unit tests and fix a few lint warnings
This commit is contained in:
parent
1e98305012
commit
46f191c33b
6 changed files with 23 additions and 24 deletions
|
@ -65,7 +65,7 @@ extension MockCompletionSuggestionScreenState: CommandsProviderProtocol {
|
||||||
func fetchCommands(_ commands: @escaping ([CommandsProviderCommand]) -> Void) {
|
func fetchCommands(_ commands: @escaping ([CommandsProviderCommand]) -> Void) {
|
||||||
commands([
|
commands([
|
||||||
CommandsProviderCommand(name: "/ban",
|
CommandsProviderCommand(name: "/ban",
|
||||||
parametersFormat: "<user-id> [reason]",
|
parametersFormat: "<user-id> [<reason>]",
|
||||||
description: "Bans user with given id"),
|
description: "Bans user with given id"),
|
||||||
CommandsProviderCommand(name: "/invite",
|
CommandsProviderCommand(name: "/invite",
|
||||||
parametersFormat: "<user-id>",
|
parametersFormat: "<user-id>",
|
||||||
|
|
|
@ -29,7 +29,7 @@ class CompletionSuggestionViewModel: CompletionSuggestionViewModelType, Completi
|
||||||
// MARK: Public
|
// MARK: Public
|
||||||
|
|
||||||
var sharedContext: CompletionSuggestionViewModelType.Context {
|
var sharedContext: CompletionSuggestionViewModelType.Context {
|
||||||
return self.context
|
context
|
||||||
}
|
}
|
||||||
|
|
||||||
var completion: ((CompletionSuggestionViewModelResult) -> Void)?
|
var completion: ((CompletionSuggestionViewModelResult) -> Void)?
|
||||||
|
|
|
@ -103,8 +103,7 @@ final class CompletionSuggestionCoordinator: Coordinator, Presentable {
|
||||||
|
|
||||||
completionSuggestionService.items.sink { [weak self] _ in
|
completionSuggestionService.items.sink { [weak self] _ in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
self.delegate?.completionSuggestionCoordinator(self,
|
self.delegate?.completionSuggestionCoordinator(self, didUpdateViewHeight: self.calculateViewHeight())
|
||||||
didUpdateViewHeight: self.calculateViewHeight())
|
|
||||||
}.store(in: &cancellables)
|
}.store(in: &cancellables)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,11 +232,7 @@ private class CompletionSuggestionCoordinatorCommandProvider: CommandsProviderPr
|
||||||
}
|
}
|
||||||
|
|
||||||
func fetchCommands(_ commands: @escaping ([CommandsProviderCommand]) -> Void) {
|
func fetchCommands(_ commands: @escaping ([CommandsProviderCommand]) -> Void) {
|
||||||
commands(self.commands.map { CommandsProviderCommand(
|
commands(self.commands.map { CommandsProviderCommand(name: $0.cmd, parametersFormat: $0.parametersFormat, description: $0.description) })
|
||||||
name: $0.cmd,
|
|
||||||
parametersFormat: $0.parametersFormat,
|
|
||||||
description: $0.description
|
|
||||||
)})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -200,14 +200,14 @@ private struct TextTrigger: Equatable {
|
||||||
let text: String
|
let text: String
|
||||||
|
|
||||||
func asString() -> String {
|
func asString() -> String {
|
||||||
return String(key.rawValue) + text
|
String(key.rawValue) + text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private extension String {
|
private extension String {
|
||||||
// Returns current completion suggestion for a text message, if any.
|
// Returns current completion suggestion for a text message, if any.
|
||||||
var currentTextTrigger: TextTrigger? {
|
var currentTextTrigger: TextTrigger? {
|
||||||
let components = self.components(separatedBy: .whitespaces)
|
let components = components(separatedBy: .whitespaces)
|
||||||
guard var lastComponent = components.last,
|
guard var lastComponent = components.last,
|
||||||
lastComponent.count > 0,
|
lastComponent.count > 0,
|
||||||
let suggestionKey = SuggestionKey(rawValue: lastComponent.removeFirst()),
|
let suggestionKey = SuggestionKey(rawValue: lastComponent.removeFirst()),
|
||||||
|
|
|
@ -143,11 +143,20 @@ extension CompletionSuggestionServiceTests: RoomMembersProviderProtocol {
|
||||||
|
|
||||||
extension CompletionSuggestionServiceTests: CommandsProviderProtocol {
|
extension CompletionSuggestionServiceTests: CommandsProviderProtocol {
|
||||||
func fetchCommands(_ commands: @escaping ([CommandsProviderCommand]) -> Void) {
|
func fetchCommands(_ commands: @escaping ([CommandsProviderCommand]) -> Void) {
|
||||||
let commandList = ["/ban", "/invite", "/join", "/me"]
|
commands([
|
||||||
|
CommandsProviderCommand(name: "/ban",
|
||||||
commands(commandList.map { command in
|
parametersFormat: "<user-id> [<reason>]",
|
||||||
CommandsProviderCommand(name: command)
|
description: "Bans user with given id"),
|
||||||
})
|
CommandsProviderCommand(name: "/invite",
|
||||||
|
parametersFormat: "<user-id>",
|
||||||
|
description: "Invites user with given id to current room"),
|
||||||
|
CommandsProviderCommand(name: "/join",
|
||||||
|
parametersFormat: "<room-address>",
|
||||||
|
description: "Joins room with given address"),
|
||||||
|
CommandsProviderCommand(name: "/me",
|
||||||
|
parametersFormat: "<message>",
|
||||||
|
description: "Displays action")
|
||||||
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ struct CompletionSuggestionList: View {
|
||||||
to the list items in order to be as close as possible as the
|
to the list items in order to be as close as possible as the
|
||||||
`UITableView` display.
|
`UITableView` display.
|
||||||
*/
|
*/
|
||||||
@available (iOS 16.0, *)
|
@available(iOS 16.0, *)
|
||||||
static let collectionViewPaddingCorrection: CGFloat = -5.0
|
static let collectionViewPaddingCorrection: CGFloat = -5.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,19 +44,14 @@ struct CompletionSuggestionList: View {
|
||||||
// MARK: Public
|
// MARK: Public
|
||||||
|
|
||||||
@ObservedObject var viewModel: CompletionSuggestionViewModel.Context
|
@ObservedObject var viewModel: CompletionSuggestionViewModel.Context
|
||||||
var showBackgroundShadow: Bool = true
|
var showBackgroundShadow = true
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if viewModel.viewState.items.isEmpty {
|
if viewModel.viewState.items.isEmpty {
|
||||||
EmptyView()
|
EmptyView()
|
||||||
} else {
|
} else {
|
||||||
ZStack {
|
ZStack {
|
||||||
CompletionSuggestionListItem(content: CompletionSuggestionViewStateItem.user(
|
CompletionSuggestionListItem(content: CompletionSuggestionViewStateItem.user(id: "Prototype", avatar: AvatarInput(mxContentUri: "", matrixItemId: "", displayName: "Prototype"), displayName: "Prototype"))
|
||||||
id: "Prototype",
|
|
||||||
avatar: AvatarInput(mxContentUri: "",
|
|
||||||
matrixItemId: "",
|
|
||||||
displayName: "Prototype"),
|
|
||||||
displayName: "Prototype"))
|
|
||||||
.background(ViewFrameReader(frame: $prototypeListItemFrame))
|
.background(ViewFrameReader(frame: $prototypeListItemFrame))
|
||||||
.hidden()
|
.hidden()
|
||||||
if showBackgroundShadow {
|
if showBackgroundShadow {
|
||||||
|
|
Loading…
Reference in a new issue