From ad2a3f3f87252711a9f3cc13916acf0fdff2949e Mon Sep 17 00:00:00 2001 From: Dominik Guzei Date: Thu, 5 Sep 2019 16:39:53 +0200 Subject: Fix delay app ux in combination with announcements --- src/features/announcements/store.js | 5 +++++ src/features/delayApp/index.js | 10 +++++++--- src/features/todos/containers/TodosScreen.js | 2 +- src/features/todos/store.js | 7 +++++-- 4 files changed, 18 insertions(+), 6 deletions(-) (limited to 'src/features') diff --git a/src/features/announcements/store.js b/src/features/announcements/store.js index de7ed2596..d58afbc8e 100644 --- a/src/features/announcements/store.js +++ b/src/features/announcements/store.js @@ -63,6 +63,11 @@ export class AnnouncementsStore extends FeatureStore { return this.stores.settings.stats.appStarts <= 1; } + @computed get isAnnouncementShown() { + const { router } = this.stores; + return router.location.pathname.includes('/announcements'); + } + async start(stores, actions) { debug('AnnouncementsStore::start'); this.stores = stores; diff --git a/src/features/delayApp/index.js b/src/features/delayApp/index.js index 627537de7..c0029873a 100644 --- a/src/features/delayApp/index.js +++ b/src/features/delayApp/index.js @@ -44,14 +44,16 @@ export default function init(stores) { config.delayDuration = globalConfig.wait !== undefined ? globalConfig.wait : DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait; autorun(() => { - if (stores.services.allDisplayed.length === 0) { - debug('seas', stores.services.all.length); + const { isAnnouncementShown } = stores.announcements; + if (stores.services.allDisplayed.length === 0 || isAnnouncementShown) { shownAfterLaunch = true; + setVisibility(false); return; } const diff = moment().diff(timeLastDelay); - if ((stores.app.isFocused && diff >= config.delayOffset) || !shownAfterLaunch) { + const itsTimeToWait = diff >= config.delayOffset; + if (!isAnnouncementShown && ((stores.app.isFocused && itsTimeToWait) || !shownAfterLaunch)) { debug(`App will be delayed for ${config.delayDuration / 1000}s`); setVisibility(true); @@ -66,6 +68,8 @@ export default function init(stores) { setVisibility(false); }, config.delayDuration + 1000); // timer needs to be able to hit 0 + } else { + setVisibility(false); } }); } else { diff --git a/src/features/todos/containers/TodosScreen.js b/src/features/todos/containers/TodosScreen.js index 65afc985b..a5da0b014 100644 --- a/src/features/todos/containers/TodosScreen.js +++ b/src/features/todos/containers/TodosScreen.js @@ -11,7 +11,7 @@ import { todoActions } from '../actions'; @inject('stores', 'actions') @observer class TodosScreen extends Component { render() { - if (!todosStore || !todosStore.isFeatureActive) { + if (!todosStore || !todosStore.isFeatureActive || todosStore.isTodosPanelForceHidden) { return null; } diff --git a/src/features/todos/store.js b/src/features/todos/store.js index aebe0dcbe..ea05077ab 100644 --- a/src/features/todos/store.js +++ b/src/features/todos/store.js @@ -29,10 +29,13 @@ export default class TodoStore extends FeatureStore { return width < TODOS_MIN_WIDTH ? TODOS_MIN_WIDTH : width; } + @computed get isTodosPanelForceHidden() { + const { isAnnouncementShown } = this.stores.announcements; + return delayAppState.isDelayAppScreenVisible || isAnnouncementShown; + } + @computed get isTodosPanelVisible() { - if (delayAppState.isDelayAppScreenVisible) return false; if (this.settings.isTodosPanelVisible === undefined) return DEFAULT_TODOS_VISIBLE; - return this.settings.isTodosPanelVisible; } -- cgit v1.2.3-70-g09d2