-
Hello, I'm trying to set a theme of a viewer in a workspace when adding it by the "New Table>" drop down menu. Whats the best way to do this? Thank you very much |
Beta Was this translation helpful? Give feedback.
Answered by
GREEB
Aug 4, 2022
Replies: 1 comment 2 replies
-
for now i fixed this with this. i'm sure there is a better way workspace.current.addEventListener(
"workspace-new-view", async () => {
if (workspace.current.children[0].attributes.getNamedItem('name') === null){
for (let i = 0; i < workspace.current.children.length; i++) {
await workspace.current.children[i].restore({ theme: (theme === "light") ? "Material Light" : "Material Dark" })
}
await workspace.current.flush()
}
}
); update above version only works when workspace empty something like that would help if you add a new empty table to a workspace with views: for (let index = 0; index < workspace.current.children.length; index++) {
if (workspace.current.children[index].attributes.getNamedItem('name') === null) {
const isTheme = (theme === "light") ? "Material Light" : "Material Dark"
if (newView !== undefined && workspace.current !== null && workspace.current !== undefined) {
if (workspace.current.children[index].attributes.getNamedItem('theme').value !== isTheme) {
await workspace.current.children[index].restore({ theme: (theme === "light") ? "Material Light" : "Material Dark" })
}
}
}
} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
GREEB
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for now i fixed this with this. i'm sure there is a better way
update above version only works when workspace empty something like that would help if you add a new empty table to a workspace with views: