From 2ba92a074e8c6f606dd04ec949a7ff648d4a7e7d Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Thu, 31 Aug 2023 11:16:41 +0300 Subject: [PATCH] Remove the visible room computation bounds padding to reduce bandwidth --- .../Sources/Screens/HomeScreen/View/HomeScreen.swift | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift index 22c1a27a9..6f5888c22 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift @@ -20,10 +20,6 @@ import SwiftUI import SwiftUIIntrospect struct HomeScreen: View { - enum Constants { - static let slidingWindowBoundsPadding = 5 - } - @ObservedObject var context: HomeScreenViewModel.Context @State private var scrollViewAdapter = ScrollViewAdapter() @@ -205,12 +201,8 @@ struct HomeScreen: View { let firstIndex = Int(max(0.0, scrollView.contentOffset.y + scrollView.contentInset.top) / cellHeight) let lastIndex = Int(max(0.0, scrollView.contentOffset.y + scrollView.bounds.height) / cellHeight) - // Add some extra padding just to be on the safe side - let lowerBound = max(0, firstIndex - Constants.slidingWindowBoundsPadding) - let upperBound = min(Int(context.viewState.rooms.count), lastIndex + Constants.slidingWindowBoundsPadding) - // This will be deduped and throttled on the view model layer - context.send(viewAction: .updateVisibleItemRange(range: lowerBound..