"Fossies" - the Fresh Open Source Software Archive

Member "jitsi-meet-7543/react/features/base/responsive-ui/reducer.ts" (23 Sep 2023, 1842 Bytes) of package /linux/misc/jitsi-meet-7543.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 { set } from '../redux/functions';
    3 
    4 import {
    5     CLIENT_RESIZED,
    6     SAFE_AREA_INSETS_CHANGED,
    7     SET_ASPECT_RATIO,
    8     SET_CONTEXT_MENU_OPEN,
    9     SET_NARROW_LAYOUT,
   10     SET_REDUCED_UI
   11 } from './actionTypes';
   12 import { ASPECT_RATIO_NARROW } from './constants';
   13 
   14 const {
   15     innerHeight = 0,
   16     innerWidth = 0
   17 } = window;
   18 
   19 /**
   20  * The default/initial redux state of the feature base/responsive-ui.
   21  */
   22 const DEFAULT_STATE = {
   23     aspectRatio: ASPECT_RATIO_NARROW,
   24     clientHeight: innerHeight,
   25     clientWidth: innerWidth,
   26     isNarrowLayout: false,
   27     reducedUI: false,
   28     contextMenuOpened: false
   29 };
   30 
   31 export interface IResponsiveUIState {
   32     aspectRatio: Symbol;
   33     clientHeight: number;
   34     clientWidth: number;
   35     contextMenuOpened: boolean;
   36     isNarrowLayout: boolean;
   37     reducedUI: boolean;
   38     safeAreaInsets?: {
   39         bottom: number;
   40         left: number;
   41         right: number;
   42         top: number;
   43     };
   44 }
   45 
   46 ReducerRegistry.register<IResponsiveUIState>('features/base/responsive-ui',
   47 (state = DEFAULT_STATE, action): IResponsiveUIState => {
   48     switch (action.type) {
   49     case CLIENT_RESIZED: {
   50         return {
   51             ...state,
   52             clientWidth: action.clientWidth,
   53             clientHeight: action.clientHeight
   54         };
   55     }
   56 
   57     case SAFE_AREA_INSETS_CHANGED:
   58         return {
   59             ...state,
   60             safeAreaInsets: action.insets
   61         };
   62 
   63     case SET_ASPECT_RATIO:
   64         return set(state, 'aspectRatio', action.aspectRatio);
   65 
   66     case SET_REDUCED_UI:
   67         return set(state, 'reducedUI', action.reducedUI);
   68 
   69     case SET_CONTEXT_MENU_OPEN:
   70         return set(state, 'contextMenuOpened', action.isOpen);
   71 
   72     case SET_NARROW_LAYOUT:
   73         return set(state, 'isNarrowLayout', action.isNarrow);
   74     }
   75 
   76     return state;
   77 });