diff --git a/Shared/Views/Tab/Profile/ProfileContentGrid.swift b/Shared/Views/Tab/Profile/ProfileContentGrid.swift index 804e4d4..b16668e 100644 --- a/Shared/Views/Tab/Profile/ProfileContentGrid.swift +++ b/Shared/Views/Tab/Profile/ProfileContentGrid.swift @@ -6,9 +6,9 @@ struct ProfileContentGrid: View { let selectedTabIndex: Int let searchQuery: String let selectedCategory: String - @State private var allPosts: [Post] = [] + let allPosts: [Post] + let isLoading: Bool @State private var selectedPostID: PostIDWrapper? = nil - @State private var isLoading = true var body: some View { VStack(alignment: .leading, spacing: 0) { @@ -87,17 +87,6 @@ struct ProfileContentGrid: View { } } .frame(maxWidth: .infinity, alignment: .topLeading) - .onAppear { -// guard isContentLoaded else { return } - - if allPosts.isEmpty { - isLoading = true - PostService.shared.fetchAllPosts { result in - self.allPosts = result - self.isLoading = false - } - } - } .fullScreenCover(item: $selectedPostID) { wrapper in PostDetailView(postID: wrapper.id) } diff --git a/Shared/Views/Tab/Profile/ProfileContentTabbedGrid.swift b/Shared/Views/Tab/Profile/ProfileContentTabbedGrid.swift index 2d574ba..61ff4b4 100644 --- a/Shared/Views/Tab/Profile/ProfileContentTabbedGrid.swift +++ b/Shared/Views/Tab/Profile/ProfileContentTabbedGrid.swift @@ -6,6 +6,8 @@ struct ProfileContentTabbedGrid: View { @State private var selectedCategory = "#все" @State private var searchQuery = "" @State private var selectedSort = "По дате" + @State private var allPosts: [Post] = [] + @State private var isLoading = true var body: some View { VStack(spacing: 0) { @@ -68,14 +70,24 @@ struct ProfileContentTabbedGrid: View { isContentLoaded: isContentLoaded, selectedTabIndex: index, searchQuery: searchQuery, - selectedCategory: selectedCategory + selectedCategory: selectedCategory, + allPosts: allPosts, + isLoading: isLoading ) -// .frame(maxWidth: .infinity, minHeight: 10) .tag(index) } } .tabViewStyle(PageTabViewStyle(indexDisplayMode: .never)) } + .onAppear { + if allPosts.isEmpty { + isLoading = true + PostService.shared.fetchAllPosts { result in + self.allPosts = result + self.isLoading = false + } + } + } } // MARK: - Вкладка с меню