fix memory leak | add missing select style

This commit is contained in:
KDSBrowne 2023-02-24 23:00:15 +00:00
parent 811095a913
commit d69b535780
2 changed files with 26 additions and 2 deletions

View File

@ -103,6 +103,11 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
background-color: #FFF !important;
color: #000 !important;
}
.select {
background-color: rgba(66, 133, 244, 1) !important;
color: #FFF !important;
}
</style>
<script>
document.addEventListener('gesturestart', function (e) {

View File

@ -190,6 +190,25 @@ export default function Whiteboard(props) {
const [isMoving, setIsMoving] = React.useState(false);
const [isPanning, setIsPanning] = React.useState(shortcutPanning);
const [panSelected, setPanSelected] = React.useState(isPanning);
const isMountedRef = React.useRef(true);
React.useEffect(() => {
return () => {
isMountedRef.current = false;
};
}, []);
const setSafeTLDrawAPI = (api) => {
if (isMountedRef.current) {
setTLDrawAPI(api);
}
};
const setSafeCurrentTool = (tool) => {
if (isMountedRef.current) {
setCurrentTool(tool);
}
};
const toggleOffCheck = (evt) => {
const clickedElement = evt.target;
@ -713,7 +732,7 @@ export default function Whiteboard(props) {
const onMount = (app) => {
const menu = document.getElementById("TD-Styles")?.parentElement;
setCurrentTool('select');
setSafeCurrentTool('select');
if (menu) {
const MENU_OFFSET = `48px`;
@ -742,7 +761,7 @@ export default function Whiteboard(props) {
}
);
setTLDrawAPI(app);
setSafeTLDrawAPI(app);
props.setTldrawAPI(app);
// disable for non presenter that doesn't have multi user access
if (!hasWBAccess && !isPresenter) {