PushMenu expand or collapse

hi please help me,
i have code with following condition
if the user login sidebar collapses, if the user has logged in the sidebar expands, what is the correct logic for the statement below?

if (statement) {
$('[data-widget="pushmenu"]').PushMenu('expand');
}else{
$('[data-widget="pushmenu"]').PushMenu('collapse');
}

Thank

You may try:

if (ew.IS_LOGGEDIN) {
    $('[data-widget="pushmenu"]').PushMenu('expand');
} else {
    $('[data-widget="pushmenu"]').PushMenu('collapse');
}

thankyou

ask again,
if I open it on my phone, the sidebar becomes a collapse statement, what do you do?

if (statement in phone resolution) {
$('[data-widget="pushmenu"]').PushMenu('collapse');
}

Please note that in mobile-mode or mobile-layout, the Sidebar will always be collapsed.

I want to ask again if this code doesn’t work in version 2024.2?
is there anything that needs to be changed?

if (ew.IS_LOGGEDIN){
     if (screen.width <= 1024) {
         $('[data-widget="pushmenu"]').PushMenu('collapse');
     } else {
         $('[data-widget="pushmenu"]').PushMenu('expand');
     }
}

Your code is not related to v2024 or not.Note that you use screen.width which is the width of your monitor screen, if you have a monitor wider than 1024px, your code will always expand the push menu.If you want to detect the window width, you may use Window: innerWidth property or the Window: matchMedia() method.You can also change AdminLTE’s Push Menu Plugin option autoCollapseSize. AdminLTE’s default is 992.

How do you do it if the user is logged in and the sidebar expands automatically without having to set the screen width?
Please, the solution is to use the autoCollapseSize option?