Skip to content

Commit

Permalink
Add experimental flag
Browse files Browse the repository at this point in the history
  • Loading branch information
nuno-vieira committed Jan 9, 2025
1 parent 6473c4b commit 2f5f203
Show file tree
Hide file tree
Showing 20 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions DemoApp/Screens/DemoAppTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//

import Combine
@_spi(ExperimentalLocation)
import StreamChat
import StreamChatUI
import UIKit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//

import CoreLocation
@_spi(ExperimentalLocation)
import StreamChat
import StreamChatUI
import UIKit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright © 2025 Stream.io Inc. All rights reserved.
//

@_spi(ExperimentalLocation)
import StreamChat
import StreamChatUI
import UIKit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright © 2025 Stream.io Inc. All rights reserved.
//

@_spi(ExperimentalLocation)
import StreamChat
import StreamChatUI
import UIKit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright © 2025 Stream.io Inc. All rights reserved.
//

@_spi(ExperimentalLocation)
import StreamChat
import StreamChatUI
import UIKit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//

import MapKit
@_spi(ExperimentalLocation)
import StreamChat
import StreamChatUI
import UIKit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Copyright © 2025 Stream.io Inc. All rights reserved.
//

@_spi(ExperimentalLocation)
import StreamChat
import StreamChatUI
import UIKit

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//

import Foundation
@_spi(ExperimentalLocation)
import StreamChat
import StreamChatUI
import UIKit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@ public class ChatChannelController: DataController, DelegateCallable, DataStoreP
/// - quotedMessageId: The id of the quoted message, in case the location is an inline reply.
/// - extraData: Additional extra data of the message object.
/// - completion: Called when saving the message to the local DB finishes, not when the message reaches the server.
@_spi(ExperimentalLocation)
public func sendStaticLocation(
_ location: LocationAttachmentInfo,
text: String? = nil,
Expand Down Expand Up @@ -901,6 +902,7 @@ public class ChatChannelController: DataController, DelegateCallable, DataStoreP
/// - extraData: Additional extra data of the message object.
/// - completion: Called when saving the message to the local DB finishes,
/// not when the message reaches the server.
@_spi(ExperimentalLocation)
public func startLiveLocationSharing(
_ location: LocationAttachmentInfo,
text: String? = nil,
Expand Down Expand Up @@ -963,6 +965,7 @@ public class ChatChannelController: DataController, DelegateCallable, DataStoreP
}

/// Stops sharing the live location message in the channel.
@_spi(ExperimentalLocation)
public func stopLiveLocationSharing(completion: ((Result<MessageId, Error>) -> Void)? = nil) {
guard let cid = cid, isChannelAlreadyCreated else {
channelModificationFailed { error in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ public extension CurrentChatUserController {
/// The updates are throttled to avoid sending too many requests.
///
/// - Parameter location: The new location to be updated.
@_spi(ExperimentalLocation)
func updateLiveLocation(_ location: LocationAttachmentInfo) {
guard let messages = activeLiveLocationMessagesObserver?.items, !messages.isEmpty else {
return
Expand Down Expand Up @@ -482,17 +483,20 @@ public protocol CurrentChatUserControllerDelegate: AnyObject {
)

/// The controller observed a change in the active live location messages.
@_spi(ExperimentalLocation)
func currentUserController(
_ controller: CurrentChatUserController,
didChangeActiveLiveLocationMessages messages: [ChatMessage]
)

/// The current user started sharing his location in message attachments.
@_spi(ExperimentalLocation)
func currentUserControllerDidStartSharingLiveLocation(
_ controller: CurrentChatUserController
)

/// The current user has no active live location attachments.
@_spi(ExperimentalLocation)
func currentUserControllerDidStopSharingLiveLocation(
_ controller: CurrentChatUserController
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,7 @@ public class ChatMessageController: DataController, DelegateCallable, DataStoreP
///
/// - Parameters:
/// - completion: Called when the server updates the message.
@_spi(ExperimentalLocation)
public func stopLiveLocationSharing(completion: ((Result<ChatMessage, Error>) -> Void)? = nil) {
guard let locationAttachment = message?.liveLocationAttachments.first else {
callback {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import Foundation
/// A type alias for an attachment with `LiveLocationAttachmentPayload` payload type.
///
/// Live location attachments are used to represent a live location sharing in a chat message.
@_spi(ExperimentalLocation)
public typealias ChatMessageLiveLocationAttachment = ChatMessageAttachment<LiveLocationAttachmentPayload>

/// The payload for attachments with `.liveLocation` type.
@_spi(ExperimentalLocation)
public struct LiveLocationAttachmentPayload: AttachmentPayload {
/// The type used to parse the attachment.
public static var type: AttachmentType = .liveLocation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import Foundation
/// A type alias for an attachment with `StaticLocationAttachmentPayload` payload type.
///
/// Static location attachments represent a location that doesn't change.
@_spi(ExperimentalLocation)
public typealias ChatMessageStaticLocationAttachment = ChatMessageAttachment<StaticLocationAttachmentPayload>

/// The payload for attachments with `.staticLocation` type.
@_spi(ExperimentalLocation)
public struct StaticLocationAttachmentPayload: AttachmentPayload {
/// The type used to parse the attachment.
public static var type: AttachmentType = .staticLocation
Expand Down
2 changes: 2 additions & 0 deletions Sources/StreamChat/Models/ChatMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,13 @@ public extension ChatMessage {
}

/// Returns the attachments of `.staticLocation` type.
@_spi(ExperimentalLocation)
var staticLocationAttachments: [ChatMessageStaticLocationAttachment] {
attachments(payloadType: StaticLocationAttachmentPayload.self)
}

/// Returns the attachments of `.liveLocation` type.
@_spi(ExperimentalLocation)
var liveLocationAttachments: [ChatMessageLiveLocationAttachment] {
attachments(payloadType: LiveLocationAttachmentPayload.self)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//

import Foundation
@testable import StreamChat
@testable @_spi(ExperimentalLocation) import StreamChat

extension MessageAttachmentPayload {
static func dummy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//

import CoreData
@_spi(ExperimentalLocation)
@testable import StreamChat
@testable import StreamChatTestTools
import XCTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//

import CoreData
@_spi(ExperimentalLocation)
@testable import StreamChat
@testable import StreamChatTestTools
import XCTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright © 2025 Stream.io Inc. All rights reserved.
//

@_spi(ExperimentalLocation)
@testable import StreamChat
@testable import StreamChatTestTools
import XCTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright © 2025 Stream.io Inc. All rights reserved.
//

@_spi(ExperimentalLocation)
@testable import StreamChat
@testable import StreamChatTestTools
import XCTest
Expand Down
1 change: 1 addition & 0 deletions Tests/StreamChatTests/Models/ChatMessage_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright © 2025 Stream.io Inc. All rights reserved.
//

@_spi(ExperimentalLocation)
@testable import StreamChat
@testable import StreamChatTestTools
import XCTest
Expand Down

0 comments on commit 2f5f203

Please sign in to comment.