Mailspring/packages/client-app/internal_packages/thread-search/lib/search-mailbox-perspective.es6
Juan Tejada 90e49d31aa [client-app] Measure and report times for removing from inbox
Summary:
This commit adds a new action, `removeThreadsFromView` to be proxied and
measured through the ThreadListActionsStore

This action can encompass many different actions, e.g.:
- unstarring in starred view
- changing unread in unread view
- Moving to inbox from trash
- archiving a search result (which won't actually remove it from the thread-list)

However, for now, we are only interested in timing actions that remove threads
from the inbox

Depends on D3983

Test Plan: manual

Reviewers: halla, spang, evan

Reviewed By: spang, evan

Differential Revision: https://phab.nylas.com/D3984
2017-02-21 11:53:38 -08:00

49 lines
1.3 KiB
JavaScript

import _ from 'underscore'
import {AccountStore, CategoryStore, TaskFactory, MailboxPerspective} from 'nylas-exports'
import SearchQuerySubscription from './search-query-subscription'
class SearchMailboxPerspective extends MailboxPerspective {
constructor(accountIds, searchQuery) {
super(accountIds)
this.searchQuery = searchQuery
this.name = 'Search'
if (!_.isString(this.searchQuery)) {
throw new Error("SearchMailboxPerspective: Expected a `string` search query")
}
}
emptyMessage() {
return "No search results available"
}
isEqual(other) {
return super.isEqual(other) && other.searchQuery === this.searchQuery
}
threads() {
return new SearchQuerySubscription(this.searchQuery, this.accountIds)
}
canReceiveThreadsFromAccountIds() {
return false
}
tasksForRemovingItems(threads) {
return TaskFactory.tasksForApplyingCategories({
source: "Removing from Search Results",
threads: threads,
categoriesToAdd: (accountId) => {
const account = AccountStore.accountForId(accountId)
return [account.defaultFinishedCategory()]
},
categoriesToRemove: (accountId) => {
return [CategoryStore.getInboxCategory(accountId)]
},
})
}
}
export default SearchMailboxPerspective;