Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

Commit

Permalink
fix: move in app rating to after review session
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyloi committed Mar 2, 2020
1 parent 6fb0623 commit 818941c
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 49 deletions.
4 changes: 0 additions & 4 deletions packages/ulangi-mobile/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
"checkDatabaseTimeout": 3000
},

"app": {
"showInAppRatingInMoreScreen": true
},

"ad": {
"showAdTimeout": 5000
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ export class MoreScreenDelegate {
this.navigatorDelegate = navigatorDelegate;
}

public autoShowInAppRating(): void {
this.inAppRatingDelegate.autoShowInAppRating();
}

public autoUpdateBottomTabs(): void {
this.observer.reaction(
(): Theme => this.themeStore.theme,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { AdAfterLessonDelegate } from '../ad/AdAfterLessonDelegate';
import { AdDelegate } from '../ad/AdDelegate';
import { DialogDelegate } from '../dialog/DialogDelegate';
import { NavigatorDelegate } from '../navigator/NavigatorDelegate';
import { InAppRatingDelegate } from '../rating/InAppRatingDelegate';
import { ReviewActionMenuDelegate } from '../review-action/ReviewActionMenuDelegate';
import { ReviewFeedbackBarDelegate } from '../review-feedback/ReviewFeedbackBarDelegate';
import { SpeakDelegate } from '../vocabulary/SpeakDelegate';
Expand All @@ -51,6 +52,7 @@ export class SpacedRepetitionLessonScreenDelegate {
private speakDelegate: SpeakDelegate;
private adDelegate: AdDelegate;
private adAfterLessonDelegate: AdAfterLessonDelegate;
private inAppRatingDelegate: InAppRatingDelegate;
private reviewActionMenuDelegate: ReviewActionMenuDelegate;
private dialogDelegate: DialogDelegate;
private navigatorDelegate: NavigatorDelegate;
Expand All @@ -67,6 +69,7 @@ export class SpacedRepetitionLessonScreenDelegate {
speakDelegate: SpeakDelegate,
adDelegate: AdDelegate,
adAfterLessonDelegate: AdAfterLessonDelegate,
inAppRatingDelegate: InAppRatingDelegate,
reviewActionMenuDelegate: ReviewActionMenuDelegate,
dialogDelegate: DialogDelegate,
navigatorDelegate: NavigatorDelegate,
Expand All @@ -82,6 +85,7 @@ export class SpacedRepetitionLessonScreenDelegate {
this.speakDelegate = speakDelegate;
this.adDelegate = adDelegate;
this.adAfterLessonDelegate = adAfterLessonDelegate;
this.inAppRatingDelegate = inAppRatingDelegate;
this.reviewActionMenuDelegate = reviewActionMenuDelegate;
this.dialogDelegate = dialogDelegate;
this.navigatorDelegate = navigatorDelegate;
Expand All @@ -94,7 +98,6 @@ export class SpacedRepetitionLessonScreenDelegate {

this.autoUpdateButtons();
this.autoDisablePopGestureWhenAdRequiredToShow();
this.autoUpdateShouldShowAdOrConsentForm();
this.addBackButtonHandler(this.handleBackPressed);

if (this.shouldLoadAd()) {
Expand Down Expand Up @@ -152,6 +155,16 @@ export class SpacedRepetitionLessonScreenDelegate {
if (this.observableScreen.shouldShowResult.get() === false) {
this.observableScreen.shouldShowResult.set(true);
this.saveResult();

this.observableScreen.shouldShowAdOrGoogleConsentForm.set(
this.adDelegate.shouldShowAdOrGoogleConsentForm(),
);

if (
this.observableScreen.shouldShowAdOrGoogleConsentForm.get() === false
) {
this.inAppRatingDelegate.autoShowInAppRating();
}
}
}

Expand Down Expand Up @@ -325,19 +338,6 @@ export class SpacedRepetitionLessonScreenDelegate {
);
}

private autoUpdateShouldShowAdOrConsentForm(): void {
this.observer.reaction(
(): boolean =>
this.observableScreen.shouldShowResult.get() &&
this.adDelegate.shouldShowAdOrGoogleConsentForm(),
(shouldShowAdOrGoogleConsentForm): void => {
this.observableScreen.shouldShowAdOrGoogleConsentForm.set(
shouldShowAdOrGoogleConsentForm,
);
},
);
}

private disableAllButtons(): void {
this.observableScreen.reviewActionBarState.buttons.forEach(
(button): void => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { AdAfterLessonDelegate } from '../ad/AdAfterLessonDelegate';
import { AdDelegate } from '../ad/AdDelegate';
import { DialogDelegate } from '../dialog/DialogDelegate';
import { NavigatorDelegate } from '../navigator/NavigatorDelegate';
import { InAppRatingDelegate } from '../rating/InAppRatingDelegate';
import { ReviewActionMenuDelegate } from '../review-action/ReviewActionMenuDelegate';
import { ReviewFeedbackBarDelegate } from '../review-feedback/ReviewFeedbackBarDelegate';
import { SpeakDelegate } from '../vocabulary/SpeakDelegate';
Expand All @@ -52,6 +53,7 @@ export class WritingLessonScreenDelegate {
private speakDelegate: SpeakDelegate;
private adDelegate: AdDelegate;
private adAfterLessonDelegate: AdAfterLessonDelegate;
private inAppRatingDelegate: InAppRatingDelegate;
private reviewActionMenuDelegate: ReviewActionMenuDelegate;
private dialogDelegate: DialogDelegate;
private navigatorDelegate: NavigatorDelegate;
Expand All @@ -69,6 +71,7 @@ export class WritingLessonScreenDelegate {
speakDelegate: SpeakDelegate,
adDelegate: AdDelegate,
adAfterLessonDelegate: AdAfterLessonDelegate,
inAppRatingDelegate: InAppRatingDelegate,
reviewActionMenuDelegate: ReviewActionMenuDelegate,
dialogDelegate: DialogDelegate,
navigatorDelegate: NavigatorDelegate,
Expand All @@ -85,6 +88,7 @@ export class WritingLessonScreenDelegate {
this.speakDelegate = speakDelegate;
this.adDelegate = adDelegate;
this.adAfterLessonDelegate = adAfterLessonDelegate;
this.inAppRatingDelegate = inAppRatingDelegate;
this.reviewActionMenuDelegate = reviewActionMenuDelegate;
this.dialogDelegate = dialogDelegate;
this.navigatorDelegate = navigatorDelegate;
Expand All @@ -93,7 +97,6 @@ export class WritingLessonScreenDelegate {

public setUp(): void {
this.autoDisablePopGestureWhenAdRequiredToShow();
this.autoUpdateShouldShowAdOrConsentForm();
this.addBackButtonHandler(this.handleBackPressed);
this.setUpActionButtons();
this.calculateNextReviewData();
Expand Down Expand Up @@ -168,6 +171,16 @@ export class WritingLessonScreenDelegate {
if (this.observableScreen.shouldShowResult.get() === false) {
this.observableScreen.shouldShowResult.set(true);
this.saveResult();

this.observableScreen.shouldShowAdOrGoogleConsentForm.set(
this.adDelegate.shouldShowAdOrGoogleConsentForm(),
);

if (
this.observableScreen.shouldShowAdOrGoogleConsentForm.get() === false
) {
this.inAppRatingDelegate.autoShowInAppRating();
}
}
}

Expand Down Expand Up @@ -300,19 +313,6 @@ export class WritingLessonScreenDelegate {
this.adAfterLessonDelegate.autoDisablePopGestureWhenAdRequiredToShow();
}

private autoUpdateShouldShowAdOrConsentForm(): void {
this.observer.reaction(
(): boolean =>
this.observableScreen.shouldShowResult.get() &&
this.adDelegate.shouldShowAdOrGoogleConsentForm(),
(shouldShowAdOrGoogleConsentForm): void => {
this.observableScreen.shouldShowAdOrGoogleConsentForm.set(
shouldShowAdOrGoogleConsentForm,
);
},
);
}

private shouldLoadAd(): boolean {
return this.adDelegate.shouldLoadAd();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { config } from '../../constants/config';
import { AdAfterLessonDelegate } from '../../delegates/ad/AdAfterLessonDelegate';
import { AdDelegate } from '../../delegates/ad/AdDelegate';
import { AutoArchiveSettingsDelegate } from '../../delegates/auto-archive/AutoArchiveSettingsDelegate';
import { InAppRatingDelegate } from '../../delegates/rating/InAppRatingDelegate';
import { ReviewActionMenuDelegate } from '../../delegates/review-action/ReviewActionMenuDelegate';
import { ReviewFeedbackBarDelegate } from '../../delegates/review-feedback/ReviewFeedbackBarDelegate';
import { ReviewFeedbackButtonDelegate } from '../../delegates/review-feedback/ReviewFeedbackButtonDelegate';
Expand Down Expand Up @@ -95,6 +96,13 @@ export class SpacedRepetitionLessonScreenFactory extends ScreenFactory {
navigatorDelegate,
);

const inAppRatingDelegate = new InAppRatingDelegate(
this.eventBus,
this.props.rootStore.userStore,
this.props.rootStore.remoteConfigStore,
dialogDelegate,
);

return new SpacedRepetitionLessonScreenDelegate(
this.observer,
this.props.rootStore.setStore,
Expand All @@ -106,6 +114,7 @@ export class SpacedRepetitionLessonScreenFactory extends ScreenFactory {
speakDelegate,
adDelegate,
adAfterLessonDelegate,
inAppRatingDelegate,
reviewActionMenuDelegate,
dialogDelegate,
navigatorDelegate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { config } from '../../constants/config';
import { AdAfterLessonDelegate } from '../../delegates/ad/AdAfterLessonDelegate';
import { AdDelegate } from '../../delegates/ad/AdDelegate';
import { AutoArchiveSettingsDelegate } from '../../delegates/auto-archive/AutoArchiveSettingsDelegate';
import { InAppRatingDelegate } from '../../delegates/rating/InAppRatingDelegate';
import { ReviewActionMenuDelegate } from '../../delegates/review-action/ReviewActionMenuDelegate';
import { ReviewFeedbackBarDelegate } from '../../delegates/review-feedback/ReviewFeedbackBarDelegate';
import { ReviewFeedbackButtonDelegate } from '../../delegates/review-feedback/ReviewFeedbackButtonDelegate';
Expand Down Expand Up @@ -57,6 +58,13 @@ export class WritingLessonScreenFactory extends ScreenFactory {
navigatorDelegate,
);

const inAppRatingDelegate = new InAppRatingDelegate(
this.eventBus,
this.props.rootStore.userStore,
this.props.rootStore.remoteConfigStore,
dialogDelegate,
);

const autoArchiveSettingsDelegate = new AutoArchiveSettingsDelegate(
this.props.rootStore.userStore,
);
Expand Down Expand Up @@ -114,6 +122,7 @@ export class WritingLessonScreenFactory extends ScreenFactory {
speakDelegate,
adDelegate,
adAfterLessonDelegate,
inAppRatingDelegate,
reviewActionMenuDelegate,
dialogDelegate,
navigatorDelegate,
Expand Down
4 changes: 0 additions & 4 deletions packages/ulangi-mobile/src/interfaces/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ export interface Config {
readonly checkDatabaseTimeout: number;
};

readonly app: {
readonly showInAppRatingInMoreScreen: boolean;
};

readonly ad: {
readonly showAdTimeout: number;
};
Expand Down
4 changes: 0 additions & 4 deletions packages/ulangi-mobile/src/resolvers/ConfigResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ export class ConfigResolver extends AbstractResolver<Config> {
animationDuration: Joi.number(),
},

app: {
showInAppRatingInMoreScreen: Joi.boolean(),
},

ad: {
showAdTimeout: Joi.number(),
},
Expand Down
5 changes: 0 additions & 5 deletions packages/ulangi-mobile/src/views/more/MoreScreenContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { observer } from 'mobx-react';
import * as React from 'react';

import { Container, ContainerPassedProps } from '../../Container';
import { config } from '../../constants/config';
import { MoreScreenFactory } from '../../factories/more/MoreScreenFactory';
import { MoreScreen } from './MoreScreen';
import { MoreScreenStyle } from './MoreScreenContainer.style';
Expand Down Expand Up @@ -58,10 +57,6 @@ export class MoreScreenContainer extends Container {
this.observableScreen.screenAppearedTimes += 1;

if (this.observableScreen.screenAppearedTimes === 1) {
if (config.app.showInAppRatingInMoreScreen === true) {
this.screenDelegate.autoShowInAppRating();
}

this.screenDelegate.autoUpdateCarouselMessages();
}
}
Expand Down

0 comments on commit 818941c

Please sign in to comment.