Skip to content

Commit

Permalink
Feat: Add MyPartyViewModel
Browse files Browse the repository at this point in the history
  • Loading branch information
YoonyoungL committed Jun 15, 2022
1 parent 22e273a commit 730aa33
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Taxi/Taxi.xcodeproj/project.pbxproj
Expand Up @@ -64,6 +64,7 @@
00F856A82844A985008E2E2F /* FirebaseFunctionsCombine-Community in Frameworks */ = {isa = PBXBuildFile; productRef = 00F856A72844A985008E2E2F /* FirebaseFunctionsCombine-Community */; };
00F856AA2844A985008E2E2F /* FirebaseStorage in Frameworks */ = {isa = PBXBuildFile; productRef = 00F856A92844A985008E2E2F /* FirebaseStorage */; };
00F856AC2844A985008E2E2F /* FirebaseStorageCombine-Community in Frameworks */ = {isa = PBXBuildFile; productRef = 00F856AB2844A985008E2E2F /* FirebaseStorageCombine-Community */; };
374E059E285A18EC00215533 /* MyPartyViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 374E059D285A18EC00215533 /* MyPartyViewModel.swift */; };
37D4D1F12856D285002E787B /* ChatRoomView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37D4D1F02856D285002E787B /* ChatRoomView.swift */; };
37F698852855FB910008C022 /* MyPartyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37F698842855FB910008C022 /* MyPartyView.swift */; };
50459E2F28542E4E00287371 /* PhotoPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50459E2E28542E4E00287371 /* PhotoPicker.swift */; };
Expand Down Expand Up @@ -154,6 +155,7 @@
00F6B72628596EEF00DACA06 /* PatyListCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PatyListCell.swift; sourceTree = "<group>"; };
00F6B72E2859C00E00DACA06 /* AddTaxiPartyViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddTaxiPartyViewModel.swift; sourceTree = "<group>"; };
00F6B7302859C44D00DACA06 /* ChattingRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChattingRepository.swift; sourceTree = "<group>"; };
374E059D285A18EC00215533 /* MyPartyViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPartyViewModel.swift; sourceTree = "<group>"; };
37D4D1F02856D285002E787B /* ChatRoomView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatRoomView.swift; sourceTree = "<group>"; };
37F698842855FB910008C022 /* MyPartyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPartyView.swift; sourceTree = "<group>"; };
50459E2E28542E4E00287371 /* PhotoPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoPicker.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -420,6 +422,7 @@
50F8003A28586F9200FA1063 /* Authentication.swift */,
00F6B72E2859C00E00DACA06 /* AddTaxiPartyViewModel.swift */,
000C24FA2859E74E0054D679 /* ChattingViewModel.swift */,
374E059D285A18EC00215533 /* MyPartyViewModel.swift */,
);
path = ViewModel;
sourceTree = "<group>";
Expand Down Expand Up @@ -610,6 +613,7 @@
00BC47472858CAF80055CB6A /* AddTaxiPartyUseCase.swift in Sources */,
00F6B7312859C44D00DACA06 /* ChattingRepository.swift in Sources */,
000E545A285321250085C39E /* JoinTaxiPartyUseCase.swift in Sources */,
374E059E285A18EC00215533 /* MyPartyViewModel.swift in Sources */,
00D3AE72284F8467001E34A0 /* TaxiPartyRepository.swift in Sources */,
50459E332854701C00287371 /* ImageExtension.swift in Sources */,
00E8F1BB284B21FE00D68DF0 /* Message.swift in Sources */,
Expand Down
35 changes: 35 additions & 0 deletions Taxi/Taxi/Presenter/ViewModel/MyPartyViewModel.swift
@@ -0,0 +1,35 @@
//
// MyPartyViewModel.swift
// Taxi
//
// Created by 이윤영 on 2022/06/15.
//

import Foundation

final class MyPartyViewModel: ObservableObject {
@Published private (set) var myPartyList: [TaxiParty] = []
private let myPartyUseCase: MyTaxiPartyUseCase = MyTaxiPartyUseCase()

func getMyParties(user: User) {
myPartyUseCase.getMyTaxiParty(user, force: true) { [weak self] taxiParties, error in
guard let self = self, let taxiParties = taxiParties else {
print(error ?? "")
return
}
print("Get MyParties, taxiParties: \(taxiParties)")
self.myPartyList = taxiParties
}
}

func leaveMyParty(user: User, party: TaxiParty) {
myPartyUseCase.leaveTaxiParty(party, user: user) { [weak self] error in
guard let self = self else {
print(error ?? "")
return
}
print("Leave Party, user:\(user.id), party:\(party.id)")
self.getMyParties(user: user)
}
}
}

0 comments on commit 730aa33

Please sign in to comment.