Skip to content

Conversation

@Brooksolomon
Copy link
Collaborator

@Brooksolomon Brooksolomon commented Sep 28, 2025

Changes in Detail

  1. API Change: openTab Method
    The signature of the openTab method has been modified to provide better utility to its callers:

Before: openTab(...) -> Void

After: openTab(...) -> Tab?

This allows the caller of openTab to immediately access and utilize the newly created Tab object (or nil if tab creation fails) without relying on external accessors or delegates.

  1. Simplification: duplicateTab Method
    The logic within the duplicateTab method has been simplified by leveraging the updated openTab method, resulting in cleaner and more concise code. This change reduces complexity and makes the duplication process easier to maintain.

}
}

func duplicateTab(_ tab: Tab) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this method could be simpler. it’s doing too much. There is already an open tab method that can be used to achive the same effect. Rearranging the tab position can also use the drag method that already is capable of inserting a tab at a specific positiion. Please try to reuse the existing methods.

@kenenisa
Copy link
Contributor

Lint is failing too please address it

self.lastAccessedAt = nowDate
}

func reorderTabs(from: Tab, to: Tab) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the need for modifiying this method?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old implementation attempts to achieve the new order solely by a series of property swaps, which is unnecessarily complicated and risky. The new approach directly manipulates the array structure to achieve the final order, making the logic much clearer and less prone to off-by-one errors.Highly faster as well The work is consistent: O(N) to re-assign the order values, regardless of how far the tab moves.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really faster or cleaner. using insert and remove at index shifts the entire array twice plus reassigning the order - itrates over the entire list 3 times plus finding the index of from and to tab also goes over the list. so the method now is going over the list 5 times instead of just once in the prev case, which also stops if the swaping is complete using the break.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returned the Reorder function back to the original

Comment on lines 54 to 80

private func isInSameSection(from: Tab, to: Tab) -> Bool {
return from.type == to.type
}

private func moveTabBetweenSections(from: Tab, to: Tab) {
// Change the tab type to match the target section
from.type = to.type

// If moving to pinned or fav, save the URL
if to.type == .pinned || to.type == .fav {
from.savedURL = from.url
} else {
from.savedURL = nil
}
}

private func tabType(for section: TabSection) -> TabType {
switch section {
case .fav:
return .fav
case .pinned:
return .pinned
case .normal:
return .normal
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TabUtils already has these methods, why the need to rewrite them here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the duplicated function and used the one in Tab utils

Comment on lines 73 to 92

private func isInSameSection(from: Tab, to: Tab) -> Bool {
return from.type == to.type
}

private func moveTabBetweenSections(from: Tab, to: Tab) {
// Change the tab type to match the target section
from.type = to.type

// If moving to pinned or fav, save the URL
if to.type == .pinned || to.type == .fav {
from.savedURL = from.url
} else {
from.savedURL = nil
}

// Reorder the tabs in the new section
from.container.reorderTabs(from: from, to: to)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, repeated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the duplicated function and used the one in Tab utils

Copy link
Contributor

@kenenisa kenenisa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The duplicated tab doesn’t load it needs to be clicked please call restoreTransientState method on it so it can load properly
  • The order the duplicate tab is inserted is kind of weird please look into it. Ideally it should show up under the original tab
  • The duplicate tab doesn’t work on dormat/inactive tabs so either we should make the option disabled or the function should actually work

kenenisa and others added 3 commits October 13, 2025 20:40
…ntly' parameter to the tab opening method, allowing for silent initialization of web views based on user preferences.
@kenenisa kenenisa merged commit 16dce77 into main Oct 13, 2025
2 checks passed
kenenisa added a commit that referenced this pull request Oct 14, 2025
* added duplication feature

* fix : added calculation logic

* fix : drag and reorder issue when duplicate tabs are located

* fix : duplicate appears below duplicated tab instead of last

* fix : fixed merge conflicts with main

* fix : refactored duplicate method to use existing functions

* fix : refactored open tab to return the tab and reordered the tabs when new tab is created using duplicate

* fix : removed duplicate functions

* fixed the reorder tab issue

* Enhance TabManager to support silent loading of tabs. Added 'loadSilently' parameter to the tab opening method, allowing for silent initialization of web views based on user preferences.

* feat : added is alive check when duplicating tab to check if the tab is dormant or not

* feat : replaced is alive check with is web view ready

---------

Co-authored-by: Kenenisa Alemayehu <[email protected]>
@yonaries yonaries deleted the feature/duplicate-tab branch October 29, 2025 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants