Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Edit] FirestorePostViewModel 변경 중 중간커밋 #142 #144

Merged
merged 2 commits into from
Mar 7, 2024

Conversation

bdrsky2010
Copy link
Contributor

@bdrsky2010 bdrsky2010 commented Mar 7, 2024

개요 (이슈 번호 및 요약)

변경 사항 (작업 내용)

  • fetch 에러가 일어날 경우 return type이 optinal -> fetch 에러가 일어날 경우 error를 throw
// posts collection의 post document data 불러오는 메서드
// 불러오지 못 할 수 경우 error throw
func fetchPostDocument(ref: CollectionReference, postID: String) async throws -> Post {
	do {
		let postField = try await fetchPostField(ref: ref, postID: postID)
		let likedUsersID: [String] = await fetchPostLikedUsersID(ref: ref, postID: postID)
		return Post(postField: postField, likedUsersID: likedUsersID)
	} catch PostFetchError.postField {
		print("error :: fetchPostField() -> fetch post field data failure")
		throw PostFetchError.postField
	} catch {
		print("error :: fetchPostDocument() -> fetch post document data failure")
		throw PostFetchError.postDocument
	}
}
	
// posts collection의 Field data 불러오는 메서드
// 불러오지 못 할 수 경우 error throw
func fetchPostField(ref: CollectionReference, postID: String) async throws -> PostField {
	do {
		return try await ref.document(postID).getDocument(as: PostField.self)
	} catch {
		print(error.localizedDescription)
		throw PostFetchError.postField
	}
}

@withseon
Copy link
Contributor

withseon commented Mar 7, 2024

확-인-완

@Phangg
Copy link
Member

Phangg commented Mar 7, 2024

좋아요-

@bdrsky2010 bdrsky2010 merged commit 0f855fa into develop Mar 7, 2024
@bdrsky2010 bdrsky2010 deleted the refactoring/ViewModel branch March 7, 2024 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants