Skip to content

Commit 45d073c

Browse files
committed
refact: split profile image URL utility to the file
1 parent 765e85b commit 45d073c

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

Sources/VRCKit/Protocols/ProfileProtocols.swift

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,3 @@ public protocol ProfileDetailRepresentable: ProfileElementRepresentable {
3434
var lastActivity: Date { get }
3535
var state: User.State { get }
3636
}
37-
38-
public extension ProfileElementRepresentable {
39-
var thumbnailUrl: URL? {
40-
if let userIcon = userIcon {
41-
return userIcon
42-
}
43-
guard let url = avatarThumbnailUrl,
44-
let urlString = url.absoluteString.hasSuffix("256")
45-
? String(url.absoluteString.dropLast(3)) + "512"
46-
: avatarImageUrl?.absoluteString else { return nil }
47-
return URL(string: urlString)
48-
}
49-
50-
var userIconUrl: URL? {
51-
if let userIcon = userIcon {
52-
return userIcon
53-
}
54-
return avatarThumbnailUrl
55-
}
56-
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// ProfileImageURL.swift
3+
// VRCKit
4+
//
5+
// Created by makinosp on 2024/08/04.
6+
//
7+
8+
import Foundation
9+
10+
public extension ProfileElementRepresentable {
11+
var thumbnailUrl: URL? {
12+
if let userIcon = userIcon {
13+
return userIcon
14+
}
15+
guard let url = avatarThumbnailUrl,
16+
let urlString = url.absoluteString.hasSuffix("256")
17+
? String(url.absoluteString.dropLast(3)) + "512"
18+
: avatarImageUrl?.absoluteString else { return nil }
19+
return URL(string: urlString)
20+
}
21+
22+
var userIconUrl: URL? {
23+
if let userIcon = userIcon {
24+
return userIcon
25+
}
26+
return avatarThumbnailUrl
27+
}
28+
}

0 commit comments

Comments
 (0)