11import useDataStyleState from "../internal_stores/data_style_state.js"
22import useMeshStyle from "../internal_stores/mesh/index.js"
33import useModelStyle from "../internal_stores/model/index.js"
4+ import { defineStore } from "pinia"
5+ import { useDataBaseStore } from "./data_base.js"
46
57export const useDataStyleStore = defineStore ( "dataStyle" , ( ) => {
68 /** States **/
@@ -10,7 +12,9 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
1012 const dataBaseStore = useDataBaseStore ( )
1113
1214 /** Actions **/
13- // function applyDataStyle() {
15+ function addDataStyle ( id , geode_object , object_type ) {
16+ dataStyleState . styles [ id ] = getDefaultStyle ( geode_object )
17+ const promise_array = [ ]
1418 if ( object_type === "mesh" ) {
1519 promise_array . push ( meshStyleStore . applyMeshDefaultStyle ( id ) )
1620 } else if ( object_type === "model" ) {
@@ -19,38 +23,34 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
1923 } else {
2024 throw new Error ( "Unknown object type" )
2125 }
22- await Promise . all ( promise_array ) ;
23- await rpc_call ( "opengeodeweb_viewer.viewer.render_now" , { } ) ;
24- return true ;
26+ return Promise . all ( promise_array )
2527 }
2628
27- async function setVisibility ( payloadOrId , visibility ) {
29+ // useDataStyleStore: setVisibility
30+ function setVisibility ( payloadOrId , visibility ) {
2831 const id =
2932 typeof payloadOrId === "string"
3033 ? payloadOrId
3134 : payloadOrId ?. id ?? payloadOrId ?. data_id ?? payloadOrId ?. model_id
3235 if ( ! id ) return Promise . resolve ( [ ] )
3336
34- const meta = dataBaseStore . itemMetaDatas ( id )
35- const object_type = meta?. object_type
36- if ( ! object_type ) return Promise . resolve ( [ ] )
37-
38- if ( ! dataStyleState . styles [ id ] ) {
39- await addDataStyle ( id , meta . geode_object , object_type )
40- }
41-
4237 const visible =
4338 typeof visibility === "boolean"
4439 ? visibility
4540 : payloadOrId ?. visible != null
4641 ? ! ! payloadOrId . visible
4742 : true
4843
44+ const meta = dataBaseStore . itemMetaDatas ( id )
45+ const object_type = meta ?. object_type
46+ if ( ! object_type ) return Promise . resolve ( [ ] )
47+
4948 if ( object_type === "mesh" ) {
5049 return Promise . all ( [ meshStyleStore . setMeshVisibility ( id , visible ) ] )
51- } else {
50+ } else if ( object_type === "model" ) {
5251 return Promise . all ( [ modelStyleStore . setModelVisibility ( id , visible ) ] )
5352 }
53+ return Promise . resolve ( [ ] )
5454 }
5555
5656 function setModelEdgesVisibility ( id , visibility ) {
0 commit comments