Skip to content

Commit

Permalink
fix crash & explore layout (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanCooper9 authored Sep 8, 2024
1 parent b7ad58a commit 3106c7b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extension FirebaseAppService: MessagingDelegate {
authenticationManager.loggedIn
.filter { $0 }
.mapToVoid()
.flatMapLatest { [userManager] in userManager.userPublisher }
.flatMapLatest(withUnretained: self) { $0.userManager.userPublisher }
.flatMapLatest { [database] user -> AnyPublisher<Void, Never> in
guard !user.notificationTokens.contains(fcmToken) else { return .never() }
return database
Expand Down
24 changes: 11 additions & 13 deletions FriendlyCompetitions/Views/Explore/ExploreView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,10 @@ struct ExploreView: View {
@StateObject private var viewModel = ExploreViewModel()

var body: some View {
List {
ScrollView {
if viewModel.searchText.isEmpty {
ForEach(viewModel.appOwnedCompetitions) { competition in
NavigationLink(value: NavigationDestination.competition(competition, nil)) {
FeaturedCompetition(competition: competition)
.padding(.horizontal)
}
.buttonStyle(.plain)
featured(competition)
}
} else {
if viewModel.searchResults.isEmpty {
Expand All @@ -30,11 +26,7 @@ struct ExploreView: View {
.frame(maxWidth: .infinity, alignment: .center)
} else {
ForEach(viewModel.searchResults.filter(\.appOwned)) { competition in
NavigationLink(value: NavigationDestination.competition(competition, nil)) {
FeaturedCompetition(competition: competition)
.padding(.horizontal)
}
.buttonStyle(.plain)
featured(competition)
}
ForEach(viewModel.searchResults.filter(\.appOwned.not)) { competition in
NavigationLink(value: NavigationDestination.competition(competition, nil)) {
Expand All @@ -57,15 +49,21 @@ struct ExploreView: View {
.listRowInsets(.zero)
}
}
.listRowInsets(.zero)
.listRowBackground(Color.clear)
.background(Color.listBackground)
.searchable(text: $viewModel.searchText, placement: .navigationBarDrawer(displayMode: .always))
.navigationTitle(L10n.Explore.title)
.registerScreenView(name: "Explore")
.embeddedInNavigationStack(path: $viewModel.navigationDestinations)
.navigationDestination(for: NavigationDestination.self) { $0.view }
}

private func featured(_ competition: Competition) -> some View {
NavigationLink(value: NavigationDestination.competition(competition, nil)) {
FeaturedCompetition(competition: competition)
.padding(.horizontal)
}
.buttonStyle(.plain)
}
}

#if DEBUG
Expand Down

0 comments on commit 3106c7b

Please sign in to comment.