main

mattermost/focalboard

Last updated at: 29/12/2023 09:51

searchText.ts

TLDR

This file provides functionality related to managing search text in the application's state using Redux Toolkit.

Methods

getSearchText

This method retrieves the current search text from the application's state.

Classes

None

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import {createSlice, PayloadAction} from '@reduxjs/toolkit'

import {RootState} from './index'

const searchTextSlice = createSlice({
    name: 'searchText',
    initialState: {value: ''} as {value: string},
    reducers: {
        setSearchText: (state, action: PayloadAction<string>) => {
            state.value = action.payload
        },
    },
})

export const {setSearchText} = searchTextSlice.actions
export const {reducer} = searchTextSlice

export function getSearchText(state: RootState): string {
    return state.searchText.value
}