<commit_before>import _ from 'underscore'
import {AccountStore, 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({
      threads: threads,
      categoriesToAdd: (accountId) => {
        const account = AccountStore.accountForId(accountId)
        return [account.defaultFinishedCategory()]
      },
    })
  }
}

export default SearchMailboxPerspective;<commit_msg>[thread-search] Fix archiving from search perspective<commit_after>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({
      threads: threads,
      categoriesToAdd: (accountId) => {
        const account = AccountStore.accountForId(accountId)
        return [account.defaultFinishedCategory()]
      },
      categoriesToRemove: (accountId) => {
        return [CategoryStore.getInboxCategory(accountId)]
      },
    })
  }
}

export default SearchMailboxPerspective;
{'fraction_non_alphanumeric': 0.09609971853638923, 'fraction_numerical': 0.0, 'mean_word_length': 4.067209775967413, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1463362', 'n_tokens_mistral': 707, 'n_tokens_neox': 693, 'n_words': 145}