Skip to content

Commit 29c617e

Browse files
Implemented pinning channels in the demo app (#419)
1 parent b4b1d4c commit 29c617e

File tree

353 files changed

+632
-803
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

353 files changed

+632
-803
lines changed

DemoAppSwiftUI/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright © 2023 Stream.io Inc. All rights reserved.
2+
// Copyright © 2024 Stream.io Inc. All rights reserved.
33
//
44

55
import Sentry

DemoAppSwiftUI/AppleMessageComposerView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright © 2023 Stream.io Inc. All rights reserved.
2+
// Copyright © 2024 Stream.io Inc. All rights reserved.
33
//
44

55
import StreamChat

DemoAppSwiftUI/CreateGroupView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright © 2023 Stream.io Inc. All rights reserved.
2+
// Copyright © 2024 Stream.io Inc. All rights reserved.
33
//
44

55
import StreamChat

DemoAppSwiftUI/CreateGroupViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright © 2023 Stream.io Inc. All rights reserved.
2+
// Copyright © 2024 Stream.io Inc. All rights reserved.
33
//
44

55
import StreamChat

DemoAppSwiftUI/CustomAttachment.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright © 2023 Stream.io Inc. All rights reserved.
2+
// Copyright © 2024 Stream.io Inc. All rights reserved.
33
//
44

55
import StreamChat

DemoAppSwiftUI/CustomChannelHeader.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright © 2023 Stream.io Inc. All rights reserved.
2+
// Copyright © 2024 Stream.io Inc. All rights reserved.
33
//
44

55
import StreamChat

DemoAppSwiftUI/CustomComposerAttachmentView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright © 2023 Stream.io Inc. All rights reserved.
2+
// Copyright © 2024 Stream.io Inc. All rights reserved.
33
//
44

55
import Foundation

DemoAppSwiftUI/DemoAppSwiftUIApp.swift

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright © 2023 Stream.io Inc. All rights reserved.
2+
// Copyright © 2024 Stream.io Inc. All rights reserved.
33
//
44

55
import StreamChat
@@ -14,6 +14,8 @@ struct DemoAppSwiftUIApp: App {
1414

1515
@ObservedObject var appState = AppState.shared
1616
@ObservedObject var notificationsHandler = NotificationsHandler.shared
17+
18+
@State var channelListController: ChatChannelListController?
1719

1820
var body: some Scene {
1921
WindowGroup {
@@ -26,17 +28,31 @@ struct DemoAppSwiftUIApp: App {
2628
if notificationsHandler.notificationChannelId != nil {
2729
ChatChannelListView(
2830
viewFactory: DemoAppFactory.shared,
31+
channelListController: channelListController,
2932
selectedChannelId: notificationsHandler.notificationChannelId
3033
)
3134
} else {
3235
ChatChannelListView(
33-
viewFactory: DemoAppFactory.shared
36+
viewFactory: DemoAppFactory.shared,
37+
channelListController: channelListController
3438
)
3539
}
3640
}
3741
}
3842
.onChange(of: appState.userState) { newValue in
3943
if newValue == .loggedIn {
44+
if let currentUserId = chatClient.currentUserId {
45+
let pinnedByKey = ChatChannel.isPinnedBy(keyForUserId: currentUserId)
46+
let channelListQuery = ChannelListQuery(
47+
filter: .containMembers(userIds: [currentUserId]),
48+
sort: [
49+
.init(key: .custom(keyPath: \.isPinned, key: pinnedByKey), isAscending: true),
50+
.init(key: .lastMessageAt),
51+
.init(key: .updatedAt)
52+
]
53+
)
54+
channelListController = chatClient.channelListController(query: channelListQuery)
55+
}
4056
notificationsHandler.setupRemoteNotifications()
4157
}
4258
}

DemoAppSwiftUI/DemoUser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright © 2023 Stream.io Inc. All rights reserved.
2+
// Copyright © 2024 Stream.io Inc. All rights reserved.
33
//
44

55
import Foundation

DemoAppSwiftUI/GroupNameView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright © 2023 Stream.io Inc. All rights reserved.
2+
// Copyright © 2024 Stream.io Inc. All rights reserved.
33
//
44

55
import StreamChatSwiftUI

0 commit comments

Comments
 (0)