fix(swift-ios): preserve pin and legacy picker state
This commit is contained in:
3 files changed
+30
-5
No files matched your search
@@ -302,9 +302,11 @@ public final class FeatureRootModel {
|
||||
mutateThread(id: id) {
|
||||
$0.pinnedAt = pinned ? Date.now : nil
|
||||
if pinned {
|
||||
$0.isSettled = false
|
||||
$0.keepsActive = true
|
||||
$0.settledAt = nil
|
||||
if $0.isSettled {
|
||||
$0.isSettled = false
|
||||
$0.keepsActive = true
|
||||
$0.settledAt = nil
|
||||
}
|
||||
$0.snoozedUntil = nil
|
||||
$0.snoozedAt = nil
|
||||
}
|
||||
|
||||
@@ -212,6 +212,7 @@ private struct ModelPickerSheet: View {
|
||||
.preferredColorScheme(.dark)
|
||||
.onAppear(perform: revealSelectedLegacyModel)
|
||||
.onChange(of: selection) { revealSelectedLegacyModel() }
|
||||
.onChange(of: providers) { revealSelectedLegacyModel() }
|
||||
}
|
||||
|
||||
private var modelList: some View {
|
||||
@@ -372,10 +373,12 @@ private struct ModelPickerSheet: View {
|
||||
}
|
||||
|
||||
private func revealSelectedLegacyModel() {
|
||||
guard let resolvedSelection else { return }
|
||||
legacyModelsExpanded = displaySections.legacy.contains {
|
||||
guard !legacyModelsExpanded, let resolvedSelection else { return }
|
||||
if displaySections.legacy.contains(where: {
|
||||
$0.provider.id == resolvedSelection.providerID
|
||||
&& $0.model.id == resolvedSelection.modelID
|
||||
}) {
|
||||
legacyModelsExpanded = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -637,6 +637,26 @@ struct FeatureRootModelTests {
|
||||
#expect(updated.snoozedUntil == nil)
|
||||
}
|
||||
|
||||
@Test
|
||||
func testPinDoesNotMakeAnOrdinaryThreadPermanentlyActive() async {
|
||||
let client = FeatureClientStub()
|
||||
let thread = FeatureThread(
|
||||
id: "thread-1",
|
||||
projectID: "project-1",
|
||||
title: "Thread"
|
||||
)
|
||||
client.createdThread = thread
|
||||
let model = testRootModel(client: client)
|
||||
_ = await model.createThread(projectID: thread.projectID, title: nil, selection: nil)
|
||||
|
||||
await model.setPinned(thread.id, pinned: true)
|
||||
await model.setPinned(thread.id, pinned: false)
|
||||
|
||||
let updated = model.snapshot.threads[0]
|
||||
#expect(updated.pinnedAt == nil)
|
||||
#expect(!updated.keepsActive)
|
||||
}
|
||||
|
||||
@Test
|
||||
func testResolveUserInputForwardsTypedAnswersAndClearsTheRequest() async {
|
||||
let client = FeatureClientStub()
|
||||
|
||||
Reference in new issue
Block a user