• Robert Knight's avatar
    Fix `groups.focused()` error if localStorage is empty when client loads · 2fef71a3
    Robert Knight authored
    If the client started and local storage did not contain a saved
    last-viewed group ID, then `groups.load()` would attempt to call
    `store.focusGroup(null)`. As a result subsequent calls to
    `groups.focused()` would return null and code in various places in the
    application expects that there will always be a focused group.
    
    Fix the problem by not setting the focus group after groups are fetched
    unless the previously-focused group was set and exists in the new
    groups list.
    
    Also improve the behavior of `store.focusGroup` by making it leave the
    focused group untouched if the specified group has not been loaded, but
    log an error so we'll know (via Sentry) if it happens again.
    
    Fixes #750
    2fef71a3
groups.js 2.16 KB