Skip to content

Commit e6d09f8

Browse files
authored
Merge pull request #75 from makinosp/develop
Develop
2 parents 55a61ad + 1f1df4f commit e6d09f8

File tree

7 files changed

+43
-18
lines changed

7 files changed

+43
-18
lines changed

.swiftlint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
disabled_rules:
22
- identifier_name
33
- multiple_closures_with_trailing_closure
4+
- non_optional_string_data_conversion
45

56
opt_in_rules:
67
- array_init

Sources/VRCKit/Models/FavoriteWorldModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extension FavoriteWorldWrapper: Decodable {
2121
if let world = try? container.decode(World.self) {
2222
worlds.append(world)
2323
} else {
24-
try container.decode(AnyCodable.self)
24+
_ = try container.decode(AnyCodable.self)
2525
}
2626
}
2727
self.worlds = worlds

Sources/VRCKit/Models/UserPlatformModel.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77

88
public enum UserPlatform: String, Codable {
9-
case android, ios, standalonewindows, web
9+
case android, ios, nativemobile, standalonewindows, web
1010
case blank = ""
1111
}
1212

@@ -19,6 +19,7 @@ extension UserPlatform: CustomStringConvertible {
1919
switch self {
2020
case .android: "Android"
2121
case .ios: "iOS"
22+
case .nativemobile: "Native Mobile"
2223
case .standalonewindows: "PC"
2324
case .web: "Web"
2425
case .blank: ""

Sources/VRCKit/PreviewServices/PreviewDataProvider.swift

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public final class PreviewDataProvider {
1515
let userDetails: [UserDetail]
1616
let instances: [Instance]
1717

18+
static let iconImageUrl = URL(string: "https://www.mediafire.com/convkey/f444/fmivuoxwvdvnucx9g.jpg")
19+
1820
private init() {
1921
let instance = Self.generateInstance(worldId: UUID(), instanceId: 0)
2022
let onlineFriendsSet: [FriendSet] = (0..<50).map { count in
@@ -65,8 +67,8 @@ public final class PreviewDataProvider {
6567
bio: "This is the demo user.",
6668
bioLinks: SafeDecodingArray(),
6769
currentAvatar: "",
68-
avatarImageUrl: nil,
69-
avatarThumbnailUrl: nil,
70+
avatarImageUrl: PreviewDataProvider.iconImageUrl,
71+
avatarThumbnailUrl: PreviewDataProvider.iconImageUrl,
7072
dateJoined: Date(),
7173
displayName: "usr_\(previewUserId.uuidString.prefix(8))",
7274
friendKey: "",
@@ -80,13 +82,13 @@ public final class PreviewDataProvider {
8082
offlineFriends: offlineFriends.map(\.id),
8183
onlineFriends: onlineFriends.map(\.id),
8284
pastDisplayNames: [],
83-
profilePicOverride: nil,
85+
profilePicOverride: PreviewDataProvider.iconImageUrl,
8486
state: .active,
8587
status: .active,
8688
statusDescription: "status",
8789
tags: UserTags(),
8890
twoFactorAuthEnabled: true,
89-
userIcon: URL(string: "https://ul.h3z.jp/9gGIcerr.png"),
91+
userIcon: PreviewDataProvider.iconImageUrl,
9092
userLanguage: nil,
9193
userLanguageCode: nil,
9294
presence: User.Presence()
@@ -119,21 +121,21 @@ public final class PreviewDataProvider {
119121
status: UserStatus
120122
) -> Friend {
121123
Friend(
122-
bio: nil,
124+
bio: "Biography",
123125
bioLinks: SafeDecodingArray(),
124-
avatarImageUrl: nil,
125-
avatarThumbnailUrl: nil,
126+
avatarImageUrl: iconImageUrl,
127+
avatarThumbnailUrl: iconImageUrl,
126128
displayName: "User_\(id.uuidString.prefix(8))",
127129
id: "usr_\(id.uuidString)",
128130
isFriend: true,
129131
lastLogin: Date(),
130132
lastPlatform: "standalonewindows",
131133
platform: .blank,
132-
profilePicOverride: nil,
134+
profilePicOverride: iconImageUrl,
133135
status: status,
134136
statusDescription: "",
135137
tags: UserTags(),
136-
userIcon: URL(string: "https://ul.h3z.jp/9gGIcerr.png"),
138+
userIcon: iconImageUrl,
137139
location: location,
138140
friendKey: ""
139141
)
@@ -149,19 +151,19 @@ public final class PreviewDataProvider {
149151
UserDetail(
150152
bio: "Demo",
151153
bioLinks: SafeDecodingArray(),
152-
avatarImageUrl: nil,
153-
avatarThumbnailUrl: nil,
154+
avatarImageUrl: iconImageUrl,
155+
avatarThumbnailUrl: iconImageUrl,
154156
displayName: "User_\(id.uuidString.prefix(8))",
155157
id: "usr_\(id.uuidString)",
156158
isFriend: isFriend,
157159
lastLogin: Date(),
158160
lastPlatform: "standalonewindows",
159-
profilePicOverride: nil,
161+
profilePicOverride: iconImageUrl,
160162
state: state,
161163
status: status,
162164
statusDescription: "Demo",
163165
tags: UserTags(),
164-
userIcon: URL(string: "https://ul.h3z.jp/9gGIcerr.png"),
166+
userIcon: iconImageUrl,
165167
location: location,
166168
friendKey: "",
167169
dateJoined: Date(),
@@ -212,8 +214,8 @@ public final class PreviewDataProvider {
212214
capacity: 32,
213215
tags: [],
214216
releaseStatus: .public,
215-
imageUrl: URL(string: "https://ul.h3z.jp/ecWPM0Wk.jpg"),
216-
thumbnailImageUrl: URL(string: "https://ul.h3z.jp/ecWPM0Wk.jpg"),
217+
imageUrl: Const.privateWorldImageUrl,
218+
thumbnailImageUrl: Const.privateWorldImageUrl,
217219
namespace: nil,
218220
organization: "",
219221
previewYoutubeId: "",
@@ -228,4 +230,8 @@ public final class PreviewDataProvider {
228230
version: 1
229231
)
230232
}
233+
234+
public static func generateWorld() -> World {
235+
generateWorld(worldId: UUID())
236+
}
231237
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// WorldPreviewService.swift
3+
// VRCKit
4+
//
5+
// Created by makinosp on 2024/09/09.
6+
//
7+
8+
public final class WorldPreviewService: WorldService {
9+
override public func fetchWorld(worldId: String) async throws -> World {
10+
PreviewDataProvider.generateWorld()
11+
}
12+
13+
override public func fetchFavoritedWorlds() async throws -> [World] {
14+
(0..<10).map { _ in PreviewDataProvider.generateWorld() }
15+
}
16+
}

Sources/VRCKit/Protocols/WorldServiceProtocol.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77

88
// WorldServiceProtocol.swift
99
public protocol WorldServiceProtocol {
10+
func fetchWorld(worldId: String) async throws -> World
1011
func fetchFavoritedWorlds() async throws -> [World]
1112
}

Sources/VRCKit/Utils/Serializer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ final class Serializer {
3939
// for debug
4040
print(type(of: T.self))
4141
print(error)
42-
print(String(decoding: data, as: UTF8.self))
42+
print(String(data: data, encoding: .utf8) ?? "")
4343
throw error
4444
}
4545
}

0 commit comments

Comments
 (0)