bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/whiteboard/utils.js
germanocaumo eef565ec81 refactor(whiteboard): lint file and remove unused code
Clean all warning and errors from linter.
2024-09-18 12:21:16 -03:00

41 lines
878 B
JavaScript

import React from 'react';
const usePrevious = (value) => {
const ref = React.useRef();
React.useEffect(() => {
ref.current = value;
}, [value]);
return ref.current;
};
const isValidShapeType = (shape) => {
const invalidTypes = ['image', 'embed'];
return !invalidTypes.includes(shape?.type);
};
// map different localeCodes from bbb to tldraw
const mapLanguage = (language) => {
// bbb has xx-xx but in tldraw it's only xx
if (['es', 'fa', 'it', 'pl', 'sv', 'uk'].some((lang) => language.startsWith(lang))) {
return language.substring(0, 2);
}
// exceptions
switch (language) {
case 'nb-no':
return 'no';
case 'zh-cn':
return 'zh-ch';
default:
return language;
}
};
const Utils = {
usePrevious, mapLanguage, isValidShapeType,
};
export default Utils;
export {
usePrevious, mapLanguage, isValidShapeType,
};