Skip to content

Commit

Permalink
Sidebar: Add activity indicator when user subscriptions are loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimillian committed May 15, 2021
1 parent 8b5019d commit b3a78ec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
9 changes: 8 additions & 1 deletion Packages/Backend/Sources/Backend/User/CurrentUserStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@ public class CurrentUserStore: ObservableObject, PersistentDataStore {
}
}

@Published public private(set) var isRefreshingSubscriptions = false

@Published public private(set) var overview: [GenericListingContent]?
@Published public private(set) var savedPosts: [SubredditPost]?
@Published public private(set) var submittedPosts: [SubredditPost]?

private var subscriptionFetched = false
private var fetchingSubscriptions: [Subreddit] = []
private var fetchingSubscriptions: [Subreddit] = [] {
didSet {
isRefreshingSubscriptions = !fetchingSubscriptions.isEmpty
}
}

private var disposables: [AnyCancellable?] = []
private var authStateCancellable: AnyCancellable?
private var afterOverview: String?
Expand Down
14 changes: 13 additions & 1 deletion RedditOs/Features/Sidebar/SidebarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct SidebarView: View {
.animation(.easeInOut)

if let subs = currentUser.subscriptions, currentUser.user != nil {
Section(header: Text("Subscriptions")) {
Section(header: subscriptionsHeader) {
ForEach(subs) { reddit in
HStack {
SidebarSubredditRow(name: reddit.displayName,
Expand Down Expand Up @@ -119,6 +119,18 @@ struct SidebarView: View {
}
}

private var subscriptionsHeader: some View {
HStack(spacing: 8) {
Text("Subscriptions")
if currentUser.isRefreshingSubscriptions {
ProgressView()
.progressViewStyle(CircularProgressViewStyle())
.frame(width: 15, height: 15)
.scaleEffect(0.5)
}
}
}

private var subredditsHeader: some View {
HStack(spacing: 8) {
Text("Favorites")
Expand Down

0 comments on commit b3a78ec

Please sign in to comment.