From d4b9a14041ba04e4b671f7e86d10a735e09e166a Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Fri, 6 Sep 2019 11:33:21 +0200 Subject: Add route listener to open todos via `/todos` --- src/features/todos/index.js | 4 ++++ src/features/todos/store.js | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'src/features') diff --git a/src/features/todos/index.js b/src/features/todos/index.js index 00b165cc5..9b6ab00a0 100644 --- a/src/features/todos/index.js +++ b/src/features/todos/index.js @@ -9,6 +9,10 @@ export const DEFAULT_TODOS_WIDTH = 300; export const TODOS_MIN_WIDTH = 200; export const DEFAULT_TODOS_VISIBLE = true; +export const TODOS_ROUTES = { + TARGET: '/todos', +}; + export const todosStore = new TodoStore(); export default function initTodos(stores, actions) { diff --git a/src/features/todos/store.js b/src/features/todos/store.js index ea05077ab..5d67c5ba0 100644 --- a/src/features/todos/store.js +++ b/src/features/todos/store.js @@ -10,7 +10,9 @@ import { todoActions } from './actions'; import { FeatureStore } from '../utils/FeatureStore'; import { createReactions } from '../../stores/lib/Reaction'; import { createActionBindings } from '../utils/ActionBinding'; -import { DEFAULT_TODOS_WIDTH, TODOS_MIN_WIDTH, DEFAULT_TODOS_VISIBLE } from '.'; +import { + DEFAULT_TODOS_WIDTH, TODOS_MIN_WIDTH, DEFAULT_TODOS_VISIBLE, TODOS_ROUTES, +} from '.'; import { IPC } from './constants'; import { state as delayAppState } from '../delayApp'; @@ -66,6 +68,7 @@ export default class TodoStore extends FeatureStore { this._setFeatureEnabledReaction, this._updateTodosConfig, this._firstLaunchReaction, + this._routeCheckReaction, ]); this._registerReactions(this._allReactions); @@ -176,4 +179,19 @@ export default class TodoStore extends FeatureStore { }); } }; + + _routeCheckReaction = () => { + const { pathname } = this.stores.router.location; + + if (pathname === TODOS_ROUTES.TARGET) { + debug('Router is on todos route, show todos panel'); + // todosStore.start(stores, actions); + + if (!this.isTodosPanelVisible) { + this._updateSettings({ + isTodosPanelVisible: true, + }); + } + } + } } -- cgit v1.2.3-70-g09d2