snapshot of https://github.com/jitsi/jitsi-meet.git @ fd1749dd28f4138aa80234fc7f311b19aaffa0e7 (2026-09-15)
This commit is contained in:
50
react/features/base/tooltip/reducer.ts
Normal file
50
react/features/base/tooltip/reducer.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import ReducerRegistry from '../redux/ReducerRegistry';
|
||||
|
||||
import { HIDE_TOOLTIP, SHOW_TOOLTIP } from './actionTypes';
|
||||
|
||||
export interface ITooltipState {
|
||||
content: string;
|
||||
previousContent: string;
|
||||
visible: boolean;
|
||||
}
|
||||
|
||||
const DEFAULT_STATE = {
|
||||
content: '',
|
||||
previousContent: '',
|
||||
visible: false
|
||||
};
|
||||
|
||||
/**
|
||||
* Reduces redux actions which mark the tooltip as displayed or hidden.
|
||||
*
|
||||
* @param {IDialogState} state - The current redux state.
|
||||
* @param {Action} action - The redux action to reduce.
|
||||
* @param {string} action.type - The type of the redux action to reduce..
|
||||
* @returns {State} The next redux state that is the result of reducing the
|
||||
* specified action.
|
||||
*/
|
||||
ReducerRegistry.register<ITooltipState>('features/base/tooltip', (state = DEFAULT_STATE, action): ITooltipState => {
|
||||
switch (action.type) {
|
||||
case SHOW_TOOLTIP:
|
||||
return {
|
||||
content: action.content,
|
||||
previousContent: state.content,
|
||||
visible: true
|
||||
};
|
||||
case HIDE_TOOLTIP: {
|
||||
// The tooltip can be marked as hidden only if the hide action
|
||||
// is dispatched by the tooltip that is displayed.
|
||||
if (action.content === state.content) {
|
||||
return {
|
||||
content: '',
|
||||
previousContent: '',
|
||||
visible: false
|
||||
};
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
return state;
|
||||
});
|
||||
Reference in New Issue
Block a user