import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';

export default class ApplicationRoute extends Route {

  @service('remotestorage') storage;
  @service localData;
  @service logger;
  @service coms;

  async beforeModel (transition) {
    super.beforeModel(...arguments);

    await this.storage.ensureReadiness();
    await this.localData.setDefaultValues();
    await this.coms.instantiateAccountsAndChannels();
    this.coms.setupListeners();

    if (!this.coms.onboardingComplete &&
        !transition.intent.url.includes('add-account')) {
      this.transitionTo('welcome');
    }

    // See a list of allowed types in logger.js
    // Add or remove all your log types here:
    // this.logger.add('message');
    // this.logger.remove('join');
    // this.logger.disable();
    // this.logger.enable();
  }

  @action
  leaveChannel (channel) {
    this.coms.removeChannel(channel.name);

    // Switch to last channel if the channel parted was currently open
    if (channel.visible) {
      let lastChannel = this.coms.sortedChannels.lastObject;
      this.transitionTo('channel', lastChannel);
    }
  }

}

@@ -126,16 +126,58 @@
 object';
+%0Aimport %7B isPresent %7D from '@ember/utils';
 %0A%0Aexport
@@ -580,37 +580,40 @@
 if (
-!this.coms.onboardingComplete
+isPresent(transition.intent.url)
  &&%0A
@@ -624,9 +624,8 @@
     
-!
 tran
@@ -665,24 +665,86 @@
 ccount')) %7B%0A
+      return;%0A    %7D%0A%0A    if (!this.coms.onboardingComplete) %7B%0A
       this.t

Fix application route logic