Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let package = Package(
)
],
dependencies: [
.package(url: "https://github.com/GetStream/stream-chat-swift.git", from: "4.91.0")
.package(url: "https://github.com/GetStream/stream-chat-swift.git", branch: "v5")
],
targets: [
.target(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,3 @@ struct MonthlyAttachmentsHeader: View {
.background(Color(colors.background6))
}
}

extension ChatMessageFileAttachment: Identifiable {}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public struct ChatChannelView<Factory: ViewFactory>: View, KeyboardReadable {
)
} else {
ZStack {
factory.makeEmptyMessagesView(for: channel, colors: colors)
factory.makeEmptyMessagesView(options: EmptyMessagesViewOptions(channel: channel, colors: colors))
.dismissKeyboardOnTap(enabled: keyboardShown) {
hideComposerCommandsAndAttachmentsPicker()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ import SwiftUI
}
}

extension ChatMessage: Identifiable {
extension ChatMessage {
@MainActor public var scrollMessageId: String {
messageId
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,15 @@ public struct ComposerInputView<Factory: ViewFactory>: View, KeyboardReadable {
}

factory.makeComposerTextInputView(
text: $text,
height: $textHeight,
selectedRangeLocation: $selectedRangeLocation,
placeholder: isInCooldown ? L10n.Composer.Placeholder.slowMode : (isChannelFrozen ? L10n.Composer.Placeholder.messageDisabled : L10n.Composer.Placeholder.message),
editable: !isInputDisabled,
maxMessageLength: maxMessageLength,
currentHeight: textFieldHeight
options: ComposerTextInputViewOptions(
text: $text,
height: $textHeight,
selectedRangeLocation: $selectedRangeLocation,
placeholder: isInCooldown ? L10n.Composer.Placeholder.slowMode : (isChannelFrozen ? L10n.Composer.Placeholder.messageDisabled : L10n.Composer.Placeholder.message),
editable: !isInputDisabled,
maxMessageLength: maxMessageLength,
currentHeight: textFieldHeight
)
)
.environmentObject(viewModel)
.accessibilityIdentifier("ComposerTextInputView")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public struct MessageListView<Factory: ViewFactory>: View, KeyboardReadable {
)
) : nil
)
.modifier(factory.makeMessageListContainerModifier())
.modifier(factory.makeMessageListContainerModifier(options: MessageListContainerModifierOptions()))
.onDisappear {
messageRenderingUtil.update(previousTopMessage: nil)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@ public struct PollAttachmentView<Factory: ViewFactory>: View {
}
}

extension PollOption: Identifiable {}

struct PollOptionView<Factory: ViewFactory>: View {
@ObservedObject var viewModel: PollAttachmentViewModel

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import SwiftUI
$comments
.dropFirst()
.map { _ in true }
.assignWeakly(to: \.animateChanges, on: self)
.assign(to: \.animateChanges, onWeak: self)
.store(in: &cancellables)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import SwiftUI
$pollVotes
.dropFirst()
.map { _ in true }
.assignWeakly(to: \.animateChanges, on: self)
.assign(to: \.animateChanges, onWeak: self)
.store(in: &cancellables)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ struct PollOptionResultsView<Factory: ViewFactory>: View {
}
}

extension PollVote: Identifiable {
extension PollVote {
var displayId: String {
"\(id)-\(optionId ?? user?.id ?? "")-\(pollId)"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ import SwiftUI
.combineLatest($maxVotesEnabled)
.map { $0 && $1 }
.removeDuplicates()
.assignWeakly(to: \.showsMaxVotesError, on: self)
.assign(to: \.showsMaxVotesError, onWeak: self)
.store(in: &cancellables)
$options
.map { options in
Expand All @@ -97,7 +97,7 @@ import SwiftUI
return errorIndices
}
.removeDuplicates()
.assignWeakly(to: \.optionsErrorIndices, on: self)
.assign(to: \.optionsErrorIndices, onWeak: self)
.store(in: &cancellables)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,3 @@ struct ReactionsUsersView: View {
.accessibilityIdentifier("ReactionsUsersView")
}
}

extension ChatMessageReaction: Identifiable {
public var id: String {
"\(author.id)-\(type.rawValue)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,3 @@ public struct ReactionIcon: View {
.foregroundColor(color)
}
}

extension MessageReactionType: Identifiable {
public var id: String {
rawValue
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,3 @@ public struct ChannelsLazyVStack<Factory: ViewFactory>: View {
.modifier(factory.makeChannelListModifier(options: ChannelListModifierOptions()))
}
}

/// Determines the uniqueness of the channel list item.
extension ChatChannel: Identifiable {
public var id: String {
cid.rawValue
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,3 @@ public struct ThreadsLazyVStack<Factory: ViewFactory>: View {
}
}
}

/// Determines the uniqueness of the channel list item.
extension ChatThread: Identifiable {
public var id: String {
parentMessageId
}
}
45 changes: 0 additions & 45 deletions Sources/StreamChatSwiftUI/DependencyInjection.swift

This file was deleted.

10 changes: 5 additions & 5 deletions Sources/StreamChatSwiftUI/InjectedValuesExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import StreamChat

extension InjectedValues {
/// Provides access to the `ChatClient` instance.
public var chatClient: ChatClient {
@MainActor public var chatClient: ChatClient {
get {
streamChat.chatClient
}
Expand All @@ -17,7 +17,7 @@ extension InjectedValues {
}

/// Provides access to the `ColorPalette` instance.
public var colors: ColorPalette {
@MainActor public var colors: ColorPalette {
get {
streamChat.appearance.colors
}
Expand All @@ -27,7 +27,7 @@ extension InjectedValues {
}

/// Provides access to the `Utils` instance.
public var utils: Utils {
@MainActor public var utils: Utils {
get {
streamChat.utils
}
Expand All @@ -37,7 +37,7 @@ extension InjectedValues {
}

/// Provides access to the `Images` instance.
public var images: Images {
@MainActor public var images: Images {
get {
streamChat.appearance.images
}
Expand All @@ -47,7 +47,7 @@ extension InjectedValues {
}

/// Provides access to the `Fonts` instance.
public var fonts: Fonts {
@MainActor public var fonts: Fonts {
get {
streamChat.appearance.fonts
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/StreamChatSwiftUI/StreamChat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import StreamChat

/// Returns the current value for the `StreamChat` instance.
private struct StreamChatProviderKey: InjectionKey {
static var currentValue: StreamChat?
nonisolated(unsafe) static var currentValue: StreamChat?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching to StreamCore's InjectedValues which does not use MainActor, therefore, this becomes needed again.

}

extension InjectedValues {
Expand Down

This file was deleted.

28 changes: 0 additions & 28 deletions Sources/StreamChatSwiftUI/Utils/StreamConcurrency.swift

This file was deleted.

6 changes: 6 additions & 0 deletions Sources/StreamChatSwiftUI/Utils/StreamCore+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//
// Copyright © 2025 Stream.io Inc. All rights reserved.
//

import Foundation
@_exported import StreamCore
64 changes: 1 addition & 63 deletions Sources/StreamChatSwiftUI/Utils/StringExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extension Character {
extension String {
/// Checks whether a string is a single emoji
var isSingleEmoji: Bool { count == 1 && containsEmoji }

/// Checks whether the string contains an emoji
var containsEmoji: Bool { contains { $0.isEmoji } }

Expand All @@ -42,54 +42,6 @@ extension String {

// MARK: -

extension String {
/// computes levenshtein distance with another string (0
public func levenshtein(_ other: String) -> Int {
let sCount = count
let oCount = other.count

guard sCount != 0 else {
return oCount
}

guard oCount != 0 else {
return sCount
}

let line: [Int] = Array(repeating: 0, count: oCount + 1)
var mat: [[Int]] = Array(repeating: line, count: sCount + 1)

for i in 0...sCount {
mat[i][0] = i
}

for j in 0...oCount {
mat[0][j] = j
}

for j in 1...oCount {
for i in 1...sCount {
if self[i - 1] == other[j - 1] {
mat[i][j] = mat[i - 1][j - 1] // no operation
} else {
let del = mat[i - 1][j] + 1 // deletion
let ins = mat[i][j - 1] + 1 // insertion
let sub = mat[i - 1][j - 1] + 1 // substitution
mat[i][j] = min(min(del, ins), sub)
}
}
}

return mat[sCount][oCount]
}
}

extension String {
subscript(index: Int) -> Character {
self[self.index(startIndex, offsetBy: index)]
}
}

extension String {
/// Checks whether the string is a URL.
var isURL: Bool {
Expand All @@ -114,20 +66,6 @@ extension String {
static let unknownMessageId = "unknown"
}

extension String {
func ranges(of string: some StringProtocol, options: String.CompareOptions = []) -> [Range<String.Index>] {
var result: [Range<Index>] = []
var startIndex = startIndex
while startIndex < endIndex, let range = self[startIndex...].range(of: string, options: options) {
result.append(range)
startIndex = range.lowerBound < range.upperBound
? range.upperBound
: index(range.lowerBound, offsetBy: 1, limitedBy: endIndex) ?? endIndex
}
return result
}
}

extension String {
var trimmed: Self {
trimmingCharacters(in: .whitespacesAndNewlines)
Expand Down
Loading
Loading