Skip to content

Commit

Permalink
[Edit] RecordViewModel의 recordPostDataClear() 호출 위치 변경 #166
Browse files Browse the repository at this point in the history
- "술상올리기"의 task 내에서 호출
- 주석 수정
  • Loading branch information
withseon committed Mar 20, 2024
1 parent 3c4beb6 commit db0f404
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
6 changes: 3 additions & 3 deletions JUDA_iOS/JUDA/View/Main/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ struct MainView: View {
ScrollView {
VStack(alignment: .leading, spacing: 20) {
// 날씨와 어울리는 술 + 안주
// WeatherAndFood()
WeatherAndFood()
// 오늘의 술장 Top3
// DrinkTopView()
DrinkTopView()
// 오늘의 술상 Top3
// PostTopView()
PostTopView()
}
.padding(.bottom, 15)
}
Expand Down
4 changes: 3 additions & 1 deletion JUDA_iOS/JUDA/View/Mypage/AuthenticatedMypageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ struct AuthenticatedMypageView: View {
.font(.medium16)
.foregroundStyle(.mainBlack)
}
.task {
recordViewModel.recordPostDataClear()
}
}
.padding(.horizontal, 20)
.padding(.top, 20)
Expand Down Expand Up @@ -70,7 +73,6 @@ struct AuthenticatedMypageView: View {
.foregroundStyle(.mainBlack)
.onAppear {
appViewModel.tabBarState = .visible
recordViewModel.recordPostDataClear()
Task {
await authViewModel.startListeningForUserField()
}
Expand Down
4 changes: 3 additions & 1 deletion JUDA_iOS/JUDA/View/Posts/PostsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ struct PostsView: View {
// 비로그인 상태일 때 네비게이션링크 비활성화
.opacity(authViewModel.signInStatus ? 1.0 : 0.3)
.disabled(!authViewModel.signInStatus)
.task {
recordViewModel.recordPostDataClear()
}
}
.padding(.horizontal, 20)
// 인기 or 최신 탭뷰
Expand Down Expand Up @@ -193,7 +196,6 @@ struct PostsView: View {
}
.onAppear {
appViewModel.tabBarState = .visible
recordViewModel.recordPostDataClear()
}
}
.environmentObject(navigationRouter)
Expand Down
2 changes: 1 addition & 1 deletion JUDA_iOS/JUDA/View/Record/RecordView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct RecordView: View {
}
DispatchQueue.main.async {
Task {
// guard let user = authViewModel.currentUser else { return }
guard let user = authViewModel.currentUser else { return }
switch recordType {
case .add:
// post images upload, post upload
Expand Down
1 change: 1 addition & 0 deletions JUDA_iOS/JUDA/ViewModel/Posts/PostViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ extension PostViewModel {
// Post 데이터 받아오기
private func fetchPosts(querySnapshots: QuerySnapshot) async {
var tasks: [Task<(Int, Post)?, Error>] = []

for (index, document) in querySnapshots.documents.enumerated() {
let task = Task<(Int, Post)?, Error> {
do {
Expand Down
6 changes: 2 additions & 4 deletions JUDA_iOS/JUDA/ViewModel/Record/RecordViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ final class RecordViewModel: ObservableObject {

// MARK: - FireStroage post 이미지 업로드 및 이미지 URL 받아오기
func uploadMultipleImagesToFirebaseStorageAsync() async {
// guard let user = writtenUser else { return }
guard let user = writtenUser else { return }
do {
// 결과를 받을 배열 생성
var downloadURLs: [(Int, URL)] = []
Expand All @@ -124,8 +124,7 @@ final class RecordViewModel: ObservableObject {
// 각 이미지 데이터에 대해 비동기 업로드 작업 실행 및 배열에 추가
group.addTask {
// storage 폴더링을 위한 userID
// let userID = user.userID
let userID = "sampleUserID"
let userID = user.userID
// image fileName 생성
let imageID = UUID().uuidString
// storage에 이미지 업로드
Expand Down Expand Up @@ -187,7 +186,6 @@ final class RecordViewModel: ObservableObject {
// MARK: - Firestore drink 업데이트
func updateDrinkToFirestore() async {
guard let user = writtenUser else { return }
print("writtenUser 정보가 있다...????: ", user)
do {
let drinkRef = db.collection("drinks")
for drinkTag in drinkTags {
Expand Down

0 comments on commit db0f404

Please sign in to comment.