Fix reblogs in iPad version
This commit is contained in:
parent
34c80c1f19
commit
e601a564d9
|
@ -1348,7 +1348,7 @@
|
|||
CODE_SIGN_ENTITLEMENTS = VernissageWidget/VernissageWidgetExtension.entitlements;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 255;
|
||||
CURRENT_PROJECT_VERSION = 256;
|
||||
DEVELOPMENT_TEAM = B2U9FEKYP8;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = VernissageWidget/Info.plist;
|
||||
|
@ -1379,7 +1379,7 @@
|
|||
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
|
||||
CODE_SIGN_ENTITLEMENTS = VernissageWidget/VernissageWidgetExtension.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 255;
|
||||
CURRENT_PROJECT_VERSION = 256;
|
||||
DEVELOPMENT_TEAM = B2U9FEKYP8;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = VernissageWidget/Info.plist;
|
||||
|
@ -1409,7 +1409,7 @@
|
|||
CODE_SIGN_ENTITLEMENTS = VernissageShare/VernissageShareExtension.entitlements;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 255;
|
||||
CURRENT_PROJECT_VERSION = 256;
|
||||
DEVELOPMENT_TEAM = B2U9FEKYP8;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = VernissageShare/Info.plist;
|
||||
|
@ -1438,7 +1438,7 @@
|
|||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = NO;
|
||||
CODE_SIGN_ENTITLEMENTS = VernissageShare/VernissageShareExtension.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 255;
|
||||
CURRENT_PROJECT_VERSION = 256;
|
||||
DEVELOPMENT_TEAM = B2U9FEKYP8;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = VernissageShare/Info.plist;
|
||||
|
@ -1592,7 +1592,7 @@
|
|||
CODE_SIGN_ENTITLEMENTS = Vernissage/Vernissage.entitlements;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 255;
|
||||
CURRENT_PROJECT_VERSION = 256;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = B2U9FEKYP8;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
|
@ -1635,7 +1635,7 @@
|
|||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_ENTITLEMENTS = Vernissage/Vernissage.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 255;
|
||||
CURRENT_PROJECT_VERSION = 256;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = B2U9FEKYP8;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
|
|
|
@ -81,7 +81,7 @@ struct PaginableStatusesView: View {
|
|||
private func list() -> some View {
|
||||
ScrollView {
|
||||
if self.imageColumns > 1 {
|
||||
WaterfallGrid($statusViewModels, columns: $imageColumns, hideLoadMore: $allItemsLoaded) { item in
|
||||
WaterfallGrid($statusViewModels, refreshId: Binding.constant(""), columns: $imageColumns, hideLoadMore: $allItemsLoaded) { item in
|
||||
ImageRowAsync(statusViewModel: item, containerWidth: $containerWidth)
|
||||
} onLoadMore: {
|
||||
do {
|
||||
|
|
|
@ -52,6 +52,7 @@ struct StatusesView: View {
|
|||
@State private var statusViewModels: [StatusModel] = []
|
||||
@State private var state: ViewState = .loading
|
||||
@State private var lastStatusId: String?
|
||||
@State private var waterfallId: String = String.randomString(length: 8)
|
||||
|
||||
// Gallery parameters.
|
||||
@State private var imageColumns = 3
|
||||
|
@ -96,7 +97,7 @@ struct StatusesView: View {
|
|||
private func list() -> some View {
|
||||
ScrollView {
|
||||
if self.imageColumns > 1 {
|
||||
WaterfallGrid($statusViewModels, columns: $imageColumns, hideLoadMore: $allItemsLoaded) { item in
|
||||
WaterfallGrid($statusViewModels, refreshId: $waterfallId, columns: $imageColumns, hideLoadMore: $allItemsLoaded) { item in
|
||||
ImageRowAsync(statusViewModel: item, containerWidth: $containerWidth)
|
||||
} onLoadMore: {
|
||||
do {
|
||||
|
@ -142,6 +143,17 @@ struct StatusesView: View {
|
|||
ErrorService.shared.handle(error, message: "statuses.error.loadingStatusesFailed", showToastr: !Task.isCancelled)
|
||||
}
|
||||
}
|
||||
.onChange(of: self.applicationState.showReboostedStatuses) { _ in
|
||||
if self.listType != .home {
|
||||
return
|
||||
}
|
||||
|
||||
Task { @MainActor in
|
||||
HapticService.shared.fireHaptic(of: .dataRefresh(intensity: 0.3))
|
||||
try await self.loadTopStatuses()
|
||||
HapticService.shared.fireHaptic(of: .dataRefresh(intensity: 0.7))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func loadData() async {
|
||||
|
@ -227,8 +239,12 @@ struct StatusesView: View {
|
|||
for item in statuses.getStatusesWithImagesOnly() {
|
||||
inPlaceStatuses.append(StatusModel(status: item))
|
||||
}
|
||||
|
||||
// Prefetch images.
|
||||
self.prefetch(statusModels: inPlaceStatuses)
|
||||
|
||||
// Replace old collection with new one.
|
||||
self.waterfallId = String.randomString(length: 8)
|
||||
self.statusViewModels = inPlaceStatuses
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ struct TrendStatusesView: View {
|
|||
NoDataView(imageSystemName: "photo.on.rectangle.angled", text: "trendingStatuses.title.noPhotos")
|
||||
} else {
|
||||
if self.imageColumns > 1 {
|
||||
WaterfallGrid($statusViewModels, columns: $imageColumns, hideLoadMore: Binding.constant(true)) { item in
|
||||
WaterfallGrid($statusViewModels, refreshId: Binding.constant(""), columns: $imageColumns, hideLoadMore: Binding.constant(true)) { item in
|
||||
ImageRowAsync(statusViewModel: item, containerWidth: $containerWidth)
|
||||
} onLoadMore: { }
|
||||
} else {
|
||||
|
|
|
@ -42,7 +42,7 @@ struct UserProfileStatusesView: View {
|
|||
var body: some View {
|
||||
if firstLoadFinished == true {
|
||||
if self.imageColumns > 1 {
|
||||
WaterfallGrid($statusViewModels, columns: $imageColumns, hideLoadMore: $allItemsLoaded) { item in
|
||||
WaterfallGrid($statusViewModels, refreshId: Binding.constant(""), columns: $imageColumns, hideLoadMore: $allItemsLoaded) { item in
|
||||
ImageRowAsync(statusViewModel: item, withAvatar: false, containerWidth: $containerWidth)
|
||||
} onLoadMore: {
|
||||
do {
|
||||
|
|
|
@ -13,11 +13,13 @@ struct WaterfallGrid<Data, ID, Content>: View where Data: RandomAccessCollection
|
|||
@Binding private var columns: Int
|
||||
@Binding private var hideLoadMore: Bool
|
||||
@Binding private var data: Data
|
||||
@Binding private var refreshId: String
|
||||
|
||||
private let content: (Data.Element) -> Content
|
||||
|
||||
@State private var columnsData: [ColumnData<Data.Element>] = []
|
||||
@State private var processedItems: [Data.Element.ID] = []
|
||||
@State private var shouldRecalculate = false
|
||||
|
||||
private let onLoadMore: () async -> Void
|
||||
private let semaphore = AsyncSemaphore(value: 1)
|
||||
|
@ -46,8 +48,16 @@ struct WaterfallGrid<Data, ID, Content>: View where Data: RandomAccessCollection
|
|||
.onFirstAppear {
|
||||
self.recalculateArrays()
|
||||
}
|
||||
.onChange(of: self.refreshId) { _ in
|
||||
self.shouldRecalculate = true
|
||||
}
|
||||
.onChange(of: self.data) { _ in
|
||||
self.appendToArrays()
|
||||
if self.shouldRecalculate {
|
||||
self.recalculateArrays()
|
||||
self.shouldRecalculate = false
|
||||
} else {
|
||||
self.appendToArrays()
|
||||
}
|
||||
}
|
||||
.onChange(of: self.columns) { _ in
|
||||
self.recalculateArrays()
|
||||
|
@ -113,25 +123,37 @@ struct WaterfallGrid<Data, ID, Content>: View where Data: RandomAccessCollection
|
|||
}
|
||||
|
||||
extension WaterfallGrid {
|
||||
init(_ data: Binding<Data>, id: KeyPath<Data.Element, ID>, columns: Binding<Int>,
|
||||
hideLoadMore: Binding<Bool>, content: @escaping (Data.Element) -> Content, onLoadMore: @escaping () async -> Void) {
|
||||
init(_ data: Binding<Data>,
|
||||
refreshId: Binding<String>,
|
||||
columns: Binding<Int>,
|
||||
hideLoadMore: Binding<Bool>,
|
||||
content: @escaping (Data.Element) -> Content,
|
||||
onLoadMore: @escaping () async -> Void) {
|
||||
|
||||
self.content = content
|
||||
self.onLoadMore = onLoadMore
|
||||
|
||||
self._data = data
|
||||
self._columns = columns
|
||||
self._hideLoadMore = hideLoadMore
|
||||
self._refreshId = refreshId
|
||||
}
|
||||
}
|
||||
|
||||
extension WaterfallGrid where ID == Data.Element.ID, Data.Element: Identifiable {
|
||||
init(_ data: Binding<Data>, columns: Binding<Int>,
|
||||
hideLoadMore: Binding<Bool>, content: @escaping (Data.Element) -> Content, onLoadMore: @escaping () async -> Void) {
|
||||
init(_ data: Binding<Data>,
|
||||
refreshId: Binding<String>,
|
||||
columns: Binding<Int>,
|
||||
hideLoadMore: Binding<Bool>,
|
||||
content: @escaping (Data.Element) -> Content,
|
||||
onLoadMore: @escaping () async -> Void) {
|
||||
|
||||
self.content = content
|
||||
self.onLoadMore = onLoadMore
|
||||
|
||||
self._data = data
|
||||
self._columns = columns
|
||||
self._hideLoadMore = hideLoadMore
|
||||
self._refreshId = refreshId
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue