diff --git a/apple/OmnivoreKit/Sources/Binders/RootViewModel.swift b/apple/OmnivoreKit/Sources/Binders/RootViewModel.swift index 9cb448341..0afd577ad 100644 --- a/apple/OmnivoreKit/Sources/Binders/RootViewModel.swift +++ b/apple/OmnivoreKit/Sources/Binders/RootViewModel.swift @@ -29,21 +29,6 @@ public final class RootViewModel: ObservableObject { registerFonts() } - func updateWaitlistStatus() { - services.dataService.viewerPublisher().sink( - receiveCompletion: { completion in - guard case let .failure(error) = completion else { return } - print(error) - }, - receiveValue: { [weak self] viewer in - guard let self = self else { return } - let isWaitlisted = viewer.isWaitlisted - self.services.authenticator.updateWaitlistStatus(isWaitlistedUser: isWaitlisted) - } - ) - .store(in: &subscriptions) - } - func configurePDFProvider(pdfViewerProvider: @escaping (URL, PDFViewerViewModel) -> AnyView) { PDFProvider.pdfViewerProvider = { [weak self] url, feedItem in guard let self = self else { return AnyView(Text("")) } @@ -163,34 +148,30 @@ public struct RootView: View { @ViewBuilder private var innerBody: some View { if authenticator.isLoggedIn { - if authenticator.isWaitlisted { - WaitlistView(viewModel: WaitlistViewModel.make(services: viewModel.services)) - } else { - PrimaryContentView(viewModel: primaryViewModel) - .onAppear { - viewModel.updateWaitlistStatus() - viewModel.triggerPushNotificationRequestIfNeeded() + PrimaryContentView(viewModel: primaryViewModel) + .onAppear { + viewModel.triggerPushNotificationRequestIfNeeded() + } + #if os(iOS) + .fullScreenCover(item: $viewModel.webLinkPath, content: { safariLinkPath in + NavigationView { + FullScreenWebAppView( + viewModel: viewModel.webAppWrapperViewModel(webLinkPath: safariLinkPath.path), + handleClose: { viewModel.webLinkPath = nil } + ) } - #if os(iOS) - .fullScreenCover(item: $viewModel.webLinkPath, content: { safariLinkPath in - NavigationView { - FullScreenWebAppView( - viewModel: viewModel.webAppWrapperViewModel(webLinkPath: safariLinkPath.path), - handleClose: { viewModel.webLinkPath = nil } - ) - } - }) - #endif - .snackBar( - isShowing: $viewModel.showSnackbar, - text: Text(viewModel.snackbarMessage ?? "") - ) - #if os(iOS) - .customAlert(isPresented: $viewModel.showPushNotificationPrimer) { - pushNotificationPrimerView - } - #endif - } + }) + #endif + .snackBar( + isShowing: $viewModel.showSnackbar, + text: Text(viewModel.snackbarMessage ?? "") + ) + #if os(iOS) + .customAlert(isPresented: $viewModel.showPushNotificationPrimer) { + pushNotificationPrimerView + } + #endif + } else { WelcomeView(viewModel: WelcomeViewModel.make(services: viewModel.services)) .accessibilityElement() diff --git a/apple/OmnivoreKit/Sources/Binders/Scenes/WaitlistScene.swift b/apple/OmnivoreKit/Sources/Binders/Scenes/WaitlistScene.swift deleted file mode 100644 index 06230803b..000000000 --- a/apple/OmnivoreKit/Sources/Binders/Scenes/WaitlistScene.swift +++ /dev/null @@ -1,39 +0,0 @@ -import Models -import Services -import SwiftUI -import Utils -import Views - -extension WaitlistViewModel { - static func make(services: Services) -> WaitlistViewModel { - let viewModel = WaitlistViewModel() - viewModel.bind(services: services) - return viewModel - } - - func bind(services: Services) { - performActionSubject.sink { [weak self] action in - switch action { - case .logout: - services.authenticator.logout() - case .checkStatus: - self?.updateWaitlistStatus(services: services) - } - } - .store(in: &subscriptions) - } - - private func updateWaitlistStatus(services: Services) { - services.dataService.viewerPublisher().sink( - receiveCompletion: { completion in - guard case let .failure(error) = completion else { return } - print(error) - }, - receiveValue: { viewer in - let isWaitlisted = viewer.isWaitlisted - services.authenticator.updateWaitlistStatus(isWaitlistedUser: isWaitlisted) - } - ) - .store(in: &subscriptions) - } -} diff --git a/apple/OmnivoreKit/Sources/Models/UserProfile.swift b/apple/OmnivoreKit/Sources/Models/UserProfile.swift index 4d9e64ca7..d3588df5c 100644 --- a/apple/OmnivoreKit/Sources/Models/UserProfile.swift +++ b/apple/OmnivoreKit/Sources/Models/UserProfile.swift @@ -50,19 +50,16 @@ public struct Viewer { public let username: String public let name: String public let profileImageURL: String? - public let isWaitlisted: Bool public init( username: String, name: String, profileImageURL: String?, - isWaitlisted: Bool, userID: String ) { self.username = username self.name = name self.profileImageURL = profileImageURL - self.isWaitlisted = isWaitlisted self.userID = userID } } diff --git a/apple/OmnivoreKit/Sources/Services/Authentication/Authenticator.swift b/apple/OmnivoreKit/Sources/Services/Authentication/Authenticator.swift index 1b0d29fb3..d973530bb 100644 --- a/apple/OmnivoreKit/Sources/Services/Authentication/Authenticator.swift +++ b/apple/OmnivoreKit/Sources/Services/Authentication/Authenticator.swift @@ -14,7 +14,6 @@ public final class Authenticator: ObservableObject { } @Published public internal(set) var isLoggedIn: Bool - @Published public internal(set) var isWaitlisted = false let networker: Networker @@ -58,10 +57,6 @@ public final class Authenticator: ObservableObject { return !authToken.isEmpty } - public func updateWaitlistStatus(isWaitlistedUser: Bool) { - isWaitlisted = isWaitlistedUser - } - private func clearCookies() { HTTPCookieStorage.shared.removeCookies(since: Date.distantPast) diff --git a/apple/OmnivoreKit/Sources/Services/DataService/Queries/ViewerPublisher.swift b/apple/OmnivoreKit/Sources/Services/DataService/Queries/ViewerPublisher.swift index 2f0089b4d..7b91e2c50 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/Queries/ViewerPublisher.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/Queries/ViewerPublisher.swift @@ -30,7 +30,6 @@ extension DataService { profileImageURL: try $0.profile( selection: .init { try $0.pictureUrl() } ), - isWaitlisted: try !($0.isFullUser() ?? false), userID: try $0.id() ) } diff --git a/apple/OmnivoreKit/Sources/Views/RegistrationViews/WaitlistView.swift b/apple/OmnivoreKit/Sources/Views/RegistrationViews/WaitlistView.swift deleted file mode 100644 index 2422c9cf0..000000000 --- a/apple/OmnivoreKit/Sources/Views/RegistrationViews/WaitlistView.swift +++ /dev/null @@ -1,125 +0,0 @@ -import Combine -import Models -import SwiftUI - -public final class WaitlistViewModel: ObservableObject { - public enum Action { - case logout - case checkStatus - } - - public var subscriptions = Set() - public let performActionSubject = PassthroughSubject() - - public init() {} -} - -public struct WaitlistView: View { - @Environment(\.horizontalSizeClass) var horizontalSizeClass - @ObservedObject private var viewModel: WaitlistViewModel - - public init(viewModel: WaitlistViewModel) { - self.viewModel = viewModel - } - - @ViewBuilder func userInteractiveView(width: CGFloat) -> some View { - waitlistButtonView - .frame(width: width) - .zIndex(2) - } - - var titleLogo: some View { - Image.omnivoreTitleLogo - .renderingMode(.template) - .foregroundColor(.appGrayTextContrast) - .frame(height: 40) - } - - var waitlistButtonView: some View { - VStack(alignment: .center, spacing: 32) { - Text("Your username has been reserved. We will inform you by email when we open up Omnivore to more users.") - .font(.appHeadline) - .multilineTextAlignment(.center) - .frame(maxWidth: 300) - - BorderedButton(color: .appGrayTextContrast, text: "Check Status") { - viewModel.performActionSubject.send(.checkStatus) - } - .frame(width: 220) - - BorderedButton(color: .appGrayTextContrast, text: "Logout") { - viewModel.performActionSubject.send(.logout) - } - .frame(width: 220) - } - .padding(.horizontal, horizontalSizeClass == .compact ? 16 : 80) - .padding(.top, horizontalSizeClass == .compact ? 16 : 0) - } - - @ViewBuilder func splitColorBackground(width: CGFloat) -> some View { - HStack(spacing: 0) { - Color.systemBackground.frame(width: width * 0.5) - Color.appBackground.frame(width: width * 0.5) - } - .edgesIgnoringSafeArea(.all) - } - - @ViewBuilder func largeBackgroundImage(width: CGFloat) -> some View { - Image.readingIllustrationXXL - .resizable() - .aspectRatio(contentMode: .fill) - .frame(width: width) - .clipped() - .edgesIgnoringSafeArea([.vertical, .trailing]) - } - - @ViewBuilder func primaryContent() -> some View { - if horizontalSizeClass == .compact { - GeometryReader { geometry in - ZStack(alignment: .leading) { - Color.systemBackground - .edgesIgnoringSafeArea(.all) - - if geometry.size.width < geometry.size.height { - VStack { - Color.appDeepBackground.frame(height: 100) - Spacer() - } - .edgesIgnoringSafeArea(.all) - } - - VStack { - if geometry.size.width < geometry.size.height { - RegistrationHeroImageView( - tapGestureHandler: {} - ) - } - userInteractiveView(width: geometry.size.width) - Spacer() - } - } - } - } else { - GeometryReader { geometry in - ZStack(alignment: .leading) { - splitColorBackground(width: geometry.size.width) - - VStack { - titleLogo - Spacer() - } - .padding() - - HStack(spacing: 0) { - userInteractiveView(width: geometry.size.width * 0.5) - largeBackgroundImage(width: geometry.size.width * 0.5) - } - } - } - } - } - - public var body: some View { - primaryContent() - } -}