Skip to content

Commit 241fead

Browse files
authored
Merge pull request #101 from makinosp/develop
Develop
2 parents d4c79f6 + 304438d commit 241fead

File tree

5 files changed

+33
-15
lines changed

5 files changed

+33
-15
lines changed

Harmonie.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

harmonie/Views/Location/LocationCardView.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ struct LocationCardView: View {
4040
}
4141
.frame(minHeight: 120)
4242
.task {
43-
do {
44-
instance = try await service.fetchInstance(location: location.location)
45-
} catch {
46-
appVM.handleError(error)
43+
if case let .id(id) = location.location {
44+
do {
45+
instance = try await service.fetchInstance(location: id)
46+
} catch {
47+
appVM.handleError(error)
48+
}
4749
}
4850
}
4951
}

harmonie/Views/UserDetail/UserDetailView+Actions.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
import VRCKit
99

1010
extension UserDetailView {
11-
func fetchInstance() async {
11+
func fetchInstance(id: String) async {
1212
let service = appVM.isDemoMode
1313
? InstancePreviewService(client: appVM.client)
1414
: InstanceService(client: appVM.client)
1515
do {
16-
instance = try await service.fetchInstance(location: user.location)
16+
defer { isRequesting = false }
17+
isRequesting = true
18+
instance = try await service.fetchInstance(location: id)
1719
} catch {
1820
appVM.handleError(error)
1921
}

harmonie/Views/UserDetail/UserDetailView+LocationSection.swift

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,40 @@ extension UserDetailView {
1313
var locationDescription: String {
1414
if let instance = instance {
1515
instance.world.name
16-
} else if !user.isVisible {
17-
user.location.capitalized
16+
} else if user.location == .offline {
17+
"Offline"
18+
} else if user.location == .private {
19+
"Private World"
1820
} else if isRequesting {
1921
String(repeating: " ", count: 15)
2022
} else {
2123
""
2224
}
2325
}
2426

27+
var locationImageUrl: URL? {
28+
if user.isVisible {
29+
return instance?.imageUrl(.x256)
30+
}
31+
return switch user.location {
32+
case .offline:
33+
Const.offlineImageUrl
34+
case .private, .traveling:
35+
Const.privateWorldImageUrl
36+
default:
37+
nil
38+
}
39+
}
40+
2541
var locationSection: some View {
2642
SectionView {
2743
Text("Location")
2844
.font(.subheadline)
2945
.foregroundStyle(Color.gray)
3046
HStack {
31-
SquareURLImage(url: instance?.world.imageUrl(.x256))
47+
SquareURLImage(url: locationImageUrl)
3248
Text(locationDescription)
33-
.font(.body)
49+
.font(.headline)
3450
}
3551
.redacted(reason: isRequesting ? .placeholder : [])
3652
}

harmonie/Views/UserDetail/UserDetailView.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,9 @@ struct UserDetailView: View {
3838
.navigationBarTitleDisplayMode(.inline)
3939
.toolbar { toolbar }
4040
.task {
41-
isRequesting = true
42-
if user.isVisible {
43-
await fetchInstance()
41+
if case let .id(id) = user.location {
42+
await fetchInstance(id: id)
4443
}
45-
isRequesting = false
4644
}
4745
}
4846

0 commit comments

Comments
 (0)