-
@piroor, I am working on a new tab search addon that plays nicely with TST and was thinking to: call "get-tree-structure" (snapshot), then expand all of the trees, do some information searching, then try to restore the tree states calling "set-tree-structure" with no other changes to the tree other than the expand/collapse state. However, in my experience, I do see information being properly being returned from get-tree-structure, but when I pass this back to set-tree-structure at the end, the tree states are not being restored. (In my case they all remain expanded due to my actions.) I do see "collapsed: true" in the information, but after doing a "set", none of the trees are collapsed. Questions
Snapshot Logic
Restore Logic
Debug runStarting TreesEnding Trees |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The Here is an example to invert collapsed/expanded state with (async () => {
const original = await browser.runtime.sendMessage('[email protected]', {
type: 'get-tree-structure',
tabs: '*',
});
const inverted = JSON.parse(JSON.stringify(original).replace(/true/g,'WAS_TRUE').replace(/false/g,'true').replace(/WAS_TRUE/g,'false'));
const result = await browser.runtime.sendMessage('[email protected]', {
type: 'set-tree-structure',
tabs: '*', // <= this is required!
structure: inverted,
});
})(); By the way, |
Beta Was this translation helpful? Give feedback.
The
tabs
parameter looks missing in your example codes. As documented at https://github.com/piroor/treestyletab/wiki/API-for-other-addons#take-a-tree-structure-snapshot-of-tabs theid
information of got snapshot is ignored by TST, so you still need to specify tabs to be applied the given snapshot.Here is an example to invert collapsed/expanded state with
get-tree-structure
andset-tree-structure
which successfully worked on my environment: