tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

quick-open.js (1077B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
      4 
      5 /**
      6 * Quick Open reducer
      7 *
      8 * @module reducers/quick-open
      9 */
     10 
     11 import { parseQuickOpenQuery } from "../utils/quick-open";
     12 
     13 export const initialQuickOpenState = () => ({
     14  enabled: false,
     15  query: "",
     16  searchType: "sources",
     17 });
     18 
     19 export default function update(state = initialQuickOpenState(), action) {
     20  switch (action.type) {
     21    case "OPEN_QUICK_OPEN":
     22      if (action.query != null) {
     23        return {
     24          ...state,
     25          enabled: true,
     26          query: action.query,
     27          searchType: parseQuickOpenQuery(action.query),
     28        };
     29      }
     30      return { ...state, enabled: true };
     31    case "CLOSE_QUICK_OPEN":
     32      return initialQuickOpenState();
     33    case "SET_QUICK_OPEN_QUERY":
     34      return {
     35        ...state,
     36        query: action.query,
     37        searchType: parseQuickOpenQuery(action.query),
     38      };
     39    default:
     40      return state;
     41  }
     42 }