diff --git a/KuringApp/KuringApp/Info.plist b/KuringApp/KuringApp/Info.plist index b6f5aa22..27258e35 100644 --- a/KuringApp/KuringApp/Info.plist +++ b/KuringApp/KuringApp/Info.plist @@ -2,6 +2,8 @@ + FirebaseAppDelegateProxyEnabled + CFBundleIcons CFBundleAlternateIcons diff --git a/package-kuring/Sources/Caches/Dependency/Departments.swift b/package-kuring/Sources/Caches/Dependency/Departments.swift index 76cc3676..2264aec6 100644 --- a/package-kuring/Sources/Caches/Dependency/Departments.swift +++ b/package-kuring/Sources/Caches/Dependency/Departments.swift @@ -40,10 +40,9 @@ extension Departments { var departments = Self.selections if departments.isEmpty { -// 학과 추가시 학과가 0개인 경우에는 current를 처음 학과로 설정 + // 학과 추가시 학과가 0개인 경우에는 current를 처음 학과로 설정 current = departments.first } - departments.append(noticeProvider) Self.selections = departments @@ -51,9 +50,9 @@ extension Departments { var departments = Self.selections Self.selections.removeAll { $0.id == id } - + if Self.current?.id == id { -// 삭제한 학과가 현재 선택한 학과일 경우 새로운 학과 정보로 업데이트 + // 삭제한 학과가 현재 선택한 학과일 경우 새로운 학과 정보로 업데이트 Self.current = nil Self.current = Self.selections.first } diff --git a/package-kuring/Sources/Caches/Dependency/Subscriptions.swift b/package-kuring/Sources/Caches/Dependency/Subscriptions.swift index aadfe865..8023ca5f 100644 --- a/package-kuring/Sources/Caches/Dependency/Subscriptions.swift +++ b/package-kuring/Sources/Caches/Dependency/Subscriptions.swift @@ -8,6 +8,8 @@ import Foundation import Dependencies public struct KuringSubscriptions { + /// 구독한 공지 리스트에 단일 객체 추가 + public var add: (_ noticeProvider: NoticeProvider) -> Void /// 구독한 공지 리스트 업데이트 public var update: (_ noticeProvider: Set) -> Void /// 구독한 모든 공지 카테고리 @@ -28,7 +30,12 @@ public struct KuringSubscriptions { extension KuringSubscriptions { public static let `default` = Self( - update: { noticeProviders in + add: { noticeProvider in + var subscriptions = Self.subscriptions + subscriptions.insert(noticeProvider) + Self.subscriptions = subscriptions + + }, update: { noticeProviders in Self.subscriptions = noticeProviders }, getAll: { diff --git a/package-kuring/Sources/UIKit/OnboardingUI/MyDepartmentSelector/MyDepartmentSelector.swift b/package-kuring/Sources/UIKit/OnboardingUI/MyDepartmentSelector/MyDepartmentSelector.swift index 4ca96f19..48fa2110 100644 --- a/package-kuring/Sources/UIKit/OnboardingUI/MyDepartmentSelector/MyDepartmentSelector.swift +++ b/package-kuring/Sources/UIKit/OnboardingUI/MyDepartmentSelector/MyDepartmentSelector.swift @@ -7,6 +7,7 @@ import Caches import Models import SwiftUI import ColorSet +import Networks import Dependencies struct MyDepartmentSelector: View { @@ -14,6 +15,10 @@ struct MyDepartmentSelector: View { @State private var currentStep: Step.ID = .searchDepartment.id @State private var selectedDepartment: NoticeProvider? = nil + @Dependency(\.kuringLink) var kuringLink + @Dependency(\.departments) var departments + @Dependency(\.subscriptions) var subscriptions + var body: some View { VStack { // 메인 영역 @@ -35,9 +40,17 @@ struct MyDepartmentSelector: View { if currentStep == .selectDepartment { Button(StringSet.button_complete.rawValue) { if let selectedDepartment { - @Dependency(\.departments) var departments + // 로컬 저장소에 학과 추가 NoticeProvider.addedDepartments.append(selectedDepartment) departments.add(selectedDepartment) + + Task(priority: .background) { + // 추가한 학과 구독, 단 api 성공시에만 구독정보 저장 + do { + try await kuringLink.subscribeDepartments([selectedDepartment.hostPrefix]) + subscriptions.add(selectedDepartment) + } + } } currentStep = .addedDepartment.id }