Search code examples
steroids

AppGyver: Can't open two modals in succession in a supersonic app


I am trying to open two views in succession, both as modals in an Appgyver project. when i do supersonic.ui.modal.hide() and supersonic.ui.modal.show(some_view), the second view does not show. If I throw in an alert('here') in between the modal.hide() and modal.show(), it seems to work. What is the problem here? It's the same with supsersonic.ui.layers.pop() and supersonic.ui.layers.push(another_view) in succession.

Usage sample:

}else if (option === 'chooseLocation'){
  $scope.currentOption = "location you chose.";
  $scope.f = true;
  supersonic.ui.modal.hide().then(function(){
    supersonic.ui.modal.show("chooseLocation");
    $localStorage.locationOption = 'lastUsed';
  });
}

another snippet that i tried this morning that's not related to modals, but also doesn't work:

supersonic.ui.layers.popAll().then(function(){
  var view = new supersonic.ui.View("searchresults#index?"+paramText);
  supersonic.ui.layers.push(view);
});

The error I get on the log screen:

landing#drawer  11:23:29.382    error   
"supersonic.ui.layers.popAll rejected: {}"

Solution

  • This seems to be a bug in the Supersonic API.

    The Javascript success callback is invoked when the native wrapper has received the API call. This is invalid behaviour. The Javascript success callback should be invoked when the native wrapper has completed the API call (expected behaviour).

    As a workaround, use Use Steroids.js events such as didclose to determine when the native API call has completed. See Steroids modals and Steroids layers for further documentation.

    I have filed a new bug in AppGyver Github issues