Skip to content

Commit b1fbd61

Browse files
committed
Rename LocationDTO -> SharedLocationDTO
1 parent 1d8f0d9 commit b1fbd61

File tree

8 files changed

+41
-41
lines changed

8 files changed

+41
-41
lines changed

Sources/StreamChat/APIClient/Endpoints/Payloads/IdentifiableModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ extension PollVoteDTO: IdentifiableModel {
9999
static func id(for model: NSManagedObject) -> DatabaseId? { (model as? Self)?.id }
100100
}
101101

102-
extension LocationDTO: IdentifiableModel {
102+
extension SharedLocationDTO: IdentifiableModel {
103103
static var className: DatabaseType { _className }
104-
static var idKeyPath: String? { #keyPath(LocationDTO.messageId) }
104+
static var idKeyPath: String? { #keyPath(SharedLocationDTO.messageId) }
105105
static func id(for model: NSManagedObject) -> DatabaseId? { (model as? Self)?.messageId }
106106
}

Sources/StreamChat/Database/DTOs/ChannelDTO.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class ChannelDTO: NSManagedObject {
7474
@NSManaged var memberListQueries: Set<ChannelMemberListQueryDTO>
7575
@NSManaged var previewMessage: MessageDTO?
7676
@NSManaged var draftMessage: MessageDTO?
77-
@NSManaged var activeLiveLocations: Set<LocationDTO>
77+
@NSManaged var activeLiveLocations: Set<SharedLocationDTO>
7878

7979
/// If the current channel is muted by the current user, `mute` contains details.
8080
@NSManaged var mute: ChannelMuteDTO?

Sources/StreamChat/Database/DTOs/MessageDTO.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class MessageDTO: NSManagedObject {
8888
@NSManaged var draftReply: MessageDTO?
8989
@NSManaged var isDraft: Bool
9090

91-
@NSManaged var location: LocationDTO?
91+
@NSManaged var location: SharedLocationDTO?
9292
@NSManaged var isActiveLiveLocation: Bool
9393

9494
@NSManaged var reminder: MessageReminderDTO?

Sources/StreamChat/Database/DTOs/LocationDTO.swift renamed to Sources/StreamChat/Database/DTOs/SharedLocationDTO.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import CoreData
66
import Foundation
77

8-
@objc(LocationDTO)
9-
class LocationDTO: NSManagedObject {
8+
@objc(SharedLocationDTO)
9+
class SharedLocationDTO: NSManagedObject {
1010
@NSManaged var messageId: String
1111
@NSManaged var channelId: String
1212
@NSManaged var deviceId: String
@@ -33,8 +33,8 @@ class LocationDTO: NSManagedObject {
3333
messageId: String,
3434
context: NSManagedObjectContext,
3535
cache: PreWarmedCache?
36-
) -> LocationDTO {
37-
if let cachedObject = cache?.model(for: messageId, context: context, type: LocationDTO.self) {
36+
) -> SharedLocationDTO {
37+
if let cachedObject = cache?.model(for: messageId, context: context, type: SharedLocationDTO.self) {
3838
return cachedObject
3939
}
4040

@@ -48,21 +48,21 @@ class LocationDTO: NSManagedObject {
4848
return new
4949
}
5050

51-
static func load(messageId: String, context: NSManagedObjectContext) -> LocationDTO? {
51+
static func load(messageId: String, context: NSManagedObjectContext) -> SharedLocationDTO? {
5252
let request = fetchRequest(for: messageId)
5353
return load(by: request, context: context).first
5454
}
5555

56-
static func fetchRequest(for messageId: String) -> NSFetchRequest<LocationDTO> {
57-
let request = NSFetchRequest<LocationDTO>(entityName: LocationDTO.entityName)
58-
LocationDTO.applyPrefetchingState(to: request)
59-
request.sortDescriptors = [NSSortDescriptor(keyPath: \LocationDTO.message.createdAt, ascending: false)]
56+
static func fetchRequest(for messageId: String) -> NSFetchRequest<SharedLocationDTO> {
57+
let request = NSFetchRequest<SharedLocationDTO>(entityName: SharedLocationDTO.entityName)
58+
SharedLocationDTO.applyPrefetchingState(to: request)
59+
request.sortDescriptors = [NSSortDescriptor(keyPath: \SharedLocationDTO.message.createdAt, ascending: false)]
6060
request.predicate = NSPredicate(format: "messageId == %@", messageId)
6161
return request
6262
}
6363
}
6464

65-
extension LocationDTO {
65+
extension SharedLocationDTO {
6666
func asModel() throws -> SharedLocation {
6767
try isNotDeleted()
6868

@@ -79,8 +79,8 @@ extension LocationDTO {
7979

8080
extension NSManagedObjectContext {
8181
@discardableResult
82-
func saveLocation(payload: SharedLocationPayload, cache: PreWarmedCache?) throws -> LocationDTO {
83-
let locationDTO = LocationDTO.loadOrCreate(
82+
func saveLocation(payload: SharedLocationPayload, cache: PreWarmedCache?) throws -> SharedLocationDTO {
83+
let locationDTO = SharedLocationDTO.loadOrCreate(
8484
messageId: payload.messageId,
8585
context: self,
8686
cache: cache

Sources/StreamChat/Database/DatabaseSession.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ protocol PollDatabaseSession {
678678
protocol LocationDatabaseSession {
679679
/// Saves the provided location payload to the DB.
680680
@discardableResult
681-
func saveLocation(payload: SharedLocationPayload, cache: PreWarmedCache?) throws -> LocationDTO
681+
func saveLocation(payload: SharedLocationPayload, cache: PreWarmedCache?) throws -> SharedLocationDTO
682682
}
683683

684684
protocol DatabaseSession: UserDatabaseSession,

Sources/StreamChat/Database/StreamChatModel.xcdatamodeld/StreamChatModel.xcdatamodel/contents

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<attribute name="typeRawValue" attributeType="String" defaultValueString=""/>
6565
<attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/>
6666
<attribute name="watcherCount" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
67-
<relationship name="activeLiveLocations" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="LocationDTO" inverseName="channel" inverseEntity="LocationDTO"/>
67+
<relationship name="activeLiveLocations" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="SharedLocationDTO" inverseName="channel" inverseEntity="SharedLocationDTO"/>
6868
<relationship name="config" maxCount="1" deletionRule="Cascade" destinationEntity="ChannelConfigDTO" inverseName="channel" inverseEntity="ChannelConfigDTO"/>
6969
<relationship name="createdBy" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="UserDTO" inverseName="createdChannels" inverseEntity="UserDTO"/>
7070
<relationship name="currentlyTypingUsers" toMany="YES" deletionRule="Nullify" destinationEntity="UserDTO" inverseName="typingIn" inverseEntity="UserDTO"/>
@@ -179,21 +179,6 @@
179179
</uniquenessConstraint>
180180
</uniquenessConstraints>
181181
</entity>
182-
<entity name="LocationDTO" representedClassName="LocationDTO" syncable="YES">
183-
<attribute name="channelId" optional="YES" attributeType="String"/>
184-
<attribute name="deviceId" optional="YES" attributeType="String"/>
185-
<attribute name="endAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
186-
<attribute name="latitude" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="YES"/>
187-
<attribute name="longitude" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="YES"/>
188-
<attribute name="messageId" optional="YES" attributeType="String"/>
189-
<relationship name="channel" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="ChannelDTO" inverseName="activeLiveLocations" inverseEntity="ChannelDTO"/>
190-
<relationship name="message" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="MessageDTO" inverseName="location" inverseEntity="MessageDTO"/>
191-
<uniquenessConstraints>
192-
<uniquenessConstraint>
193-
<constraint value="messageId"/>
194-
</uniquenessConstraint>
195-
</uniquenessConstraints>
196-
</entity>
197182
<entity name="MemberDTO" representedClassName="MemberDTO" syncable="YES">
198183
<attribute name="archivedAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
199184
<attribute name="banExpiresAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
@@ -268,7 +253,7 @@
268253
<relationship name="draftOfThread" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="MessageDTO" inverseName="draftReply" inverseEntity="MessageDTO"/>
269254
<relationship name="draftReply" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="MessageDTO" inverseName="draftOfThread" inverseEntity="MessageDTO"/>
270255
<relationship name="flaggedBy" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="CurrentUserDTO" inverseName="flaggedMessages" inverseEntity="CurrentUserDTO"/>
271-
<relationship name="location" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="LocationDTO" inverseName="message" inverseEntity="LocationDTO"/>
256+
<relationship name="location" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="SharedLocationDTO" inverseName="message" inverseEntity="SharedLocationDTO"/>
272257
<relationship name="mentionedUsers" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="UserDTO" inverseName="mentionedMessages" inverseEntity="UserDTO"/>
273258
<relationship name="moderationDetails" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="MessageModerationDetailsDTO" inverseName="message" inverseEntity="MessageModerationDetailsDTO"/>
274259
<relationship name="parentMessage" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="MessageDTO" inverseName="replies" inverseEntity="MessageDTO"/>
@@ -457,6 +442,21 @@
457442
</uniquenessConstraint>
458443
</uniquenessConstraints>
459444
</entity>
445+
<entity name="SharedLocationDTO" representedClassName="SharedLocationDTO" syncable="YES">
446+
<attribute name="channelId" optional="YES" attributeType="String"/>
447+
<attribute name="deviceId" optional="YES" attributeType="String"/>
448+
<attribute name="endAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
449+
<attribute name="latitude" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="YES"/>
450+
<attribute name="longitude" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="YES"/>
451+
<attribute name="messageId" optional="YES" attributeType="String"/>
452+
<relationship name="channel" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="ChannelDTO" inverseName="activeLiveLocations" inverseEntity="ChannelDTO"/>
453+
<relationship name="message" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="MessageDTO" inverseName="location" inverseEntity="MessageDTO"/>
454+
<uniquenessConstraints>
455+
<uniquenessConstraint>
456+
<constraint value="messageId"/>
457+
</uniquenessConstraint>
458+
</uniquenessConstraints>
459+
</entity>
460460
<entity name="ThreadDTO" representedClassName="ThreadDTO" syncable="YES">
461461
<attribute name="createdAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
462462
<attribute name="currentUserUnreadCount" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>

StreamChat.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,7 @@
15821582
AD793F49270B767500B05456 /* ChatMessageReactionAuthorsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD793F48270B767500B05456 /* ChatMessageReactionAuthorsVC.swift */; };
15831583
AD793F4B270B769E00B05456 /* ChatMessageReactionAuthorViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD793F4A270B769E00B05456 /* ChatMessageReactionAuthorViewCell.swift */; };
15841584
AD7977BA2936D9450008B5FB /* Token_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD7977B92936D9450008B5FB /* Token_Tests.swift */; };
1585-
AD7A11902DEE008C00B8F963 /* LocationDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD9C926C2DD3A3900013A7E6 /* LocationDTO.swift */; };
1585+
AD7A11902DEE008C00B8F963 /* SharedLocationDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD9C926C2DD3A3900013A7E6 /* SharedLocationDTO.swift */; };
15861586
AD7A11912DEE00A000B8F963 /* SendMessageInterceptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD9C926F2DD4DCF90013A7E6 /* SendMessageInterceptor.swift */; };
15871587
AD7A11CB2DEE091400B8F963 /* LocationEndpoints.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD7A11CA2DEE090B00B8F963 /* LocationEndpoints.swift */; };
15881588
AD7A11CC2DEE091400B8F963 /* LocationEndpoints.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD7A11CA2DEE090B00B8F963 /* LocationEndpoints.swift */; };
@@ -1675,7 +1675,7 @@
16751675
AD99C909279B0E9D009DD9C5 /* MessageDateSeparatorFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD99C906279B0C9B009DD9C5 /* MessageDateSeparatorFormatter.swift */; };
16761676
AD99C90C279B136B009DD9C5 /* UserLastActivityFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD99C90A279B1363009DD9C5 /* UserLastActivityFormatter.swift */; };
16771677
AD99C90D279B136D009DD9C5 /* UserLastActivityFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD99C90A279B1363009DD9C5 /* UserLastActivityFormatter.swift */; };
1678-
AD9C926D2DD3A3950013A7E6 /* LocationDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD9C926C2DD3A3900013A7E6 /* LocationDTO.swift */; };
1678+
AD9C926D2DD3A3950013A7E6 /* SharedLocationDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD9C926C2DD3A3900013A7E6 /* SharedLocationDTO.swift */; };
16791679
AD9C92702DD4DD070013A7E6 /* SendMessageInterceptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD9C926F2DD4DCF90013A7E6 /* SendMessageInterceptor.swift */; };
16801680
ADA03A222D64EFE900DFE048 /* DraftMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADA03A212D64EFE900DFE048 /* DraftMessage.swift */; };
16811681
ADA03A232D64EFE900DFE048 /* DraftMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADA03A212D64EFE900DFE048 /* DraftMessage.swift */; };
@@ -4440,7 +4440,7 @@
44404440
AD99C906279B0C9B009DD9C5 /* MessageDateSeparatorFormatter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageDateSeparatorFormatter.swift; sourceTree = "<group>"; };
44414441
AD99C90A279B1363009DD9C5 /* UserLastActivityFormatter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserLastActivityFormatter.swift; sourceTree = "<group>"; };
44424442
AD9BE32526680E4200A6D284 /* Stream.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Stream.playground; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
4443-
AD9C926C2DD3A3900013A7E6 /* LocationDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationDTO.swift; sourceTree = "<group>"; };
4443+
AD9C926C2DD3A3900013A7E6 /* SharedLocationDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharedLocationDTO.swift; sourceTree = "<group>"; };
44444444
AD9C926F2DD4DCF90013A7E6 /* SendMessageInterceptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendMessageInterceptor.swift; sourceTree = "<group>"; };
44454445
ADA03A212D64EFE900DFE048 /* DraftMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DraftMessage.swift; sourceTree = "<group>"; };
44464446
ADA03A242D65041300DFE048 /* DraftMessage_Mock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DraftMessage_Mock.swift; sourceTree = "<group>"; };
@@ -5691,7 +5691,7 @@
56915691
ADEEB7F42BD168D500C76602 /* MessageReactionGroupDTO.swift */,
56925692
7978FBBB26E16295002CA2DF /* MessageSearchQueryDTO.swift */,
56935693
C1B49B3F2822C01C00F4E89E /* NSManagedObject+Validation.swift */,
5694-
AD9C926C2DD3A3900013A7E6 /* LocationDTO.swift */,
5694+
AD9C926C2DD3A3900013A7E6 /* SharedLocationDTO.swift */,
56955695
841BAA502BD1CD81000C73E4 /* PollDTO.swift */,
56965696
841BAA4D2BD1CD76000C73E4 /* PollOptionDTO.swift */,
56975697
841BAA4A2BD1CCC0000C73E4 /* PollVoteDTO.swift */,
@@ -11753,7 +11753,7 @@
1175311753
7978FBBC26E16295002CA2DF /* MessageSearchQueryDTO.swift in Sources */,
1175411754
DA640FBE2535CF9200D32944 /* UserListSortingKey.swift in Sources */,
1175511755
79877A182498E4EE00015F8B /* ChannelEndpoints.swift in Sources */,
11756-
AD7A11902DEE008C00B8F963 /* LocationDTO.swift in Sources */,
11756+
AD7A11902DEE008C00B8F963 /* SharedLocationDTO.swift in Sources */,
1175711757
40789D2D29F6AC500018C2BB /* AudioRecordingState.swift in Sources */,
1175811758
40789D3529F6AC500018C2BB /* AudioAnalysisEngine.swift in Sources */,
1175911759
7964F3BA249A314D002A09EC /* LogDestination.swift in Sources */,
@@ -12438,7 +12438,7 @@
1243812438
files = (
1243912439
4F1BEE7D2BE3851200B6685C /* ReactionListState+Observer.swift in Sources */,
1244012440
82BE0ACE2C009A17008DA9DC /* BlockedUserDetails.swift in Sources */,
12441-
AD9C926D2DD3A3950013A7E6 /* LocationDTO.swift in Sources */,
12441+
AD9C926D2DD3A3950013A7E6 /* SharedLocationDTO.swift in Sources */,
1244212442
40789D1C29F6AC500018C2BB /* AudioPlaybackState.swift in Sources */,
1244312443
AD8C7C612BA3DF2800260715 /* AppSettings.json in Sources */,
1244412444
C121E804274544AC00023E4C /* ChatClient.swift in Sources */,

TestTools/StreamChatTestTools/Mocks/StreamChat/Database/DatabaseSession_Mock.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class DatabaseSession_Mock: DatabaseSession {
272272
return underlyingSession.saveMessageSearch(payload: payload, for: query)
273273
}
274274

275-
func saveLocation(payload: SharedLocationPayload, cache: PreWarmedCache?) throws -> LocationDTO {
275+
func saveLocation(payload: SharedLocationPayload, cache: PreWarmedCache?) throws -> SharedLocationDTO {
276276
try underlyingSession.saveLocation(payload: payload, cache: cache)
277277
}
278278

0 commit comments

Comments
 (0)