Mailspring/internal_packages/sidebar-inbox-internal/lib/internal-admin-store.coffee
Ben Gotow dff5465931 fix(*) Small visual tweaks and fixes - see summary
Summary:
ThreadStore should be done loading as soon as threads are available

SearchSuggestionStore should use ContactsStore for contact results

Contact Store should not "filter all, take 10" it should only filter until it has 10. It should also check against "Ben Gotow" as well as "Ben" and "Gotow", so I can type "Ben Go"

Sometimes participants are "Ben Gotow <ben@g.com>", "ben@g.com". If we get zero contacts after removing Me, put "Me" back in...

Fix "Update Available" notification, broken reference to `atom.views.getView(atom.workspace)`

A bit more debugging around cursors. Need to handle this case soon.

Only use atomWorkspace if it exists.

Fix for dragging next to / around toolbar window controls

Consolidate the display of Contacts in menus into a single MenuItem subclass

Update Template Popover styling

fetchFromCache should only remove thread loading indicator *IF* it found results in the cache. Doh...

Give the thread list "Name" column a fixed width (mg)

Better styling of message list collapsed mode, rage against user selection and cursor: pointer

Occasionally admin.inboxapp.com returns bogus data

Sebaastian feedback on thread list

Test Plan: Run tests

Reviewers: evan

Reviewed By: evan

Differential Revision: https://review.inboxapp.com/D1350
2015-03-25 18:22:52 -07:00

80 lines
2.1 KiB
CoffeeScript

_ = require 'underscore-plus'
Reflux = require 'reflux'
request = require 'request'
{FocusedContactsStore, NamespaceStore} = require 'inbox-exports'
module.exports =
FullContactStore = Reflux.createStore
init: ->
@_accountCache = null
@_applicationCache = null
@_enabled = false
@_error = null
@listenTo FocusedContactsStore, @_onFocusedContacts
@listenTo NamespaceStore, @_onNamespaceChanged
@_onNamespaceChanged()
dataForFocusedContact: ->
return {loading: true} if @_accountCache is null or @_applicationCache is null
contact = FocusedContactsStore.focusedContact()
return {} unless contact
account = _.find @_accountCache, (account) -> account.email is contact.email
apps = undefined
if account
apps = @_applicationCache.accounts["#{account.id}"]
{account, apps}
enabled: ->
@_enabled
error: ->
@_error
_onFocusedContacts: ->
@trigger(@)
_onNamespaceChanged: ->
clearInterval(@_fetchInterval) if @_fetchInterval
@_fetchInterval = null
n = NamespaceStore.current()
if n and n.emailAddress.indexOf('@nilas.com') > 0
@_fetchInterval = setInterval(( => @_fetchAPIData()), 5 * 60 * 1000)
@_fetchAPIData()
@_enabled = true
else
@_accountCache = null
@_applicationCache = null
@_enabled = false
@trigger(@)
_fetchAPIData: ->
console.log('Fetching Internal Admin Data')
# Swap the url's to see real data
request 'https://admin.inboxapp.com/api/status/accounts', (err, resp, data) =>
if err
@_error = err
else
@_error = null
try
@_accountCache = JSON.parse(data)
catch err
@_error = err
@_accountCache = null
@trigger(@)
# Swap the url's to see real data
request 'https://admin.inboxapp.com/api/status/accounts/applications', (err, resp, data) =>
if err
@_error = err
else
@_error = null
try
@_applicationCache = JSON.parse(data)
catch err
@_error = err
@_applicationCache = null
@trigger(@)