2018-11-01 02:51:56 +08:00
|
|
|
import React from 'react';
|
|
|
|
import getFromUserSettings from '/imports/ui/services/users-settings';
|
|
|
|
|
|
|
|
const withShortcutHelper = (WrappedComponent, param) => (props) => {
|
2024-05-29 21:26:11 +08:00
|
|
|
const BASE_SHORTCUTS = window.meetingClientSettings.public.app.shortcuts;
|
2019-07-22 22:28:13 +08:00
|
|
|
const ENABLED_SHORTCUTS = getFromUserSettings('bbb_shortcuts', null);
|
2018-11-01 02:51:56 +08:00
|
|
|
let shortcuts = Object.values(BASE_SHORTCUTS);
|
|
|
|
|
|
|
|
if (ENABLED_SHORTCUTS) {
|
2019-08-03 02:38:38 +08:00
|
|
|
shortcuts = Object.values(BASE_SHORTCUTS).map((el) => {
|
|
|
|
const obj = { ...el };
|
2020-02-20 02:44:26 +08:00
|
|
|
obj.descId = obj.descId.toLowerCase();
|
2019-08-03 02:38:38 +08:00
|
|
|
return obj;
|
2020-02-20 02:44:26 +08:00
|
|
|
}).filter(el => ENABLED_SHORTCUTS.includes(el.descId.toLowerCase()));
|
2018-11-01 02:51:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (param !== undefined) {
|
|
|
|
if (!Array.isArray(param)) {
|
|
|
|
shortcuts = shortcuts
|
2020-02-20 02:44:26 +08:00
|
|
|
.filter(el => el.descId.toLowerCase() === param.toLowerCase())
|
2018-11-01 02:51:56 +08:00
|
|
|
.map(el => el.accesskey)
|
|
|
|
.pop();
|
|
|
|
} else {
|
|
|
|
shortcuts = shortcuts
|
2020-05-22 02:43:34 +08:00
|
|
|
.filter(el => param.map(p => p.toLowerCase()).includes(el.descId.toLowerCase()))
|
2018-11-01 02:51:56 +08:00
|
|
|
.reduce((acc, current) => {
|
2020-05-26 20:12:57 +08:00
|
|
|
acc[current.descId.toLowerCase()] = current.accesskey;
|
2018-11-01 02:51:56 +08:00
|
|
|
return acc;
|
|
|
|
}, {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<WrappedComponent {...props} shortcuts={shortcuts} />
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default withShortcutHelper;
|