Commit 42585598 authored by Marcelo Rivera's avatar Marcelo Rivera

(fix): disable old onboarding service if the new onboarding feature is enabled

1 merge request!674Onboarding
Pipeline #106623177 failed with stages
in 32 minutes and 17 seconds
......@@ -2,6 +2,7 @@ import { ChannelOnboardingService } from './onboarding.service';
import { clientMock } from '../../../../tests/client-mock.spec';
import { fakeAsync } from '@angular/core/testing';
import { sessionMock } from '../../../../tests/session-mock.spec';
import { featuresServiceMock } from '../../../../tests/features-service-mock.spec';
describe('ChannelOnboardingService', () => {
let service: ChannelOnboardingService;
......@@ -9,7 +10,12 @@ describe('ChannelOnboardingService', () => {
beforeEach(() => {
jasmine.clock().uninstall();
jasmine.clock().install();
service = new ChannelOnboardingService(clientMock, sessionMock);
featuresServiceMock.mock('onboarding-december-2019', false);
service = new ChannelOnboardingService(
clientMock,
sessionMock,
featuresServiceMock
);
clientMock.response = {};
const url = 'api/v2/onboarding/progress';
......
......@@ -5,6 +5,7 @@ import { TokenRewardsOnboardingComponent } from './rewards/rewards.component';
import { EventEmitter } from '@angular/core';
import { Client } from '../../../services/api/client';
import { Session } from '../../../services/session';
import { FeaturesService } from '../../../services/features.service';
export class ChannelOnboardingService {
slides = [
......@@ -31,11 +32,15 @@ export class ChannelOnboardingService {
// these are updated per each slide when calculating the next one, except for the first time onboarding
pendingItems: Array<string> = [];
static _(client: Client, session: Session) {
return new ChannelOnboardingService(client, session);
static _(client: Client, session: Session, featuresService: FeaturesService) {
return new ChannelOnboardingService(client, session, featuresService);
}
constructor(private client: Client, private session: Session) {
constructor(
private client: Client,
private session: Session,
private featuresService: FeaturesService
) {
this.session.userEmitter.subscribe(v => {
if (!v) {
this.reset();
......@@ -44,7 +49,12 @@ export class ChannelOnboardingService {
}
async checkProgress() {
if (!this.session.isLoggedIn()) return;
if (
!this.session.isLoggedIn() ||
this.featuresService.has('onboarding-december-2019')
) {
return;
}
try {
const response: any = await this.client.get('api/v2/onboarding/progress');
......@@ -58,6 +68,12 @@ export class ChannelOnboardingService {
}
async showModal(force: boolean = false) {
if (
!this.session.isLoggedIn() ||
this.featuresService.has('onboarding-december-2019')
) {
return false;
}
if (!force) {
const status = localStorage.getItem('already_onboarded');
......@@ -108,7 +124,7 @@ export class ChannelOnboardingService {
// empty is 1 because username is always there from the beginning
this.currentSlide++;
} else {
//here we just go to the next slide with incomplete stuff
// here we just go to the next slide with incomplete stuff
const i = this.currentSlide + 1;
this.pendingItems = [];
......
......@@ -22,6 +22,7 @@ import { TokenRewardsOnboardingComponent } from './channel/rewards/rewards.compo
import { Client } from '../../services/api/client';
import { SuggestionsModule } from '../suggestions/suggestions.module';
import { Session } from '../../services/session';
import { FeaturesService } from '../../services/features.service';
@NgModule({
imports: [
......@@ -49,7 +50,7 @@ import { Session } from '../../services/session';
OnboardingService,
{
provide: ChannelOnboardingService,
deps: [Client, Session],
deps: [Client, Session, FeaturesService],
useFactory: ChannelOnboardingService._,
},
],
......
Please register or to comment