<commit_before>Reflux = require 'reflux'
{Contact,
 Thread,
 Actions,
 DatabaseStore,
 AccountStore,
 FocusedPerspectiveStore,
 ContactStore} = require 'nylas-exports'
_ = require 'underscore'

SearchActions = require './search-actions'

# Stores should closely match the needs of a particular part of the front end.
# For example, we might create a "MessageStore" that observes this store
# for changes in selectedThread, "DatabaseStore" for changes to the underlying database,
# and vends up the array used for that view.

SearchSuggestionStore = Reflux.createStore
  init: ->
    @_query = ""
    @_clearResults()

    @listenTo FocusedPerspectiveStore, @_onPerspectiveChanged
    @listenTo SearchActions.querySubmitted, @_onQuerySubmitted
    @listenTo SearchActions.queryChanged, @_onQueryChanged
    @listenTo SearchActions.searchBlurred, @_onSearchBlurred

  _onPerspectiveChanged: =>
    @_query = FocusedPerspectiveStore.current()?.searchQuery ? ""<commit_msg>Fix search suggestions using old-style store<commit_after>Reflux = require 'reflux'
{Contact,
 Thread,
 Actions,
 DatabaseStore,
 AccountStore,
 FocusedPerspectiveStore,
 ContactStore} = require 'nylas-exports'
_ = require 'underscore'

SearchActions = require './search-actions'

# Stores should closely match the needs of a particular part of the front end.
# For example, we might create a "MessageStore" that observes this store
# for changes in selectedThread, "DatabaseStore" for changes to the underlying database,
# and vends up the array used for that view.

SearchSuggestionStore = Reflux.createStore
  init: ->
    @_query = ""
    @_clearResults()

    @listenTo FocusedPerspectiveStore, @_onPerspectiveChanged
    @listenTo SearchActions.querySubmitted, @_onQuerySubmitted
    @listenTo SearchActions.queryChanged, @_onQueryChanged
    @listenTo SearchActions.searchBlurred, @_onSearchBlurred

  _onPerspectiveChanged: ->
    @_query = FocusedPerspectiveStore.current()?.searchQuery ? ""
{'fraction_non_alphanumeric': 0.08176739461655663, 'fraction_numerical': 0.0, 'mean_word_length': 5.234177215189874, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5711375', 'n_tokens_mistral': 566, 'n_tokens_neox': 539, 'n_words': 169}