Skip to content

Commit

Permalink
Merge branch 'develop' into native-channel-pinning
Browse files Browse the repository at this point in the history
  • Loading branch information
laevandus committed Dec 9, 2024
2 parents 0ff7bf6 + 194eea5 commit 2aa2955
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

# Upcoming

### 🐞 Fixed
- Fix message thread reply footnote view not shown if parent message not in cache [#681](https://github.com/GetStream/stream-chat-swiftui/pull/681)
### ⚡ Performance
- Improve message search performance [#680](https://github.com/GetStream/stream-chat-swiftui/pull/680)
### ✅ Added
- Make `CreatePollView` public [#685](https://github.com/GetStream/stream-chat-swiftui/pull/685)

# [4.68.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.68.0)
_December 03, 2024_
Expand Down
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.67.0"),
.package(url: "https://github.com/GetStream/stream-chat-swift.git", from: "4.68.0"),
],
targets: [
.target(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,20 @@ public struct MessageContainerView<Factory: ViewFactory>: View {
)
.accessibilityElement(children: .contain)
.accessibility(identifier: "MessageRepliesView")
} else if message.showReplyInChannel, let parentId = message.parentMessageId {
/// In case the parent message is not available in the local cache, we need to fetch it from the remote server.
/// The lazy view uses the `factory.makeMessageRepliesShownInChannelView` internally once the parent message is fetched.
LazyMessageRepliesView(
factory: factory,
channel: channel,
message: message,
parentMessageController: chatClient.messageController(
cid: channel.cid,
messageId: parentId
)
)
.accessibilityElement(children: .contain)
.accessibility(identifier: "MessageRepliesView")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,45 @@ public struct MessageRepliesView<Factory: ViewFactory>: View {
}
}
}

/// Lazy view that uses the message controller to fetch the parent message before creating message replies view.
/// This is needed when the parent message is not available in the local cache.
/// Changing the `parentMessage` to `nil` in the `MessageRepliesView` would case multiple changes including breaking changes.
struct LazyMessageRepliesView<Factory: ViewFactory>: View {
@StateObject private var parentMessageObserver: ChatMessageController.ObservableObject

var factory: Factory
var channel: ChatChannel
var message: ChatMessage

init(
factory: Factory,
channel: ChatChannel,
message: ChatMessage,
parentMessageController: ChatMessageController
) {
_parentMessageObserver = StateObject(wrappedValue: parentMessageController.observableObject)
self.factory = factory
self.channel = channel
self.message = message
}

var body: some View {
VStack {
if let parentMessage = parentMessageObserver.message {
factory.makeMessageRepliesShownInChannelView(
channel: channel,
message: message,
parentMessage: parentMessage,
replyCount: parentMessage.replyCount
)
} else {
EmptyView()
}
}.onAppear {
if parentMessageObserver.message == nil {
parentMessageObserver.controller.synchronize()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct ComposerPollView: View {
}
}

struct CreatePollView: View {
public struct CreatePollView: View {

@Injected(\.colors) var colors
@Injected(\.fonts) var fonts
Expand All @@ -47,7 +47,7 @@ struct CreatePollView: View {

@State private var listId = UUID()

init(chatController: ChatChannelController, messageController: ChatMessageController?) {
public init(chatController: ChatChannelController, messageController: ChatMessageController?) {
_viewModel = StateObject(
wrappedValue: CreatePollViewModel(
chatController: chatController,
Expand All @@ -56,7 +56,7 @@ struct CreatePollView: View {
)
}

var body: some View {
public var body: some View {
NavigationView {
List {
VStack(alignment: .leading, spacing: 8) {
Expand Down
34 changes: 34 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,40 @@ private_lane :appstore_api_key do
)
end

desc "Updates StreamChat dependency locally. Usage: `bundle exec fastlane update_stream_chat version:4.56.0`"
lane :update_stream_chat do |options|
raise UI.user_error!('Provide a version.') unless options[:version]

Dir.chdir('..') do
file = 'Package.swift'
current_stream_chat_version = File.read(file)[/stream-chat-swift\.git", from: "([\d.]+)"\)/, 1]
File.write(file, File.read(file).gsub(/(stream-chat-swift\.git", from: ")[\d.]+"/, "\\1#{options[:version]}\""))

file = 'StreamChatSwiftUI-XCFramework.podspec'
File.write(file, File.read(file).gsub(/(StreamChat-XCFramework', '~> )[\d.]+'/, "\\1#{options[:version]}'"))

file = 'StreamChatSwiftUI.podspec'
File.write(file, File.read(file).gsub(/(StreamChat', '~> )[\d.]+'/, "\\1#{options[:version]}'"))

file = 'StreamChatSwiftUI.xcodeproj/project.pbxproj'
content = File.read(file)
if content.include?("minimumVersion = #{current_stream_chat_version}")
File.write(file, content.gsub("minimumVersion = #{current_stream_chat_version}", "minimumVersion = #{options[:version]}"))
elsif content.include?('branch = develop')
File.write(file, content.gsub('kind = branch', "minimumVersion = #{options[:version]}").gsub('branch = develop', 'kind = upToNextMajorVersion'))
else
UI.user_error!("Something went wrong after trying to modify #{file}.")
end
end

pr_create(
title: "Update StreamChat dependency to #{options[:version]}",
base_branch: 'develop',
head_branch: "ci/update-stream-chat-dependency-#{Time.now.to_i}",
github_repo: github_repo
)
end

lane :pod_lint do
lint_required = true
Dir.chdir('..') do
Expand Down

0 comments on commit 2aa2955

Please sign in to comment.