From 5e9ee9e5cf6375a025e8a117f679e116b003f7f0 Mon Sep 17 00:00:00 2001 From: Hermes Date: Thu, 13 Aug 2026 16:00:32 +0000 Subject: [PATCH] Prevent duplicate approve reviews + redesign bottom bar; bump to 2.9 - Approve: rapid taps fired multiple submitReview calls that each appended a review, stacking duplicate entries. Add a busy guard (skip while one is in flight) and dedupe reviews per user so the latest replaces earlier ones; disable the review menu while submitting. - Bottom bar: replace the full-width bar with a floating frosted-glass pill inset from the edges (like SideStore), with a highlighted capsule behind the active tab. Bump to 2.9. --- GiteaPR.xcodeproj/project.pbxproj | 8 +++--- GiteaPR/Detail/PRDetailView.swift | 38 +++++++++++++++++++------- GiteaPR/Detail/PRDetailViewModel.swift | 8 ++++++ 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/GiteaPR.xcodeproj/project.pbxproj b/GiteaPR.xcodeproj/project.pbxproj index 744d8b5..d0f6dc6 100644 --- a/GiteaPR.xcodeproj/project.pbxproj +++ b/GiteaPR.xcodeproj/project.pbxproj @@ -187,7 +187,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 19; + CURRENT_PROJECT_VERSION = 20; DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_CFBundleDisplayName = "GiteaPR"; @@ -197,7 +197,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.8; + MARKETING_VERSION = 2.9; PRODUCT_BUNDLE_IDENTIFIER = com.bueso.giteapr; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -211,7 +211,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 19; + CURRENT_PROJECT_VERSION = 20; DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_CFBundleDisplayName = "GiteaPR"; @@ -221,7 +221,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.8; + MARKETING_VERSION = 2.9; PRODUCT_BUNDLE_IDENTIFIER = com.bueso.giteapr; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/GiteaPR/Detail/PRDetailView.swift b/GiteaPR/Detail/PRDetailView.swift index e26aacf..255a782 100644 --- a/GiteaPR/Detail/PRDetailView.swift +++ b/GiteaPR/Detail/PRDetailView.swift @@ -102,7 +102,11 @@ struct PRDetailView: View { .toolbar { if prIsOpen { ToolbarItem(placement: .primaryAction) { mergeButton } - ToolbarItem(placement: .primaryAction) { reviewMenu } + ToolbarItem(placement: .primaryAction) { + // Disable while a review submission is in flight so rapid + // taps can't stack duplicate reviews. + reviewMenu.disabled(vm.busyMessage != nil) + } } } } @@ -130,29 +134,43 @@ struct PRDetailView: View { .background(Color(.secondarySystemBackground)) } - /// Bottom tab bar: full-width frosted-glass bar at the standard iOS tab - /// bar height, sitting flush above the home indicator — matching Apple - /// Music's tab bar (not a floating capsule with space below it). + /// Bottom tab bar: a floating, frosted-glass pill inset from the screen + /// edges (like the SideStore tab bar), with a highlighted capsule behind + /// the active tab. Icon + text per tab. private var bottomTabBar: some View { - HStack { + HStack(spacing: 4) { ForEach(DetailTab.allCases) { tab in Button { selectedTab = tab } label: { VStack(spacing: 2) { Image(systemName: tab.icon) - .font(.system(size: 22)) + .font(.system(size: 20, weight: .medium)) Text(tab.rawValue) - .font(.caption2) + .font(.caption2.weight(.medium)) } .foregroundColor(selectedTab == tab ? .accentColor : .secondary) .frame(maxWidth: .infinity) + .padding(.vertical, 6) + .background( + selectedTab == tab + ? AnyShapeStyle(.ultraThinMaterial) + : AnyShapeStyle(.clear) + ) + .clipShape(Capsule()) } + .buttonStyle(.plain) } } - .padding(.top, 8) - .padding(.bottom, 4) - .background(.bar) + .padding(.horizontal, 6) + .padding(.vertical, 6) + .background( + Capsule() + .fill(.regularMaterial) + .shadow(color: .black.opacity(0.15), radius: 10, y: 4) + ) + .padding(.horizontal, 20) + .padding(.bottom, 8) } private var reviewMenu: some View { diff --git a/GiteaPR/Detail/PRDetailViewModel.swift b/GiteaPR/Detail/PRDetailViewModel.swift index 186293b..a0c640c 100644 --- a/GiteaPR/Detail/PRDetailViewModel.swift +++ b/GiteaPR/Detail/PRDetailViewModel.swift @@ -113,12 +113,20 @@ final class PRDetailViewModel: ObservableObject { func submitReview(state: String, comment: String?) async { guard let client = SettingsStore.shared.client() else { return } + // Guard against concurrent submissions: rapid taps on Approve used to + // fire several requests that each appended a review, stacking + // duplicate entries. Skip if one is already in flight. + guard busyMessage == nil else { return } busyMessage = "Submitting…" defer { busyMessage = nil } do { let r = try await client.submitReview(owner: owner, repo: repo.name, number: prNumber, state: state, comment: comment) + // A user's latest review replaces their earlier ones (Gitea stores + // one review per user per PR). Drop any prior review by this user + // so we don't render duplicates. + reviews.removeAll { $0.user?.login == r.user?.login } reviews.append(r) } catch { errorMessage = error.localizedDescription