iOS client for Grain grain.social
ios photography atproto
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: remove redundant await from auth.authContext() calls

+20 -20
+2 -2
Grain/Views/Components/ReportView.swift
··· 80 80 81 81 private func loadLabels() async { 82 82 do { 83 - labelDefs = try await client.describeLabels(auth: await auth.authContext()) 83 + labelDefs = try await client.describeLabels(auth: auth.authContext()) 84 84 if let first = labelDefs.first { 85 85 selectedLabel = first.identifier 86 86 } ··· 99 99 subjectCid: subjectCid, 100 100 label: selectedLabel, 101 101 reason: reason.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty ? nil : reason.trimmingCharacters(in: .whitespacesAndNewlines), 102 - auth: await auth.authContext() 102 + auth: auth.authContext() 103 103 ) 104 104 isSubmitted = true 105 105 } catch {
+5 -5
Grain/Views/Feed/HashtagFeedView.swift
··· 112 112 private func loadInitial() async { 113 113 isLoading = true 114 114 do { 115 - let response = try await client.getFeed(feed: "hashtag", tag: tag, auth: await auth.authContext()) 115 + let response = try await client.getFeed(feed: "hashtag", tag: tag, auth: auth.authContext()) 116 116 galleries = response.items ?? [] 117 117 cursor = response.cursor 118 118 } catch {} ··· 123 123 guard !isLoading, let cursor else { return } 124 124 isLoading = true 125 125 do { 126 - let response = try await client.getFeed(feed: "hashtag", cursor: cursor, tag: tag, auth: await auth.authContext()) 126 + let response = try await client.getFeed(feed: "hashtag", cursor: cursor, tag: tag, auth: auth.authContext()) 127 127 galleries.append(contentsOf: response.items ?? []) 128 128 self.cursor = response.cursor 129 129 } catch {} ··· 132 132 133 133 private func checkPinned() async { 134 134 do { 135 - let response = try await client.getPreferences(auth: await auth.authContext()) 135 + let response = try await client.getPreferences(auth: auth.authContext()) 136 136 isPinned = response.preferences.pinnedFeeds?.contains(where: { $0.id == feedId }) ?? false 137 137 } catch {} 138 138 } 139 139 140 140 private func togglePin() async { 141 141 do { 142 - let response = try await client.getPreferences(auth: await auth.authContext()) 142 + let response = try await client.getPreferences(auth: auth.authContext()) 143 143 var feeds = response.preferences.pinnedFeeds ?? PinnedFeed.defaults 144 144 if isPinned { 145 145 feeds.removeAll { $0.id == feedId } 146 146 } else { 147 147 feeds.append(PinnedFeed(id: feedId, label: tag, type: "hashtag", path: "/hashtags/\(tag)")) 148 148 } 149 - try await client.putPinnedFeeds(feeds, auth: await auth.authContext()) 149 + try await client.putPinnedFeeds(feeds, auth: auth.authContext()) 150 150 isPinned.toggle() 151 151 } catch {} 152 152 }
+5 -5
Grain/Views/Feed/LocationFeedView.swift
··· 140 140 private func loadInitial() async { 141 141 isLoading = true 142 142 do { 143 - let response = try await client.getFeed(feed: "location", location: h3Index, auth: await auth.authContext()) 143 + let response = try await client.getFeed(feed: "location", location: h3Index, auth: auth.authContext()) 144 144 galleries = response.items ?? [] 145 145 cursor = response.cursor 146 146 } catch {} ··· 151 151 guard !isLoading, let cursor else { return } 152 152 isLoading = true 153 153 do { 154 - let response = try await client.getFeed(feed: "location", cursor: cursor, location: h3Index, auth: await auth.authContext()) 154 + let response = try await client.getFeed(feed: "location", cursor: cursor, location: h3Index, auth: auth.authContext()) 155 155 galleries.append(contentsOf: response.items ?? []) 156 156 self.cursor = response.cursor 157 157 } catch {} ··· 160 160 161 161 private func checkPinned() async { 162 162 do { 163 - let response = try await client.getPreferences(auth: await auth.authContext()) 163 + let response = try await client.getPreferences(auth: auth.authContext()) 164 164 isPinned = response.preferences.pinnedFeeds?.contains(where: { $0.id == feedId }) ?? false 165 165 } catch {} 166 166 } 167 167 168 168 private func togglePin() async { 169 169 do { 170 - let response = try await client.getPreferences(auth: await auth.authContext()) 170 + let response = try await client.getPreferences(auth: auth.authContext()) 171 171 var feeds = response.preferences.pinnedFeeds ?? PinnedFeed.defaults 172 172 if isPinned { 173 173 feeds.removeAll { $0.id == feedId } 174 174 } else { 175 175 feeds.append(PinnedFeed(id: feedId, label: locationName, type: "location", path: "/location/\(h3Index)")) 176 176 } 177 - try await client.putPinnedFeeds(feeds, auth: await auth.authContext()) 177 + try await client.putPinnedFeeds(feeds, auth: auth.authContext()) 178 178 isPinned.toggle() 179 179 } catch {} 180 180 }
+5 -5
Grain/Views/Profile/FollowListView.swift
··· 152 152 do { 153 153 switch mode { 154 154 case .followers: 155 - let response = try await client.getFollowers(actor: did, viewer: auth.userDID, cursor: nil, auth: await auth.authContext()) 155 + let response = try await client.getFollowers(actor: did, viewer: auth.userDID, cursor: nil, auth: auth.authContext()) 156 156 items = (response.items ?? []).map { FollowListItem(from: $0) } 157 157 cursor = response.cursor 158 158 totalCount = response.totalCount 159 159 case .following: 160 - let response = try await client.getFollowing(actor: did, viewer: auth.userDID, cursor: nil, auth: await auth.authContext()) 160 + let response = try await client.getFollowing(actor: did, viewer: auth.userDID, cursor: nil, auth: auth.authContext()) 161 161 items = (response.items ?? []).map { FollowListItem(from: $0) } 162 162 cursor = response.cursor 163 163 totalCount = response.totalCount 164 164 case .knownFollowers: 165 165 if let viewer = auth.userDID { 166 - let response = try await client.getKnownFollowers(actor: did, viewer: viewer, auth: await auth.authContext()) 166 + let response = try await client.getKnownFollowers(actor: did, viewer: viewer, auth: auth.authContext()) 167 167 items = (response.items ?? []).map { FollowListItem(from: $0) } 168 168 totalCount = items.count 169 169 } ··· 184 184 let existingIDs = Set(items.map(\.id)) 185 185 switch mode { 186 186 case .followers: 187 - let response = try await client.getFollowers(actor: did, viewer: auth.userDID, cursor: cursor, auth: await auth.authContext()) 187 + let response = try await client.getFollowers(actor: did, viewer: auth.userDID, cursor: cursor, auth: auth.authContext()) 188 188 if let newItems = response.items { 189 189 let filtered = newItems.filter { !existingIDs.contains($0.did) } 190 190 items.append(contentsOf: filtered.map { FollowListItem(from: $0) }) 191 191 } 192 192 cursor = response.cursor 193 193 case .following: 194 - let response = try await client.getFollowing(actor: did, viewer: auth.userDID, cursor: cursor, auth: await auth.authContext()) 194 + let response = try await client.getFollowing(actor: did, viewer: auth.userDID, cursor: cursor, auth: auth.authContext()) 195 195 if let newItems = response.items { 196 196 let filtered = newItems.filter { !existingIDs.contains($0.did) } 197 197 items.append(contentsOf: filtered.map { FollowListItem(from: $0) })
+3 -3
Grain/Views/Search/SearchView.swift
··· 94 94 } 95 95 .onSubmit(of: .search) { 96 96 recentSearches.addTextSearch(searchText) 97 - Task { await viewModel.search(auth: await auth.authContext()) } 97 + Task { await viewModel.search(auth: auth.authContext()) } 98 98 } 99 99 .onChange(of: searchText) { 100 100 viewModel.searchText = searchText 101 101 } 102 102 .onChange(of: viewModel.selectedTab) { 103 103 if !viewModel.searchText.isEmpty { 104 - Task { await viewModel.search(auth: await auth.authContext()) } 104 + Task { await viewModel.search(auth: auth.authContext()) } 105 105 } 106 106 } 107 107 .navigationDestination(item: $searchNavigationUri) { uri in ··· 192 192 searchText = recent.query 193 193 viewModel.searchText = recent.query 194 194 searchIsPresented = true 195 - Task { await viewModel.search(auth: await auth.authContext()) } 195 + Task { await viewModel.search(auth: auth.authContext()) } 196 196 } 197 197 } 198 198 }