-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: Configurable essentials max fix conflict of PR 8441 #9189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+3,075
−74
Closed
Changes from 12 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
cd9ba2e
feat: Add config to support more than 12 essential tabs
blakegearin 6a8c7f9
Merge branch 'dev' into configurable-essentials-max
blakegearin 144d55e
Add dynamic getter
blakegearin 4a38fd8
Add overflow handling
blakegearin 6a280bd
Merge branch 'dev' into configurable-essentials-max
mr-cheffy 3126321
Merge branch 'dev' into configurable-essentials-max
blakegearin 8df6c41
Merge branch 'dev' into configurable-essentials-max
blakegearin 3137447
Merge branch 'dev' into configurable-essentials-max
blakegearin 98a2fc6
Fix merge conflict
blakegearin b99dc64
Merge branch 'dev' into configurable-essentials-max
MiraiDevv 895f075
Merge branch 'dev' into configurable-essentials-max
MiraiDevv d1df727
Merge branch 'dev' into configurable-essentials-max
MiraiDevv d74c582
Merge branch 'dev' into configurable-essentials-max
MiraiDevv 325b23d
fix: put an initial value in the space name
MiraiDevv 36bacbf
fix: Enhance pinned tabs resizing logic and workspace creation, inclu…
MiraiDevv aaf357a
Merge branch 'configurable-essentials-max' of https://github.com/Mira…
MiraiDevv c0f5759
Merge branch 'dev' into configurable-essentials-max
MiraiDevv fd50118
refactor: Remove essentials height preference and related logic from …
MiraiDevv f5b71dd
Merge branch 'configurable-essentials-max' of https://github.com/Mira…
MiraiDevv f132ba1
refactor: Remove the onPinnedTabsResize method to speed up workspace …
MiraiDevv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -311,6 +311,19 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { | |
} | ||
} | ||
|
||
onPinnedTabsResize() { | ||
for (const container of document.querySelectorAll('.zen-essentials-container')) { | ||
this._updateEssentialsOverflow(container); | ||
} | ||
for (let element of document.querySelectorAll('.zen-workspace-pinned-tabs-section')) { | ||
if (element.scrollHeight > element.clientHeight) { | ||
element.setAttribute('hide-separator', 'true'); | ||
} else { | ||
element.removeAttribute('hide-separator'); | ||
} | ||
} | ||
} | ||
|
||
_initializeEmptyTab() { | ||
this._emptyTab = gBrowser.addTrustedTab('about:blank', { | ||
inBackground: true, | ||
|
@@ -445,6 +458,17 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { | |
essentialsContainer.setAttribute('container', container); | ||
document.getElementById('zen-essentials').appendChild(essentialsContainer); | ||
|
||
this._updateEssentialsOverflow(essentialsContainer); | ||
|
||
essentialsContainer.addEventListener('scroll', () => { | ||
this._updateEssentialsOverflow(essentialsContainer); | ||
}); | ||
|
||
const resizeObserver = new ResizeObserver(() => { | ||
this._updateEssentialsOverflow(essentialsContainer); | ||
}); | ||
resizeObserver.observe(essentialsContainer); | ||
|
||
// Set an initial hidden state if the essentials section is not supposed | ||
// to be shown on the current workspace | ||
if ( | ||
|
@@ -457,6 +481,30 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { | |
return essentialsContainer; | ||
} | ||
|
||
_updateEssentialsOverflow(container) { | ||
const isOverflowing = container.scrollHeight > container.clientHeight; | ||
const isAtStart = container.scrollTop === 0; | ||
const isAtEnd = (container.scrollTop + container.clientHeight) >= (container.scrollHeight - 1); | ||
|
||
if (isOverflowing) { | ||
container.setAttribute('overflowing', 'true'); | ||
} else { | ||
container.removeAttribute('overflowing'); | ||
} | ||
|
||
if (isAtStart) { | ||
container.setAttribute('scrolledtostart', 'true'); | ||
} else { | ||
container.removeAttribute('scrolledtostart'); | ||
} | ||
|
||
if (isAtEnd) { | ||
container.setAttribute('scrolledtoend', 'true'); | ||
} else { | ||
container.removeAttribute('scrolledtoend'); | ||
} | ||
} | ||
|
||
getCurrentEssentialsContainer() { | ||
const currentWorkspace = this.getActiveWorkspaceFromCache(); | ||
return this.getEssentialsSection(currentWorkspace?.containerTabId); | ||
|
@@ -2254,56 +2302,30 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { | |
} | ||
|
||
async createAndSaveWorkspace( | ||
name = 'Space', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, why was a change done here |
||
icon = undefined, | ||
dontChange = false, | ||
name, | ||
|
||
icon, | ||
setActive = false, | ||
containerTabId = 0, | ||
{ beforeChangeCallback } = { beforeChangeCallback: null } // Callback to run before changing workspace | ||
{ beforeChangeCallback = null, afterChangeCallback = null } = {} | ||
) { | ||
if (!this.workspaceEnabled) { | ||
if (this.privateWindowOrDisabled) { | ||
return; | ||
} | ||
if (this.isPrivateWindow) { | ||
name = 'Private ' + name; | ||
} | ||
// get extra tabs remaning (e.g. on new profiles) and just move them to the new workspace | ||
const extraTabs = Array.from(gBrowser.tabContainer.arrowScrollbox.children).filter( | ||
(child) => | ||
child.tagName === 'tab' && | ||
!child.hasAttribute('zen-workspace-id') && | ||
!child.hasAttribute('zen-empty-tab') && | ||
!child.hasAttribute('zen-essential') | ||
); | ||
let workspaceData = await this._createWorkspaceData( | ||
name, | ||
icon, | ||
extraTabs, | ||
!dontChange, | ||
containerTabId | ||
); | ||
if (this.isPrivateWindow) { | ||
this._privateWorkspace = workspaceData; | ||
} else { | ||
await this.saveWorkspace(workspaceData, dontChange); | ||
} | ||
if (!dontChange) { | ||
const newWorkspace = await ZenWorkspacesStorage.createWorkspace(name, icon, containerTabId); | ||
await this._propagateWorkspaceData(); | ||
await this._createWorkspaceTabsSection(newWorkspace, []); | ||
this.registerPinnedResizeObserver(); | ||
if (setActive) { | ||
if (beforeChangeCallback) { | ||
try { | ||
await beforeChangeCallback(workspaceData); | ||
} catch (e) { | ||
console.error('Error in beforeChangeCallback:', e); | ||
} | ||
await beforeChangeCallback(newWorkspace); | ||
} | ||
this.registerPinnedResizeObserver(); | ||
let changed = extraTabs.length > 0; | ||
if (changed) { | ||
gBrowser.tabContainer._invalidateCachedTabs(); | ||
gBrowser.selectedTab = extraTabs[0]; | ||
await this.changeWorkspace(newWorkspace); | ||
if (afterChangeCallback) { | ||
await afterChangeCallback(); | ||
} | ||
await this.changeWorkspace(workspaceData); | ||
} | ||
this.onWindowResize(); | ||
return workspaceData; | ||
await this._updateWorkspacesChangeContextMenu(); | ||
return newWorkspace; | ||
} | ||
|
||
async updateTabsContainers(target = undefined, forAnimation = false) { | ||
|
@@ -2474,11 +2496,12 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { | |
|
||
// Context menu management | ||
async contextChangeContainerTab(event) { | ||
this._organizingWorkspaceStrip = true; | ||
let workspaces = await this._workspaces(); | ||
let workspace = workspaces.workspaces.find( | ||
(workspace) => workspace.uuid === (this.#contextMenuData?.workspaceId || this.activeWorkspace) | ||
); | ||
let workspace; | ||
if (this.#contextMenuData.workspaceId) { | ||
workspace = this.getWorkspaceFromId(this.#contextMenuData.workspaceId); | ||
} else { | ||
workspace = this.getActiveWorkspaceFromCache(); | ||
} | ||
let userContextId = parseInt(event.target.getAttribute('data-usercontextid')); | ||
workspace.containerTabId = userContextId + 0; // +0 to convert to number | ||
await this.saveWorkspace(workspace); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why sticky possition?