-
Notifications
You must be signed in to change notification settings - Fork 22.5k
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
Add contextualIdentities.move #31191
Conversation
Preview URLs
Flaws (1)Note! 2 documents with no flaws that don't need to be listed. 🎉 URL:
External URLs (1)URL:
(comment last updated: 2024-01-05 16:56:57) |
files/en-us/mozilla/add-ons/webextensions/api/contextualidentities/move/index.md
Outdated
Show resolved
Hide resolved
files/en-us/mozilla/add-ons/webextensions/api/contextualidentities/move/index.md
Outdated
Show resolved
Hide resolved
|
||
## Examples | ||
|
||
Starting with this list of contextual identities `[id0, id1, id2, id3]`: |
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.
I guess that these were based on the testcase. In there, id0, id1, etc are variable names referring to the actual IDs. The examples below are unclear and not working.
I would simplify this section by showing how one can query identities, then choose the identity to move. For example, the scenario of moving the last identity to the start, and then back to the end. And another one where multiple identities are moved.
let identities = await browser.contextualIdentities.query({});
let firstId = identities[0].cookieStoreId;
// Moves first identity to the end.
await browser.contextualIdentities.move(firstId, -1);
// Move identity to the start again.
await browser.contextualIdentities.move(firstId, 0);
Alternative way of moving the first identity to the end: by moving all other identities to the start we get the same effect:
let identities = await browser.contextualIdentities.query({});
let ids = identities.map(identity => identity.cookieStoreId);
// Create array without the first item:
let otherIds = ids.slice(1);
// Moves other identities to the start,
// effectively putting the first identity to the end.
await browser.contextualIdentities.move(otherIds, 0);
Another example, move "Personal" identity before "Work". Important note: this example assumes containers with these names to exist. This is often not the case in customized or localized (non-English) Firefox instances.
let identities = await browser.contextualIdentities.query({});
// Find cookieStoreId of container with name "Personal".
let personalId = identities.find(ci => ci.name === "Personal")?.cookieStoreId;
if (!personalId) {
throw new Error("Personal container not found");
}
// Find index of container with name "Work".
let workIndex = identities.findIndex(identity => identity.name === "Work");
if (workIndex === -1) {
throw new Error("Work container not found!");
}
await browser.contextualIdentities.move(personalId, workIndex);
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.
Thanks for the suggestions @Rob--W
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.
Please apply the suggested edits before merging.
files/en-us/mozilla/add-ons/webextensions/api/contextualidentities/move/index.md
Outdated
Show resolved
Hide resolved
files/en-us/mozilla/add-ons/webextensions/api/contextualidentities/move/index.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Rob Wu <rob@robwu.nl>
* Add contextualIdentities.move * typo * Apply suggestions from review * Examples update * Apply suggestions from review Co-authored-by: Rob Wu <rob@robwu.nl> --------- Co-authored-by: Rob Wu <rob@robwu.nl>
* Add contextualIdentities.move * typo * Apply suggestions from review * Examples update * Apply suggestions from review Co-authored-by: Rob Wu <rob@robwu.nl> --------- Co-authored-by: Rob Wu <rob@robwu.nl>
Description
Documentation and release note in support of Bug 1333395 Consider support for containers sort order.