Skip to content

Commit

Permalink
Wait 500ms before sending request token (#317)
Browse files Browse the repository at this point in the history
* Wait 500ms before sending request token

* Check cancellation before reporting error
  • Loading branch information
shp7724 authored Oct 12, 2024
1 parent cde3589 commit 702ad8a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions SNUTT-2022/SNUTT/Repositories/NetworkUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ extension DataTask {
if let data = await response.data,
let errDto = try? JSONDecoder().decode(ErrorDto.self, from: data)
{
try Task.checkCancellation()
let errCode = ErrorCode(rawValue: errDto.errcode)
var requestInfo = await collectRequestInfo()
requestInfo["ErrorMessage"] = errCode?.errorMessage
Expand All @@ -129,13 +130,13 @@ extension DataTask {
throw STError(errCode ?? .SERVER_FAULT)
}
}

if let dto = try? await value {
return dto
}

try Task.checkCancellation()
let requestInfo = await collectRequestInfo()
Crashlytics.crashlytics().record(error: NSError(domain: "UNKNOWN_ERROR", code: -1, userInfo: requestInfo))
try Task.checkCancellation()
throw STError(.SERVER_FAULT)
}

Expand Down
1 change: 1 addition & 0 deletions SNUTT-2022/SNUTT/ViewModels/FriendsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class FriendsViewModel: BaseViewModel, ObservableObject {
Task { @MainActor [weak self] in
guard let self else { return }
appState.friend.pendingFriendRequestToken = nil
try await Task.sleep(nanoseconds: 500_000_000)
await eventEmitter.emitEvent(.addFriendKakao, payload: ["requestToken": token])
}
}
Expand Down

0 comments on commit 702ad8a

Please sign in to comment.