pub fn js_restore(&self, update: JsValue) -> js_sys::Promise {
        clone!(self.session, self.renderer, self.root, self.theme);
        promisify_ignore_view_delete(async move {
            let ViewerConfigUpdate {
                plugin,
                plugin_config,
                settings,
                theme: theme_name,
                mut view_config,
            } = ViewerConfigUpdate::decode(&update)?;

            let needs_restyle = match theme_name {
                OptionalUpdate::SetDefault => {
                    let current_name = theme.get_name().await;
                    if None != current_name {
                        theme.set_name(None).await?;
                        true
                    } else {
                        false
                    }
                }
                OptionalUpdate::Update(x) => {
                    let current_name = theme.get_name().await;
                    if current_name.is_some() && current_name.as_ref().unwrap() != &x {
                        theme.set_name(Some(&x)).await?;
                        true
                    } else {
                        false
                    }
                }
                _ => false,
            };

            let plugin_changed = renderer.update_plugin(plugin)?;
            if plugin_changed {
                session.set_update_column_defaults(&mut view_config, &renderer.metadata());
            }

            session.update_view_config(view_config);
            let draw_task = renderer.draw(async {
                let task = root
                    .borrow()
                    .as_ref()
                    .ok_or("Already deleted")?
                    .promise_message(move |x| Msg::ToggleSettingsComplete(settings, x));

                let result = async {
                    let plugin = renderer.get_active_plugin()?;
                    if let Some(plugin_config) = &plugin_config {
                        let js_config = JsValue::from_serde(plugin_config);
                        plugin.restore(&js_config.into_jserror()?);
                    }

                    session.validate().await?.create_view().await
                }
                .await;

                task.await.into_jserror()?;
                result
            });

            drop(draw_task.await?);

            // TODO this should be part of the API for `draw()` above, such that
            // the plugin need not render twice when a theme is provided.
            if needs_restyle {
                let view = session.get_view().into_jserror()?;
                renderer.restyle_all(&view).await?;
            }

            Ok(JsValue::UNDEFINED)
        })
    }
/// Restores this element from a full/partial `JsPerspectiveViewConfig`.
///
/// # Arguments
/// - `update` The config to restore to, as returned by `.save()` in either
///   "json", "string" or "arraybuffer" format.
Restores this element from a full/partial `JsPerspectiveViewConfig`.
Restores this element from a full / partial ` JsPerspectiveViewConfig ` .
pub fn js_restore(&self, update: JsValue) -> js_sys::Promise {
        clone!(self.session, self.renderer, self.root, self.theme);
        promisify_ignore_view_delete(async move {
            let ViewerConfigUpdate {
                plugin,
                plugin_config,
                settings,
                theme: theme_name,
                mut view_config,
            } = ViewerConfigUpdate::decode(&update)?;
            let needs_restyle = match theme_name {
                OptionalUpdate::SetDefault => {
                    let current_name = theme.get_name().await;
                    if None != current_name {
                        theme.set_name(None).await?;
                        true
                    } else {
                        false
                    }
                }
                OptionalUpdate::Update(x) => {
                    let current_name = theme.get_name().await;
                    if current_name.is_some() && current_name.as_ref().unwrap() != &x {
                        theme.set_name(Some(&x)).await?;
                        true
                    } else {
                        false
                    }
                }
                _ => false,
            };
            let plugin_changed = renderer.update_plugin(plugin)?;
            if plugin_changed {
                session.set_update_column_defaults(&mut view_config, &renderer.metadata());
            }
            session.update_view_config(view_config);
            let draw_task = renderer.draw(async {
                let task = root
                    .borrow()
                    .as_ref()
                    .ok_or("Already deleted")?
                    .promise_message(move |x| Msg::ToggleSettingsComplete(settings, x));
                let result = async {
                    let plugin = renderer.get_active_plugin()?;
                    if let Some(plugin_config) = &plugin_config {
                        let js_config = JsValue::from_serde(plugin_config);
                        plugin.restore(&js_config.into_jserror()?);
                    }
                    session.validate().await?.create_view().await
                }
                .await;
                task.await.into_jserror()?;
                result
            });
            drop(draw_task.await?);
            // TODO this should be part of the API for `draw()` above, such that
            // the plugin need not render twice when a theme is provided.
            if needs_restyle {
                let view = session.get_view().into_jserror()?;
                renderer.restyle_all(&view).await?;
            }
            Ok(JsValue::UNDEFINED)
        })
    }
pub fn js_restore ( & self , update : JsValue ) -> js_sys :: Promise { clone ! ( self session self renderer self root self theme ) ; promisify_ignore_view_delete ( async move { let ViewerConfigUpdate { plugin , plugin_config , settings , theme : theme_name , mut view_config , } = ViewerConfigUpdate :: decode ( & update ) ? ; let needs_restyle = match theme_name { OptionalUpdate :: SetDefault => { let current_name = theme . get_name ( ) . await ; if None != current_name { theme . set_name ( None ) . await ? ; true } else { false } } OptionalUpdate :: Update ( x ) => { let current_name = theme . get_name ( ) . await ; if current_name . is_some ( ) && current_name . as_ref ( ) . unwrap ( ) != & x { theme . set_name ( Some ( & x ) ) . await ? ; true } else { false } } _ => false , } ; let plugin_changed = renderer . update_plugin ( plugin ) ? ; if plugin_changed { session . set_update_column_defaults ( & mut view_config , & renderer . metadata ( ) ) ; } session . update_view_config ( view_config ) ; let draw_task = renderer . draw ( async { let task = root . borrow ( ) . as_ref ( ) . ok_or ( " " ) ? . promise_message ( move | x | Msg :: ToggleSettingsComplete ( settings , x ) ) ; let result = async { let plugin = renderer . get_active_plugin ( ) ? ; if let Some ( plugin_config ) = & plugin_config { let js_config = JsValue :: from_serde ( plugin_config ) ; plugin . restore ( & js_config . into_jserror ( ) ? ) ; } session . validate ( ) . await ? . create_view ( ) . await } . await ; task . await . into_jserror ( ) ? ; result } ) ; drop ( draw_task . await ? ) ; // TODO this should be part of the API for `draw()` above, such that // the plugin need not render twice when a theme is provided. if needs_restyle { let view = session . get_view ( ) . into_jserror ( ) ? ; renderer . restyle_all ( & view ) . await ? ; } Ok ( JsValue :: UNDEFINED ) } ) }
Restores this element from a full/partial `JsPerspectiveViewConfig`.
Restores this element from a full / partial ` JsPerspectiveViewConfig ` .
&self
update
JsValue
&self
update
JsValue
The config to restore to, as returned by `.save()` in either
"json", "string" or "arraybuffer" format.
The config to restore to as returned by ` . save () ` in either " json " " string " or " arraybuffer " format .