Skip to content

Commit 744b81c

Browse files
levinli303claude
andcommitted
Make mainSetting a function that builds the section list itself
Convert the @mainactor let to func mainSetting(featureFlags:) so the notifications section can be inserted at the right slot — between advancedSettings and the trailing Celestia PLUS + misc sections — without the caller calculating settings.count - 2. The Catalyst / feature-flag gate now lives next to the insertion. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0a6a21c commit 744b81c

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

MobileCelestia/MainViewController.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,14 +1358,7 @@ Device Model: \(model)
13581358

13591359
@objc private func showSettings() {
13601360
let executor = self.executor
1361-
var settings = mainSetting
1362-
#if !targetEnvironment(macCatalyst)
1363-
if featureFlags.pushNotificationIOS {
1364-
// Insert just above the trailing Celestia PLUS + misc sections.
1365-
let insertIndex = max(0, settings.count - 2)
1366-
settings.insert(notificationsSettingSection, at: insertIndex)
1367-
}
1368-
#endif
1361+
let settings = mainSetting(featureFlags: featureFlags)
13691362
let controller = SettingsCoordinatorController(
13701363
core: core,
13711364
executor: executor,

MobileCelestia/Settings/SettingsModel.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ let notificationsSettingSection: SettingSection = SettingSection(
139139
)
140140

141141
@MainActor
142-
let mainSetting: [SettingSection] = {
142+
func mainSetting(featureFlags: FeatureFlags) -> [SettingSection] {
143143
var items = [
144144
displaySettings(),
145145
timeAndRegionSettings(),
@@ -171,7 +171,12 @@ let mainSetting: [SettingSection] = {
171171
]),
172172
advancedSettings(extraItems: advanceSettingExtraItems),
173173
]
174+
#if !targetEnvironment(macCatalyst)
175+
if featureFlags.pushNotificationIOS {
176+
items.append(notificationsSettingSection)
177+
}
178+
#endif
174179
items.append(celestiaPlusSettings())
175180
items.append(miscSettings())
176181
return items
177-
}()
182+
}

0 commit comments

Comments
 (0)