From ecd6d6829a82b76049a766ea2c71d4394ca96e4a Mon Sep 17 00:00:00 2001 From: Sam Symons Date: Mon, 21 Feb 2022 14:04:17 -0800 Subject: [PATCH] Avoid the default empty state appearing at unexpected times. --- .../Model/PasswordManagementItemListModel.swift | 10 ++++++++++ .../View/PasswordManagementViewController.swift | 4 +--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/DuckDuckGo/SecureVault/Model/PasswordManagementItemListModel.swift b/DuckDuckGo/SecureVault/Model/PasswordManagementItemListModel.swift index 1c97e219fd..0cdf270717 100644 --- a/DuckDuckGo/SecureVault/Model/PasswordManagementItemListModel.swift +++ b/DuckDuckGo/SecureVault/Model/PasswordManagementItemListModel.swift @@ -359,6 +359,16 @@ final class PasswordManagementItemListModel: ObservableObject { selected(item: nil) } } + + func clear() { + update(items: []) + filter = "" + clearSelection() + + // Setting items to an empty array will typically show the No Data empty state, but this call is used when + // the popover is closed so instead there should be no empty state. + emptyState = .none + } func clearSelection() { selected = nil diff --git a/DuckDuckGo/SecureVault/View/PasswordManagementViewController.swift b/DuckDuckGo/SecureVault/View/PasswordManagementViewController.swift index f30e2f142c..94da960d6b 100644 --- a/DuckDuckGo/SecureVault/View/PasswordManagementViewController.swift +++ b/DuckDuckGo/SecureVault/View/PasswordManagementViewController.swift @@ -163,9 +163,7 @@ final class PasswordManagementViewController: NSViewController { } func clear() { - self.listModel?.update(items: []) - self.listModel?.filter = "" - self.listModel?.clearSelection() + self.listModel?.clear() self.itemModel?.clearSecureVaultModel() }