3

I have a gmail add-on with CardAction - Logout:

enter image description here

And if in stack navigation there are few cards and user make "Logout" - appears "Back Arrow":

enter image description here

This is my logoutAction, it works fine, but do you have any ideas how to disable this back-arrow?

function logoutAction(e) {

  var service = getOAuthService();
  service.reset();

  return CardService.newAuthorizationException()
  .setAuthorizationUrl(service.getAuthorizationUrl())
  .setResourceDisplayName("MY_PROJECT")
  .throwException();
}

This is my simple Card, where I use my logoutAction:

function afterImportScreenBuild() {

    var action = CardService.newAction().setFunctionName('logoutAction');

    var cardHeader = CardService.newCardHeader()
        .setTitle("MY_HEADER");

    var viewButton = CardService.newTextButton()
        .setText("BTN")
        .setOpenLink(CardService.newOpenLink()
            .setUrl("https://test.com/"));

    var card = CardService.newCardBuilder()
        .setHeader(cardHeader);

    var section = CardService.newCardSection();

    var textKeyValue = CardService.newKeyValue()
        .setContent("MY_TIMELINE")
        .setButton(viewButton);

    card.addCardAction(CardService.newCardAction().setText('Logout').setOnClickAction(action));
    section.addWidget(textKeyValue);
    card.addSection(section);

    return card.build();
}

If my logoutAction would return ActionResponseBuilder I could use popToRoot():

CardService.newActionResponseBuilder().setNavigation( CardService.newNavigation().popToRoot() ).build()

But in logoutAction I need to return newAuthorizationException() and I have no ideas how I can сlear my navigation stack.

RomanSorin
  • 189
  • 2
  • 7

1 Answers1

1

I'm not sure, but let me say a few things I see

function logoutAction(e) {

  var service = getOAuthService();
  service.reset();

}

With this function you completed the logout process, so, my question here is:

Do you really need to return anything there?

Because if not, we are done.

If we really need the return, we could always use a setCustomUiCallback(callback) on the newAuthorizationException() and make the popToRoot() call on there, showing the card you wish and avoiding the go back arrow.

yuri
  • 3,182
  • 2
  • 16
  • 26