fix: fix nav animation for notifications/mentions (#1515)

This commit is contained in:
Nolan Lawson 2019-09-22 16:20:26 -07:00 committed by GitHub
parent 8648bb0ad2
commit 3490f98208
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -3,10 +3,18 @@ import { emit } from '../../_utils/eventBus'
export function navObservers (store) {
function pageIsInNav (store, page) {
const { navPages } = store.get()
return !!navPages.find(_ => _.name === page)
return navPages.find(_ => _.name === page)
}
function normalizePageName (page) {
// notifications/mentions are a special case; they show as selected in the nav
return page === 'notifications/mentions' ? 'notifications' : page
}
store.observe('currentPage', (currentPage, previousPage) => {
currentPage = normalizePageName(currentPage)
previousPage = normalizePageName(previousPage)
if (currentPage && previousPage &&
pageIsInNav(store, currentPage) &&
pageIsInNav(store, previousPage)) {