"Fossies" - the Fresh Open Source Software Archive 
Member "jitsi-meet-7315/react/features/reactions/reducer.ts" (2 Jun 2023, 2649 Bytes) of package /linux/misc/jitsi-meet-7315.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 '../base/redux/ReducerRegistry';
2
3 import {
4 ADD_REACTION_BUFFER,
5 FLUSH_REACTION_BUFFER,
6 SET_REACTION_QUEUE,
7 SHOW_SOUNDS_NOTIFICATION,
8 TOGGLE_REACTIONS_VISIBLE
9 } from './actionTypes';
10 import { IReactionEmojiProps } from './constants';
11
12 export interface IReactionsState {
13
14 /**
15 * An array that contains the reactions buffer to be sent.
16 */
17 buffer: Array<string>;
18
19 /**
20 * Whether or not the disable reaction sounds notification was shown.
21 */
22 notificationDisplayed: boolean;
23
24 /**
25 * The array of reactions to animate.
26 */
27 queue: Array<IReactionEmojiProps>;
28
29 /**
30 * A number, non-zero value which identifies the timer created by a call
31 * to setTimeout().
32 */
33 timeoutID: number | null;
34
35 /**
36 * The indicator that determines whether the reactions menu is visible.
37 */
38 visible: boolean;
39 }
40
41 export interface IReactionsAction extends Partial<IReactionsState> {
42
43 /**
44 * The message to be added to the chat.
45 */
46 message?: string;
47
48 /**
49 * The reaction to be added to buffer.
50 */
51 reaction?: string;
52
53 /**
54 * The reactions to be added to the animation queue.
55 */
56 reactions?: Array<string>;
57
58 /**
59 * The action type.
60 */
61 type: string;
62 }
63
64 /**
65 * Returns initial state for reactions' part of Redux store.
66 *
67 * @private
68 * @returns {IReactionsState}
69 */
70 function _getInitialState(): IReactionsState {
71 return {
72 visible: false,
73 buffer: [],
74 timeoutID: null,
75 queue: [],
76 notificationDisplayed: false
77 };
78 }
79
80 ReducerRegistry.register<IReactionsState>(
81 'features/reactions',
82 (state = _getInitialState(), action: IReactionsAction): IReactionsState => {
83 switch (action.type) {
84
85 case TOGGLE_REACTIONS_VISIBLE:
86 return {
87 ...state,
88 visible: !state.visible
89 };
90
91 case ADD_REACTION_BUFFER:
92 return {
93 ...state,
94 buffer: action.buffer ?? [],
95 timeoutID: action.timeoutID ?? null
96 };
97
98 case FLUSH_REACTION_BUFFER:
99 return {
100 ...state,
101 buffer: [],
102 timeoutID: null
103 };
104
105 case SET_REACTION_QUEUE: {
106 return {
107 ...state,
108 queue: action.queue ?? []
109 };
110 }
111
112 case SHOW_SOUNDS_NOTIFICATION: {
113 return {
114 ...state,
115 notificationDisplayed: true
116 };
117 }
118 }
119
120 return state;
121 });