"Fossies" - the Fresh Open Source Software Archive

Member "jitsi-meet-7319/react/features/base/jwt/reducer.ts" (6 Jun 2023, 1153 Bytes) of package /linux/misc/jitsi-meet-7319.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 import ReducerRegistry from '../redux/ReducerRegistry';
    2 import { equals } from '../redux/functions';
    3 
    4 import { SET_JWT } from './actionTypes';
    5 
    6 export interface IJwtState {
    7     callee?: {
    8         name: string;
    9     };
   10     group?: string;
   11     jwt?: string;
   12     server?: string;
   13     tenant?: string;
   14     user?: {
   15         id: string;
   16         name: string;
   17     };
   18 }
   19 
   20 /**
   21  * Reduces redux actions which affect the JSON Web Token (JWT) stored in the
   22  * redux store.
   23  *
   24  * @param {Object} state - The current redux state.
   25  * @param {Object} action - The redux action to reduce.
   26  * @returns {Object} The next redux state which is the result of reducing the
   27  * specified {@code action}.
   28  */
   29 ReducerRegistry.register<IJwtState>(
   30     'features/base/jwt',
   31     (state = {}, action): IJwtState => {
   32         switch (action.type) {
   33         case SET_JWT: {
   34             // eslint-disable-next-line @typescript-eslint/no-unused-vars
   35             const { type, ...payload } = action;
   36             const nextState = {
   37                 ...payload
   38             };
   39 
   40             return equals(state, nextState) ? state : nextState;
   41         }
   42         }
   43 
   44         return state;
   45     });