Skip to content

Commit

Permalink
fix stuttering on profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
ejbills committed Jan 9, 2024
1 parent 43058e3 commit 3db4089
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 23 deletions.
Binary file not shown.
29 changes: 8 additions & 21 deletions OpenArtemis/Views/Profiles/ProfileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,16 @@ struct ProfileView: View {
readPosts: readPosts,
savedPosts: savedPosts,
savedComments: savedComments,
appTheme: appTheme,
onListElementAppearance: { media in
handleMediaAppearance(MiscUtils.extractMediaId(from: media))
}
appTheme: appTheme
)

Rectangle()
.fill(Color.clear)
.frame(height: 1)
.onAppear {
scrapeProfile(lastPostAfter, sort: filterType)
}

if isLoading { // show spinner at the bottom of the feed
HStack {
Spacer()
Expand Down Expand Up @@ -124,21 +128,4 @@ struct ProfileView: View {

scrapeProfile()
}

private func handleMediaAppearance(_ mediaId: String) {
guard mixedMedia.count > 0 else {
return
}

let index = Int(Double(mixedMedia.count) * 0.85)
guard index < mixedMedia.count else {
return
}

let tempMediaId = MiscUtils.extractMediaId(from: mixedMedia[index])

if mediaId == tempMediaId {
scrapeProfile(lastPostAfter, sort: filterType)
}
}
}
2 changes: 1 addition & 1 deletion OpenArtemis/Views/Search/SearchView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct SearchView: View {
readPosts: readPosts,
savedPosts: savedPosts,
appTheme: appTheme,
preventDivider: true
preventDivider: isSubredditSearch
)
}
} else {
Expand Down
3 changes: 2 additions & 1 deletion OpenArtemis/Views/Subreddits/SubredditFeedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ struct SubredditFeedView: View {
.refreshable {
clearFeedAndReload()
}
.onChange(of: subredditName) { _, _ in // this handles a navsplitview edge case where swiftui reuses the initial view from the sidebar selection.
.onChange(of: subredditName) { _, _ in // this handles a navsplitview edge case where swiftui
// reuses the initial view from the sidebar selection.
clearFeedAndReload()
}
.searchable(text: $searchTerm, prompt: "Search r/\((titleOverride != nil) ? titleOverride! : subredditName)")
Expand Down
1 change: 1 addition & 0 deletions OpenArtemis/Views/Themes/Theme Wrappers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct ThemedList<Content: View>: View {
.listRowSeparator(.hidden)
}
.scrollContentBackground(.hidden)
.listStyle(.plain)
.environment(\.defaultMinListRowHeight, 0)
} else {
List {
Expand Down

0 comments on commit 3db4089

Please sign in to comment.