|
437 | 437 | async _removePinnedAttributes(tab, isClosing = false) {
|
438 | 438 | tab.removeAttribute('zen-has-static-label');
|
439 | 439 | if (!tab.getAttribute('zen-pin-id') || this._temporarilyUnpiningEssential) {
|
440 |
| - this._temporarilyUnpiningEssential = false; |
441 | 440 | return;
|
442 | 441 | }
|
443 | 442 |
|
|
587 | 586 | const tabs = tab ? [tab] : TabContextMenu.contextTab.multiselected ? gBrowser.selectedTabs : [TabContextMenu.contextTab];
|
588 | 587 | for (let i = 0; i < tabs.length; i++) {
|
589 | 588 | const tab = tabs[i];
|
| 589 | + if (tab.hasAttribute('zen-essential')) { |
| 590 | + continue; |
| 591 | + } |
590 | 592 | tab.setAttribute('zen-essential', 'true');
|
591 | 593 | if (tab.hasAttribute('zen-workspace-id')) {
|
592 | 594 | tab.removeAttribute('zen-workspace-id');
|
593 | 595 | }
|
594 |
| - if (tab.pinned) { |
595 |
| - this._temporarilyUnpiningEssential = true; |
596 |
| - gBrowser.unpinTab(tab); |
| 596 | + if (tab.pinned && tab.hasAttribute('zen-pin-id')) { |
| 597 | + const pin = this._pinsCache.find((pin) => pin.uuid === tab.getAttribute('zen-pin-id')); |
| 598 | + if (pin) { |
| 599 | + pin.isEssential = true; |
| 600 | + ZenPinnedTabsStorage.savePin(pin); |
| 601 | + } |
| 602 | + document.getElementById('zen-essentials-container').appendChild(tab); |
| 603 | + gBrowser.tabContainer._invalidateCachedTabs(); |
| 604 | + } else { |
| 605 | + gBrowser.pinTab(tab); |
597 | 606 | }
|
598 |
| - gBrowser.pinTab(tab); |
599 |
| - this.resetPinChangedUrl(tab); |
600 | 607 | this.onTabIconChanged(tab);
|
601 | 608 | this._onTabMove(tab);
|
602 | 609 | }
|
603 | 610 | gZenUIManager.updateTabsToolbar();
|
604 | 611 | }
|
605 | 612 |
|
606 |
| - removeEssentials(tab) { |
| 613 | + removeEssentials(tab, unpin = true) { |
607 | 614 | const tabs = tab ? [tab] : TabContextMenu.contextTab.multiselected ? gBrowser.selectedTabs : [TabContextMenu.contextTab];
|
608 | 615 | for (let i = 0; i < tabs.length; i++) {
|
609 | 616 | const tab = tabs[i];
|
610 | 617 | tab.removeAttribute('zen-essential');
|
611 | 618 | if (ZenWorkspaces.workspaceEnabled && ZenWorkspaces.getActiveWorkspaceFromCache.uuid) {
|
612 | 619 | tab.setAttribute('zen-workspace-id', ZenWorkspaces.getActiveWorkspaceFromCache.uuid);
|
613 | 620 | }
|
614 |
| - gBrowser.unpinTab(tab); |
| 621 | + if (unpin) { |
| 622 | + gBrowser.unpinTab(tab); |
| 623 | + } else { |
| 624 | + const pinContainer = ZenWorkspaces.pinnedTabsContainer; |
| 625 | + pinContainer.prepend(tab); |
| 626 | + gBrowser.tabContainer._invalidateCachedTabs(); |
| 627 | + this._onTabMove(tab); |
| 628 | + } |
615 | 629 | }
|
616 | 630 | gZenUIManager.updateTabsToolbar();
|
617 | 631 | }
|
|
685 | 699 | gBrowser.pinTab(draggedTab);
|
686 | 700 | moved = true;
|
687 | 701 | } else if (draggedTab.hasAttribute('zen-essential')) {
|
688 |
| - this.removeEssentials(draggedTab); |
689 |
| - gBrowser.pinTab(draggedTab); |
| 702 | + this.removeEssentials(draggedTab, false); |
690 | 703 | moved = true;
|
691 | 704 | }
|
692 | 705 | }
|
|
0 commit comments