2018-02-10 21:57:04 +00:00
|
|
|
|
2018-03-04 20:55:45 +00:00
|
|
|
function computeForTimeline (store, key, defaultValue) {
|
|
|
|
store.compute(key,
|
|
|
|
['currentInstance', 'currentTimeline', `timelineData_${key}`],
|
|
|
|
(currentInstance, currentTimeline, root) => {
|
|
|
|
let instanceData = root && root[currentInstance]
|
|
|
|
return (currentTimeline && instanceData && currentTimeline in instanceData) ? instanceData[currentTimeline] : defaultValue
|
|
|
|
})
|
2018-02-10 21:57:04 +00:00
|
|
|
}
|
|
|
|
|
2018-02-09 06:29:29 +00:00
|
|
|
export function timelineComputations (store) {
|
2018-03-04 20:55:45 +00:00
|
|
|
computeForTimeline(store, 'timelineItemIds', null)
|
|
|
|
computeForTimeline(store, 'runningUpdate', false)
|
|
|
|
computeForTimeline(store, 'initialized', false)
|
|
|
|
computeForTimeline(store, 'lastFocusedElementSelector', null)
|
|
|
|
computeForTimeline(store, 'ignoreBlurEvents', false)
|
|
|
|
computeForTimeline(store, 'itemIdsToAdd', null)
|
|
|
|
computeForTimeline(store, 'showHeader', false)
|
|
|
|
computeForTimeline(store, 'shouldShowHeader', false)
|
2018-03-11 19:11:06 +00:00
|
|
|
computeForTimeline(store, 'timelineItemIdsAreStale', false)
|
2018-03-21 07:53:52 +00:00
|
|
|
computeForTimeline(store, 'shouldRestoreFocus', false)
|
2018-03-04 20:55:45 +00:00
|
|
|
|
|
|
|
store.compute('firstTimelineItemId', ['timelineItemIds'], (timelineItemIds) => {
|
|
|
|
return timelineItemIds && timelineItemIds[0]
|
|
|
|
})
|
|
|
|
store.compute('lastTimelineItemId', ['timelineItemIds'], (timelineItemIds) => {
|
|
|
|
return timelineItemIds && timelineItemIds[timelineItemIds.length - 1]
|
|
|
|
})
|
2018-01-28 21:09:39 +00:00
|
|
|
|
2018-03-04 20:55:45 +00:00
|
|
|
store.compute('numberOfNotifications',
|
|
|
|
[`timelineData_itemIdsToAdd`, 'currentInstance', 'currentTimeline'],
|
|
|
|
(root, currentInstance, currentTimeline) => {
|
|
|
|
return (
|
|
|
|
currentTimeline !== 'notifications' &&
|
|
|
|
root &&
|
|
|
|
root[currentInstance] &&
|
|
|
|
root[currentInstance].notifications &&
|
|
|
|
root[currentInstance].notifications.length
|
|
|
|
) || 0
|
|
|
|
}
|
|
|
|
)
|
2018-02-10 21:57:04 +00:00
|
|
|
|
2018-03-04 20:55:45 +00:00
|
|
|
store.compute('hasNotifications',
|
|
|
|
['numberOfNotifications'],
|
|
|
|
(numberOfNotifications) => !!numberOfNotifications
|
|
|
|
)
|
2018-02-09 06:29:29 +00:00
|
|
|
}
|