Skip to content

Commit 9f9f85c

Browse files
authored
Merge pull request #4327 from anyproto/ios-5454-sorting-chats-by-last-message-dates-not-working-on-ios
IOS-5454 Fix chat sorting by adding auto-enrichment for date sorts
2 parents c3ecfd1 + d7f6aae commit 9f9f85c

File tree

6 files changed

+184
-196
lines changed

6 files changed

+184
-196
lines changed

Anytype/Sources/PresentationLayer/TextEditor/Set/Subscriptions/Set/SetSubscriptionData.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ struct SetSubscriptionData: Hashable {
4545
if sorts.isEmpty {
4646
sorts.append(SearchHelper.sort(
4747
relation: .createdDate,
48-
type: .desc,
49-
includeTime: true
48+
type: .desc
5049
))
5150
}
5251
self.sorts = sorts

Anytype/Sources/ServiceLayer/ChatStorage/ChatDetailsSubscriptionBuilder.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ final class ChatDetailsSubscriptionBuilder: ChatDetailsSubscriptionBuilderProtoc
1818
}
1919

2020
func build() -> SubscriptionData {
21-
let sorts: [DataviewSort] = .builder {
22-
SearchHelper.sort(relation: .lastMessageDate, type: .desc)
23-
}
24-
2521
let filters: [DataviewFilter] = .builder {
2622
SearchHelper.layoutFilter([.chatDerived])
2723
}

Anytype/Sources/ServiceLayer/Object/Search/SearchService.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ final class SearchService: SearchServiceProtocol, Sendable {
152152
func searchRelations(text: String, excludedIds: [String], spaceId: String) async throws -> [PropertyDetails] {
153153
let sort = SearchHelper.sort(
154154
relation: BundledPropertyKey.lastUsedDate,
155-
type: .desc,
156-
includeTime: true
155+
type: .desc
157156
)
158157

159158
let spaceUxType = spaceViewsStorage.spaceView(spaceId: spaceId)?.uxType

Anytype/Sources/ServiceLayer/Subscriptions/RecentSubscriptionService.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,12 @@ final class RecentSubscriptionService: RecentSubscriptionServiceProtocol {
8585
case .recentEdit:
8686
return SearchHelper.sort(
8787
relation: BundledPropertyKey.lastModifiedDate,
88-
type: .desc,
89-
includeTime: true
88+
type: .desc
9089
)
9190
case .recentOpen:
9291
return SearchHelper.sort(
9392
relation: BundledPropertyKey.lastOpenedDate,
94-
type: .desc,
95-
includeTime: true
93+
type: .desc
9694
)
9795
}
9896
}

Modules/Services/Sources/Models/Common/BundledPropertyKey+InculdeType.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,32 @@ import AnytypeCore
33
import ProtobufMessages
44

55
public extension BundledPropertyKey {
6-
static let sortIncudeTimeKeys: [BundledPropertyKey] = [
7-
.lastOpenedDate,
6+
static let dateKeys: [BundledPropertyKey] = [
7+
.createdDate,
88
.lastModifiedDate,
9-
.createdDate
9+
.lastOpenedDate,
10+
.lastMessageDate,
11+
.dueDate,
12+
.addedDate,
13+
.lastUsedDate,
14+
.syncDate,
15+
.spaceJoinDate,
16+
.toBeDeletedDate
1017
]
1118
}
1219

1320
// MARK: - Helpers
1421

1522
public extension DataviewSort {
1623
func fixIncludeTime() -> Self {
17-
let rawKeys = BundledPropertyKey.sortIncudeTimeKeys.map(\.rawValue)
18-
24+
let rawKeys = BundledPropertyKey.dateKeys.map(\.rawValue)
25+
1926
if rawKeys.contains(relationKey) {
2027
var newSort = self
2128
newSort.includeTime = true
2229
return newSort
2330
}
24-
31+
2532
return self
2633
}
2734
}

0 commit comments

Comments
 (0)