Skip to content
Merged
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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### 🔄 Changed

# [4.76.0](https://github.com/GetStream/stream-chat-swift/releases/tag/4.76.0)
_March 31, 2025_

### StreamChatUI
### 🐞 Fixed
- Fix runtime exception if fonts in `Appearance.default.fonts` are set to scaled fonts [#3633](https://github.com/GetStream/stream-chat-swift/pull/3633)

### StreamChatUI
### 🐞 Fixed
- Fix draft not deleted when attachments are removed from the composer [#3631](https://github.com/GetStream/stream-chat-swift/pull/3631)

# [4.75.0](https://github.com/GetStream/stream-chat-swift/releases/tag/4.75.0)
_March 26, 2025_

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import Foundation

extension SystemEnvironment {
/// A Stream Chat version.
public static let version: String = "4.75.0"
public static let version: String = "4.76.0"
}
2 changes: 1 addition & 1 deletion Sources/StreamChat/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>4.75.0</string>
<string>4.76.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ private extension UIFont {
monospaced: Bool = false
) -> UIFont {
if !markdownFont.hasFontChanges && !monospaced {
return UIFontMetrics(forTextStyle: textStyle).scaledFont(for: defaultFont)
let font = UIFont(
descriptor: defaultFont.fontDescriptor,
size: defaultFont.pointSize
)
return UIFontMetrics(forTextStyle: textStyle)
.scaledFont(for: font)
}
// Default
var descriptor = defaultFont.fontDescriptor
Expand Down
11 changes: 6 additions & 5 deletions Sources/StreamChatUI/Composer/ComposerVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@ open class ComposerVC: _ViewController,
public var content: Content = .initial() {
didSet {
updateContentIfNeeded()

/// If the input message was erased or the attachments have been removed, delete the draft message.
if !oldValue.isEmpty && content.isEmpty {
deleteDraftMessageIfNeeded()
}
}
}

Expand Down Expand Up @@ -553,6 +558,7 @@ open class ComposerVC: _ViewController,

override open func updateContent() {
super.updateContent()

// Note: The order of the calls is important.
updateText()
updateKeystrokeEvents()
Expand Down Expand Up @@ -1544,11 +1550,6 @@ open class ComposerVC: _ViewController,
guard textView.text != content.text else { return }

content.text = textView.text

/// If the input message was erased and there is a draft message, the draft message should be deleted.
if content.isEmpty {
deleteDraftMessageIfNeeded()
}
}

open func textView(
Expand Down
2 changes: 1 addition & 1 deletion Sources/StreamChatUI/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>4.75.0</string>
<string>4.76.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion StreamChat-XCFramework.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "StreamChat-XCFramework"
spec.version = "4.75.0"
spec.version = "4.76.0"
spec.summary = "StreamChat iOS Client"
spec.description = "stream-chat-swift is the official Swift client for Stream Chat, a service for building chat applications."

Expand Down
2 changes: 1 addition & 1 deletion StreamChat.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "StreamChat"
spec.version = "4.75.0"
spec.version = "4.76.0"
spec.summary = "StreamChat iOS Chat Client"
spec.description = "stream-chat-swift is the official Swift client for Stream Chat, a service for building chat applications."

Expand Down
2 changes: 1 addition & 1 deletion StreamChatArtifacts.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion StreamChatUI-XCFramework.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "StreamChatUI-XCFramework"
spec.version = "4.75.0"
spec.version = "4.76.0"
spec.summary = "StreamChat UI Components"
spec.description = "StreamChatUI SDK offers flexible UI components able to display data provided by StreamChat SDK."

Expand Down
2 changes: 1 addition & 1 deletion StreamChatUI.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "StreamChatUI"
spec.version = "4.75.0"
spec.version = "4.76.0"
spec.summary = "StreamChat UI Components"
spec.description = "StreamChatUI SDK offers flexible UI components able to display data provided by StreamChat SDK."

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import StreamSwiftTestHelpers
import XCTest

final class ChatMessageMarkdown_Tests: XCTestCase {
override func tearDownWithError() throws {
Appearance.default = Appearance()
}

func test_text() {
let view = contentView(
"""
Expand Down Expand Up @@ -79,6 +83,26 @@ final class ChatMessageMarkdown_Tests: XCTestCase {
AssertSnapshot(view)
}

func test_headers_appearance_scaled_font() {
Appearance.default.fonts.title = UIFontMetrics.default.scaledFont(for: Appearance.default.fonts.title)
Appearance.default.fonts.title2 = UIFontMetrics.default.scaledFont(for: Appearance.default.fonts.title2)
Appearance.default.fonts.title3 = UIFontMetrics.default.scaledFont(for: Appearance.default.fonts.title3)
Appearance.default.fonts.headline = UIFontMetrics.default.scaledFont(for: Appearance.default.fonts.headline)
Appearance.default.fonts.subheadline = UIFontMetrics.default.scaledFont(for: Appearance.default.fonts.subheadline)
Appearance.default.fonts.footnote = UIFontMetrics.default.scaledFont(for: Appearance.default.fonts.footnote)
let view = contentView(
"""
# A first level heading
## A _second_ level heading
### A `third` level heading
#### A ~fourth~ level heading
##### A fifth level heading
###### A sixth level heading
"""
)
AssertSnapshot(view)
}

func test_unorderedLists() {
let view = contentView(
"""
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,32 @@ final class ComposerVC_Tests: XCTestCase {
XCTAssertEqual(mock.updateDraftMessage_callCount, 1)
}

func test_content_whenAttachmentsCleared_whenHasDraft_deletesDraft() {
composerVC.content.text = ""
composerVC.content.attachments = [.mockFile]

let mock = ChatChannelController_Mock.mock()
mock.channel_mock = .mock(cid: .unique, draftMessage: .mock())
composerVC.channelController = mock

composerVC.content.attachments = []

XCTAssertEqual(mock.deleteDraftMessage_callCount, 1)
}

func test_content_whenAttachmentsCleared_whenHasText_doesNotCallDeleteDraft() {
composerVC.content.text = "Hey"
composerVC.content.attachments = [.mockFile]

let mock = ChatChannelController_Mock.mock()
mock.channel_mock = .mock(cid: .unique, draftMessage: .mock())
composerVC.channelController = mock

composerVC.content.attachments = []

XCTAssertEqual(mock.deleteDraftMessage_callCount, 0)
}

func test_textViewDidChange_whenInputIsEmpty_whenHasDraft_deletesDraft() {
composerVC.content.text = "Hey"
let mock = ChatChannelController_Mock.mock()
Expand Down
Loading