Commit 95c762ed authored by sunko's avatar sunko
Browse files

fix: reworked implementation

parent c591eab7
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -15,12 +15,15 @@

<ion-content scroll="true" class="app-view has-header">
	<div class="about-content">
		<loading [hidden]="aboutHtml != null"></loading>
		<loading [hidden]="useAboutHtml != null"></loading>
		<div
			*ngIf="aboutHtml != null"
			[innerHTML]="aboutHtml | safe: 'html'"
			*ngIf="useAboutHtml != null"
			[innerHTML]="useAboutHtml | safe: 'html'"
		></div>
		<h5 style="padding-left: 10px; color: #888;" *ngIf="aboutHtml != null">
		<h5
			style="padding-left: 10px; color: #888;"
			*ngIf="useAboutHtml != null"
		>
			App Version: {{ appVersion }}
		</h5>
	</div>
+28 −28
Original line number Diff line number Diff line
import { Component } from '@angular/core';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { UserRouter } from '@modules/client.common.angular2/routers/user-router.service';
import { Subscription } from 'rxjs/Subscription';
import { Store } from 'services/store.service';
import { environment } from 'environments/environment';
import ILanguage from '@modules/server.common/interfaces/ILanguage';
import { DeviceRouter } from '@modules/client.common.angular2/routers/device-router.service';

@Component({
	selector: 'page-about',
	templateUrl: 'about.html',
	styleUrls: ['about.scss'],
})
export class AboutPage {
	aboutHtml: string;
	appVersion: string;

	private _pageSubscriptions: Subscription[] = [];

	constructor(private userRouter: UserRouter, private store: Store) {
		this._getAboutHtml();
export class AboutPage implements OnInit, OnDestroy {
	public useAboutHtml: string = '<h1>Loading...</h1>';
	public selectedLanguage: ILanguage;
	private sub: Subscription;
	public deviceId: string;
	public userId: string;
	public appVersion: string;

	constructor(
		private userRouter: UserRouter,
		private deviceRouter: DeviceRouter
	) {
		this.selectedLanguage =
			(localStorage.getItem('_language') as ILanguage) || 'en-US';
		this.deviceId = localStorage.getItem('_deviceId');
		this.userId = localStorage.getItem('_userId');
		this.appVersion = environment.APP_VERSION;
	}

	get userId() {
		return this.store.carrierId;
	}

	get deviceId() {
		return this.store.deviceId;
	}

	private _getAboutHtml() {
		if (this.userId && this.deviceId) {
			const aboutSubscription = this.userRouter
	ngOnInit() {
		this.deviceRouter.updateLanguage(this.deviceId, this.selectedLanguage);
		this.sub = this.userRouter
			.getAboutUs(this.userId, this.deviceId)
				.subscribe((html) => (this.aboutHtml = html));

			this._pageSubscriptions.push(aboutSubscription);
		}
			.subscribe((html) => {
				this.useAboutHtml = html;
			});
	}

	ionViewWillLeave() {
		this._pageSubscriptions.forEach((s) => s.unsubscribe);
	ngOnDestroy() {
		this.sub.unsubscribe();
	}
}
+22 −14
Original line number Diff line number Diff line
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, OnDestroy } from '@angular/core';

import { UserRouter } from '@modules/client.common.angular2/routers/user-router.service';
import { Subscription } from 'rxjs';
import ILanguage from '@modules/server.common/interfaces/ILanguage';
import { DeviceRouter } from '@modules/client.common.angular2/routers/device-router.service';

@Component({
	selector: 'page-terms-of-use',
	templateUrl: 'terms-of-use.html',
	styleUrls: ['terms-of-use.scss'],
})
export class TermsOfUsePage implements OnInit {
export class TermsOfUsePage implements OnInit, OnDestroy {
	public useTermsHtml: string = '<h1>Loading...</h1>';
	public selectedLanguage: string;
	public selectedLanguage: ILanguage;
	private sub: Subscription;
	public deviceId: string;
	public userId: string;

	constructor(private userRouter: UserRouter) {
		this.selectedLanguage = localStorage.getItem('_language');
	constructor(
		private userRouter: UserRouter,
		private deviceRouter: DeviceRouter
	) {
		this.selectedLanguage =
			(localStorage.getItem('_language') as ILanguage) || 'en-US';
		this.deviceId = localStorage.getItem('_deviceId');
		this.userId = localStorage.getItem('_userId');
	}

	ngOnInit() {
		this.userRouter
			.getTermsOfUseByLanguage(this.selectedLanguage)
		this.deviceRouter.updateLanguage(this.deviceId, this.selectedLanguage);
		this.sub = this.userRouter
			.getTermsOfUse(this.userId, this.deviceId)
			.subscribe((html) => {
				this.useTermsHtml = html;
			});
	}

	private get _userId() {
		return localStorage.getItem('_userId');
	}

	private get _deviceId() {
		return localStorage.getItem('_deviceId');
	ngOnDestroy() {
		this.sub.unsubscribe();
	}
}
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
	"name": "@ever-platform/common-angular",
	"description": "Ever Platform Shared Angular Core",
	"license": "AGPL-3.0",
	"version": "0.3.4",
	"version": "0.3.5",
	"homepage": "https://ever.co",
	"repository": {
		"type": "git",
+2 −26
Original line number Diff line number Diff line
@@ -76,32 +76,8 @@ export class UserRouter implements IUserRouter {
		);
	}

	getPrivacyByLanguage(selectedLanguage: string): Observable<string> {
		return this.router.runAndObserve<string>(
			'getPrivacyByLanguage',
			selectedLanguage
		);
	}

	getTermsOfUseByLanguage(selectedLanguage: string): Observable<string> {
		return this.router.runAndObserve<string>(
			'getTermsOfUseByLanguage',
			selectedLanguage
		);
	}

	getAboutUsByLanguage(selectedLanguage: string): Observable<string> {
		return this.router.runAndObserve<string>(
			'getAboutUsByLanguage',
			selectedLanguage
		);
	}

	getHelpByLanguage(selectedLanguage: string): Observable<string> {
		return this.router.runAndObserve<string>(
			'getHelpByLanguage',
			selectedLanguage
		);
	getHelp(userId: string, deviceId: string): Observable<string> {
		return this.router.runAndObserve<string>('getHelp', userId, deviceId);
	}

	getPrivacy(userId: string, deviceId: string): Observable<string> {
Loading