Skip to content
This repository has been archived by the owner on Mar 28, 2018. It is now read-only.

Commit

Permalink
[Sprint/Dylan] (feat): Create App Status service and disable points a…
Browse files Browse the repository at this point in the history
…nimation when on background (#28)

* (fix): Refresh points counter when re-logging and add pull to refresh on wallet view (#19)

* (feat): Re-sync discovery entity when loading full-screen (#17)

* (feat): Be able to click post date to original post page (#16)

* (fix): ios icon

* (fix): Boost rejected notification typo (#21)

* (fix) : Reminds don't take you to the original post (#23)

* (fix): Link images and blogs on notifications (#20)

* (fix): Wrong storage key for points animation toggle (#22)

* (feat): Improve back button visibility (z-index and outline) (#18)

* (fix): prevent navigation become dead when pop is happening

* (chore): improve unread and online icons

* (feat): Create App Status service and disable points animation when on background
  • Loading branch information
edgebal authored and markharding committed Mar 27, 2017
1 parent a7ff18b commit 86132af
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { SettingsComponent } from './modules/settings/settings.component';

//for testing onboarding
import { OnboardingComponent } from './modules/onboarding/onboarding.component';
import { AppStatusService } from "./common/services/app-status.service";

@Component({
selector: "ion-app",
Expand All @@ -39,7 +40,7 @@ export class MindsApp {

constructor(private oauth2 : OAuth2, public menuCtrl: MenuController, private platform : Platform, private app : App,
private storage : Storage, private push : PushService, private share : ShareService, private sockets: SocketsService,
private client : Client){
private client : Client, private appStatus: AppStatusService){

if(this.oauth2.hasAccessToken()){
this.rootPage = TabsComponent;
Expand All @@ -62,6 +63,8 @@ export class MindsApp {
.then((code) => {
this.versionCode = code;
});

this.appStatus.setUp();
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/common/common.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import { TextareaComponent } from './components/textarea.component';
import { RichInputComponent } from './components/rich-input.component.ts';
import { SafePipe } from "./pipes/safe.pipe";
import { PlatformFeaturesService } from "./services/platform-features.service";

import { AppStatusService } from "./services/app-status.service";

@NgModule({
imports: [ IonicModule ],
providers: [ Storage, PlatformFeaturesService ],
providers: [ Storage, PlatformFeaturesService, AppStatusService ],
declarations: [ ImgFadeDirective, ExplicitDirective, ContenteditableModel, DomainPipe, AbbrPipe, TagsPipe, TextareaComponent, RichInputComponent, SafePipe ],
exports: [ ImgFadeDirective, ExplicitDirective, ContenteditableModel, DomainPipe, AbbrPipe, TagsPipe, TextareaComponent, RichInputComponent, SafePipe ]
})
Expand Down
23 changes: 23 additions & 0 deletions src/app/common/services/app-status.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Injectable } from '@angular/core';
import { Platform } from "ionic-angular";

@Injectable()
export class AppStatusService {
private _isActive: boolean = true;

constructor(private platform: Platform) { }

setUp() {
this.platform.pause.subscribe(() => {
this._isActive = false;
});

this.platform.resume.subscribe(() => {
this._isActive = true;
});
}

isActive() {
return this._isActive;
}
}
3 changes: 2 additions & 1 deletion src/app/modules/wallet/wallet.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { BoostReviewComponent } from './boost.component';
import { Client } from '../../common/services/api/client';
import { SocketsService } from "../../common/services/api/sockets.service";
import { Storage } from "../../common/services/storage";
import { AppStatusService } from "../../common/services/app-status.service";

@NgModule({
imports: [ IonicModule, CommonModule, PaymentsModule ],
Expand All @@ -25,7 +26,7 @@ import { Storage } from "../../common/services/storage";
{
provide: WalletService,
useFactory: WalletService._,
deps: [ Client, PopController, SocketsService, Storage ]
deps: [ Client, PopController, SocketsService, Storage, AppStatusService ]
},
PopController
],
Expand Down
9 changes: 5 additions & 4 deletions src/app/modules/wallet/wallet.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { App } from 'ionic-angular'
import { PopController } from './pop/pop';
import { SocketsService } from "../../common/services/api/sockets.service";
import { Storage } from '../../common/services/storage';
import { AppStatusService } from "../../common/services/app-status.service";

export class WalletService{

Expand All @@ -14,7 +15,7 @@ export class WalletService{
apiInProgress: boolean = false;
pointsTxSubscription;

constructor(private client : Client, private popCtrl : PopController, private sockets: SocketsService, private storage: Storage){
constructor(private client : Client, private popCtrl : PopController, private sockets: SocketsService, private storage: Storage, private appStatus: AppStatusService){
//this.getCount();
this.listen();
}
Expand Down Expand Up @@ -85,7 +86,7 @@ export class WalletService{
return;
}

if (this.storage.get('pointsAnimation')) {
if (this.storage.get('pointsAnimation') && this.appStatus.isActive()) {
this.queueAnimation(points);
}

Expand All @@ -112,8 +113,8 @@ export class WalletService{
}

// factory
static _(client : Client, popCtrl : PopController, sockets: SocketsService, storage: Storage){
return new WalletService(client, popCtrl, sockets, storage);
static _(client : Client, popCtrl : PopController, sockets: SocketsService, storage: Storage, appStatus: AppStatusService){
return new WalletService(client, popCtrl, sockets, storage, appStatus);
}

}

0 comments on commit 86132af

Please sign in to comment.