Skip to content

Commit

Permalink
Assign the coordinator delegate to the view model
Browse files Browse the repository at this point in the history
  • Loading branch information
Sophie Amin authored and Sophie Amin committed Nov 25, 2024
1 parent f27f864 commit c17e72d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class BookmarksCoordinator: BaseCoordinator,
viewModel.onBookmarkSaved = { [weak self] in
self?.reloadLastBookmarksController()
}
viewModel.bookmarkCoordinatorDelegate = self
setBackBarButtonItemTitle(viewModel.backNavigationButtonTitle())
let controller = EditBookmarkViewController(viewModel: viewModel,
windowUUID: windowUUID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ class EditBookmarkViewController: UIViewController,
guard let section = Section(rawValue: indexPath.section) else { return }
if section == .folder, let folder = viewModel.folderStructures[safe: indexPath.row] {
viewModel.selectFolder(folder)
}
else if section == .newFolder {
} else if section == .newFolder {
viewModel.createNewFolder()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class EditBookmarkViewModel {
private let profile: Profile
private let folderFetcher: FolderHierarchyFetcher
private let bookmarksSaver: BookmarksSaver
weak var bookmarkCoordinatorDelegate: BookmarksCoordinatorDelegate?

private var isFolderCollapsed = true
private(set) var folderStructures: [Folder] = []
Expand Down Expand Up @@ -68,7 +69,9 @@ class EditBookmarkViewModel {
}

func createNewFolder() {

self.bookmarkCoordinatorDelegate?.showBookmarkDetail(
bookmarkType: .folder,
parentBookmarkFolder: parentFolder)
}

private func getFolderStructure(_ selectedFolder: Folder) {
Expand Down

0 comments on commit c17e72d

Please sign in to comment.