mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Rename UserProfileProxy to UserProfile. It's a pure struct and proxies nothing.
Also remove the redundant `userID` property given `id` already exists (for Identifiable conformance).
This commit is contained in:
@@ -52,7 +52,7 @@ struct LocationSharingScreenViewState: BindableState {
|
||||
self.mapURLBuilder = mapURLBuilder
|
||||
self.ownUserID = ownUserID
|
||||
|
||||
let initialProfile: UserProfileProxy = switch interactionMode {
|
||||
let initialProfile: UserProfile = switch interactionMode {
|
||||
case .viewStatic(let locationData):
|
||||
.init(sender: locationData.sender)
|
||||
case .viewLive(let sender, _):
|
||||
@@ -64,7 +64,7 @@ struct LocationSharingScreenViewState: BindableState {
|
||||
case .picker:
|
||||
.init(userID: ownUserID)
|
||||
}
|
||||
userProfiles = [initialProfile.userID: initialProfile]
|
||||
userProfiles = [initialProfile.id: initialProfile]
|
||||
|
||||
if case .viewLive(_, let initialLiveLocationShare) = interactionMode, let initialLiveLocationShare {
|
||||
liveLocationShares = [initialLiveLocationShare]
|
||||
@@ -79,7 +79,7 @@ struct LocationSharingScreenViewState: BindableState {
|
||||
let interactionMode: LocationSharingInteractionMode
|
||||
let mapURLBuilder: MapTilerURLBuilderProtocol
|
||||
let ownUserID: String
|
||||
var userProfiles: [String: UserProfileProxy]
|
||||
var userProfiles: [String: UserProfile]
|
||||
var liveLocationShares: [LiveLocationShare] = []
|
||||
var isStoppingLiveLocation = false
|
||||
/// Whether this device has an active live location sharing session in the room.
|
||||
@@ -103,10 +103,10 @@ struct LocationSharingScreenViewState: BindableState {
|
||||
return nil
|
||||
}
|
||||
|
||||
let profile = userProfiles[share.userID] ?? UserProfileProxy(userID: share.userID)
|
||||
let profile = userProfiles[share.userID] ?? UserProfile(userID: share.userID)
|
||||
let kind = LocationMarkerKind.liveUser(profile)
|
||||
let coordinate = CLLocationCoordinate2D(latitude: geoURI.latitude, longitude: geoURI.longitude)
|
||||
return LocationAnnotation(id: profile.userID, coordinate: coordinate, kind: kind)
|
||||
return LocationAnnotation(id: profile.id, coordinate: coordinate, kind: kind)
|
||||
}
|
||||
case .picker:
|
||||
return []
|
||||
@@ -287,8 +287,8 @@ extension AlertInfo where T == LocationSharingViewAlert {
|
||||
|
||||
enum LocationMarkerKind: Equatable {
|
||||
case pin
|
||||
case staticUser(UserProfileProxy)
|
||||
case liveUser(UserProfileProxy)
|
||||
case staticUser(UserProfile)
|
||||
case liveUser(UserProfile)
|
||||
case placeholder
|
||||
|
||||
var id: String {
|
||||
@@ -296,7 +296,7 @@ enum LocationMarkerKind: Equatable {
|
||||
case .pin, .placeholder:
|
||||
UUID().uuidString
|
||||
case .staticUser(let profile), .liveUser(let profile):
|
||||
profile.userID
|
||||
profile.id
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ enum LocationMarkerKind: Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
var userProfile: UserProfileProxy? {
|
||||
var userProfile: UserProfile? {
|
||||
switch self {
|
||||
case .pin, .placeholder:
|
||||
nil
|
||||
|
||||
@@ -194,11 +194,11 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati
|
||||
private func updateUserProfiles(members: [RoomMemberProxyProtocol]) {
|
||||
switch state.interactionMode {
|
||||
case .picker:
|
||||
let ownUser = members.first { $0.userID == roomProxy.ownUserID }.map(UserProfileProxy.init) ?? .init(userID: roomProxy.ownUserID)
|
||||
state.userProfiles = [ownUser.userID: ownUser]
|
||||
let ownUser = members.first { $0.userID == roomProxy.ownUserID }.map(UserProfile.init) ?? .init(userID: roomProxy.ownUserID)
|
||||
state.userProfiles = [ownUser.id: ownUser]
|
||||
case .viewStatic(let location):
|
||||
let sender = members.first { $0.userID == location.sender.id }.map(UserProfileProxy.init) ?? .init(sender: location.sender)
|
||||
state.userProfiles = [sender.userID: sender]
|
||||
let sender = members.first { $0.userID == location.sender.id }.map(UserProfile.init) ?? .init(sender: location.sender)
|
||||
state.userProfiles = [sender.id: sender]
|
||||
case .viewLive(let sender, _):
|
||||
var userIDs = Set(state.liveLocationShares.map(\.userID))
|
||||
if let senderID = sender?.id {
|
||||
@@ -206,9 +206,9 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati
|
||||
}
|
||||
state.userProfiles = userIDs.reduce(into: [:]) { dict, userID in
|
||||
if let member = members.first(where: { $0.userID == userID }) {
|
||||
dict[userID] = UserProfileProxy(member: member)
|
||||
dict[userID] = UserProfile(member: member)
|
||||
} else {
|
||||
dict[userID] = UserProfileProxy(userID: userID)
|
||||
dict[userID] = UserProfile(userID: userID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ struct LocationShareSheet: View {
|
||||
}
|
||||
|
||||
private var senderName: String? {
|
||||
annotation.kind.displayName ?? annotation.kind.userProfile?.userID
|
||||
annotation.kind.displayName ?? annotation.kind.userProfile?.id
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@@ -40,8 +40,8 @@ struct LocationShareSheet: View {
|
||||
// MARK: - Previews
|
||||
|
||||
struct LocationShareSheet_Previews: PreviewProvider {
|
||||
static let profile = UserProfileProxy(userID: "@alice:example.com", displayName: "Alice")
|
||||
static let annotation = LocationAnnotation(id: profile.userID,
|
||||
static let profile = UserProfile(userID: "@alice:example.com", displayName: "Alice")
|
||||
static let annotation = LocationAnnotation(id: profile.id,
|
||||
coordinate: .init(latitude: 51.509865, longitude: -0.118092),
|
||||
kind: .liveUser(profile))
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ struct StaticLocationSheet: View {
|
||||
longitude: location.geoURI.longitude)))
|
||||
} label: {
|
||||
UserLocationCell(profile: profile,
|
||||
isOwnUser: context.viewState.isOwnUser(profile.userID),
|
||||
isOwnUser: context.viewState.isOwnUser(profile.id),
|
||||
kind: .static(isUserLocation: location.kind == .sender,
|
||||
timestamp: location.timestamp),
|
||||
mediaProvider: context.mediaProvider,
|
||||
|
||||
@@ -9,7 +9,7 @@ import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct UserLocationCell: View {
|
||||
let profile: UserProfileProxy
|
||||
let profile: UserProfile
|
||||
let isOwnUser: Bool
|
||||
let kind: Kind
|
||||
var mediaProvider: MediaProviderProtocol?
|
||||
@@ -23,7 +23,7 @@ struct UserLocationCell: View {
|
||||
}
|
||||
|
||||
private var name: String {
|
||||
isOwnUser ? L10n.commonYou : profile.displayName ?? profile.userID
|
||||
isOwnUser ? L10n.commonYou : profile.displayName ?? profile.id
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
|
||||
Reference in New Issue
Block a user