Skip to content

Commit

Permalink
Pmi format
Browse files Browse the repository at this point in the history
  • Loading branch information
vince-hz committed Nov 22, 2023
1 parent 535f09f commit 42ecd47
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
25 changes: 22 additions & 3 deletions Flat/Models/Flat/RoomBasicInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,23 @@ import RxSwift

extension String {
var formatterInviteCode: String {
split(every: 3).joined(separator: " ")
if count == 11 {
let i = index(startIndex, offsetBy: 4)
let j = index(i, offsetBy: 3)

let r =
self[startIndex ..< i]
+
" "
+
self[i ..< j]
+
" "
+
self[j ..< endIndex]
return String(r)
}
return split(every: 3).joined(separator: " ")
}
}

Expand All @@ -37,6 +53,7 @@ struct RoomBasicInfo: Decodable, Equatable {
let hasRecord: Bool
let inviteCode: String
let ownerAvatarURL: String
let isPmi: Bool
}

extension RoomBasicInfo {
Expand All @@ -58,7 +75,8 @@ extension RoomBasicInfo {
region: info.region,
hasRecord: info.hasRecord,
inviteCode: info.inviteCode,
ownerAvatarURL: "")
ownerAvatarURL: "",
isPmi: info.isPmi)
}
}

Expand All @@ -82,7 +100,8 @@ extension RoomBasicInfo {
region: info.region,
hasRecord: info.hasRecord,
inviteCode: info.inviteCode,
ownerAvatarURL: "")
ownerAvatarURL: "",
isPmi: info.isPmi)
completion(.success(basicInfo))
case let .failure(error):
completion(.failure(error))
Expand Down
6 changes: 5 additions & 1 deletion Flat/Modules/UIComponents/Share/ShareManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ struct ShareInfo {
time = formatter.string(from: roomDetail.beginTime)
subject = roomDetail.title
number = roomDetail.inviteCode.formatterInviteCode
link = URL(string: Env().webBaseURL + "/join/\(roomDetail.roomUUID)")!
if roomDetail.isPmi {
link = URL(string: Env().webBaseURL + "/join/\(roomDetail.inviteCode)")!
} else {
link = URL(string: Env().webBaseURL + "/join/\(roomDetail.roomUUID)")!
}
}

var description: String {
Expand Down

0 comments on commit 42ecd47

Please sign in to comment.