fn init_toggle_settings_task(
        &mut self,
        ctx: &Context<Self>,
        force: Option<bool>,
        sender: Option<Sender<Result<JsValue, JsValue>>>,
    ) {
        let is_open = ctx.props().renderer.is_settings_open();
        match force {
            Some(force) if is_open == force => {
                if let Some(sender) = sender {
                    sender.send(Ok(JsValue::UNDEFINED)).unwrap();
                }
            }
            Some(_) | None => {
                let force = !is_open;
                let callback = ctx.link().callback(move |resolve| {
                    let update = SettingsUpdate::Update(force);
                    Msg::ToggleSettingsComplete(update, resolve)
                });

                clone!(ctx.props().renderer, ctx.props().session);
                drop(promisify_ignore_view_delete(async move {
                    let result = if session.js_get_table().is_some() {
                        renderer.presize(force, callback.emit_and_render()).await
                    } else {
                        callback.emit_and_render().await?;
                        Ok(JsValue::UNDEFINED)
                    };

                    if let Some(sender) = sender {
                        // TODO shouldn't ignore, this should retry (?)
                        let msg = result.clone().or_else(ignore_view_delete);
                        sender.send(msg).into_jserror()?;
                    };

                    result
                }));
            }
        };
    }
/// Toggle the settings, or force the settings panel either open (true) or
/// closed (false) explicitly.  In order to reduce apparent
/// screen-shear, `toggle_settings()` uses a somewhat complex render
/// order:  it first resize the plugin's `<div>` without moving it,
/// using `overflow: hidden` to hide the extra draw area;  then,
/// after the _async_ drawing of the plugin is complete, it will send a
/// message to complete the toggle action and re-render the element with
/// the settings removed.
///
/// # Arguments
/// * `force` - Whether to explicitly set the settings panel state to
///   Open/Close (`Some(true)`/`Some(false)`), or to just toggle the current
///   state (`None`).
Toggle the settings, or force the settings panel either open (true) or
closed (false) explicitly.
Toggle the settings or force the settings panel either open ( true ) or closed ( false ) explicitly .
fn init_toggle_settings_task(
        &mut self,
        ctx: &Context<Self>,
        force: Option<bool>,
        sender: Option<Sender<Result<JsValue, JsValue>>>,
    ) {
        let is_open = ctx.props().renderer.is_settings_open();
        match force {
            Some(force) if is_open == force => {
                if let Some(sender) = sender {
                    sender.send(Ok(JsValue::UNDEFINED)).unwrap();
                }
            }
            Some(_) | None => {
                let force = !is_open;
                let callback = ctx.link().callback(move |resolve| {
                    let update = SettingsUpdate::Update(force);
                    Msg::ToggleSettingsComplete(update, resolve)
                });
                clone!(ctx.props().renderer, ctx.props().session);
                drop(promisify_ignore_view_delete(async move {
                    let result = if session.js_get_table().is_some() {
                        renderer.presize(force, callback.emit_and_render()).await
                    } else {
                        callback.emit_and_render().await?;
                        Ok(JsValue::UNDEFINED)
                    };
                    if let Some(sender) = sender {
                        // TODO shouldn't ignore, this should retry (?)
                        let msg = result.clone().or_else(ignore_view_delete);
                        sender.send(msg).into_jserror()?;
                    };
                    result
                }));
            }
        };
    }
fn init_toggle_settings_task ( & mut self , ctx : & Context < Self > , force : Option < bool > , sender : Option < Sender < Result < JsValue , JsValue > > > , ) { let is_open = ctx . props ( ) . renderer . is_settings_open ( ) ; match force { Some ( force ) if is_open == force => { if let Some ( sender ) = sender { sender . send ( Ok ( JsValue :: UNDEFINED ) ) . unwrap ( ) ; } } Some ( _ ) | None => { let force = ! is_open ; let callback = ctx . link ( ) . callback ( move | resolve | { let update = SettingsUpdate :: Update ( force ) ; Msg :: ToggleSettingsComplete ( update , resolve ) } ) ; clone ! ( ctx props ( ) renderer ctx props ( ) session ) ; drop ( promisify_ignore_view_delete ( async move { let result = if session . js_get_table ( ) . is_some ( ) { renderer . presize ( force , callback . emit_and_render ( ) ) . await } else { callback . emit_and_render ( ) . await ? ; Ok ( JsValue :: UNDEFINED ) } ; if let Some ( sender ) = sender { // TODO shouldn't ignore, this should retry (?) let msg = result . clone ( ) . or_else ( ignore_view_delete ) ; sender . send ( msg ) . into_jserror ( ) ? ; } ; result } ) ) ; } } ; }
Toggle the settings, or force the settings panel either open (true) or
closed (false) explicitly.
Toggle the settings or force the settings panel either open ( true ) or closed ( false ) explicitly .
&mut self
ctx
&Context<Self>
force
Option<bool>
sender
Option<Sender<Result<JsValue, JsValue>>>
&mut self
ctx
&Context<Self>
force
Option<bool>
sender
Option<Sender<Result<JsValue, JsValue>>>