import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { Menu, SearchBar, ListensToFluxStore } from 'nylas-component-kit'; import { FocusedPerspectiveStore } from 'nylas-exports'; import SearchStore from './search-store'; import SearchActions from './search-actions'; class ThreadSearchBar extends Component { static displayName = 'ThreadSearchBar'; static propTypes = { query: PropTypes.string, isSearching: PropTypes.bool, suggestions: PropTypes.array, perspective: PropTypes.object, }; _onSelectSuggestion = suggestion => { if (suggestion.thread) { SearchActions.querySubmitted(`"${suggestion.thread.subject}"`); } else { SearchActions.querySubmitted(suggestion.value); } }; _onSearchQueryChanged = query => { SearchActions.queryChanged(query); if (query === '') { this._onClearSearchQuery(); } }; _onSubmitSearchQuery = query => { SearchActions.querySubmitted(query); }; _onClearSearchQuery = () => { SearchActions.querySubmitted(''); }; _onClearSearchSuggestions = () => { SearchActions.searchBlurred(); }; _renderSuggestion = suggestion => { if (suggestion.contact) { return