Skip to content

Commit

Permalink
[Edit] 줄바꿈좀 했습니다. #142
Browse files Browse the repository at this point in the history
  • Loading branch information
bdrsky2010 committed Mar 7, 2024
1 parent 05375a9 commit 6415bfc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions JUDA/ViewModel/Posts/FirestoreDrinkViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ extension FirestoreDrinkViewModel {
// 불러오지 못 할 경우 배열에 추가 x
func fetchTaggedPosts(ref: CollectionReference) async -> [Post] {
var taggedPosts = [Post]()

do {
let snapshot = try await ref.getDocuments()
for document in snapshot.documents {
Expand Down
3 changes: 3 additions & 0 deletions JUDA/ViewModel/Posts/FirestorePostViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extension FirestorePostViewModel {
let postField = try await fetchPostField(document: document)
let likedUsersIDRef = document.collection("likedUsersID")
let likedUsersID: [String] = await fetchPostLikedUsersID(ref: likedUsersIDRef)

return Post(postField: postField, likedUsersID: likedUsersID)
} catch PostFetchError.postField {
print("error :: fetchPostField() -> fetch post field data failure")
Expand All @@ -50,6 +51,7 @@ extension FirestorePostViewModel {
// fetch 에러를 던질 시, 해당 값을 배열에 추가되지 않음
func fetchPostLikedUsersID(ref: CollectionReference) async -> [String] {
var likedUsersID = [String]()

do {
let snapshot = try await ref.getDocuments()
for document in snapshot.documents {
Expand All @@ -69,6 +71,7 @@ extension FirestorePostViewModel {
// posts collection에서 삭제하고싶은 post에 해당하는 document 삭제 메서드
func deletePostDocument(postID: String) async -> Bool {
let postRef = Firestore.firestore().collection("posts")

do {
try await postRef.document(postID).delete()
return true
Expand Down

0 comments on commit 6415bfc

Please sign in to comment.