Mailspring/packages/client-app/internal_packages/thread-search/lib/search-mailbox-perspective.es6
Juan Tejada de0e30d8dd Revert "[client-app] Limit search to focused perspective"
Temporarily reverting this commit for 1.0.30 release.
See https://phab.nylas.com/T7910 for details
This reverts commit da6bc473f8.
2017-02-28 11:07:44 -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;