From 4574b7f03ccc85c4bebdbfd9475788456086704f Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 8 Aug 2024 12:27:40 -0400
Subject: many changes to add typing in place of 'any's etc

---
 src/client/views/OverlayView.tsx | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

(limited to 'src/client/views/OverlayView.tsx')

diff --git a/src/client/views/OverlayView.tsx b/src/client/views/OverlayView.tsx
index a7907a565..7bf10467e 100644
--- a/src/client/views/OverlayView.tsx
+++ b/src/client/views/OverlayView.tsx
@@ -3,6 +3,7 @@ import { observer } from 'mobx-react';
 import { computedFn } from 'mobx-utils';
 import * as React from 'react';
 import ReactLoading from 'react-loading';
+import ResizeObserver from 'resize-observer-polyfill';
 import { returnEmptyDoclist, returnEmptyFilter, returnTrue, setupMoveUpEvents } from '../../ClientUtils';
 import { Utils, emptyFunction } from '../../Utils';
 import { Doc } from '../../fields/Doc';
@@ -18,8 +19,6 @@ import './OverlayView.scss';
 import { DefaultStyleProvider } from './StyleProvider';
 import { DocumentView, DocumentViewInternal } from './nodes/DocumentView';
 
-const _global = (window /* browser */ || global) /* node */ as any;
-
 export type OverlayDisposer = () => void;
 
 export type OverlayElementOptions = {
@@ -109,19 +108,19 @@ export class OverlayWindow extends ObservableReactComponent<OverlayWindowProps>
 }
 
 @observer
-export class OverlayView extends ObservableReactComponent<{}> {
+export class OverlayView extends ObservableReactComponent<object> {
     // eslint-disable-next-line no-use-before-define
     public static Instance: OverlayView;
     @observable.shallow _elements: JSX.Element[] = [];
 
-    constructor(props: any) {
+    constructor(props: object) {
         super(props);
         makeObservable(this);
         if (!OverlayView.Instance) {
             OverlayView.Instance = this;
-            new _global.ResizeObserver(
-                action((entries: any) => {
-                    Array.from(entries).forEach((entry: any) => {
+            new ResizeObserver(
+                action(entries => {
+                    Array.from(entries).forEach(entry => {
                         Doc.MyOverlayDocs.forEach(docIn => {
                             const doc = docIn;
                             if (NumCast(doc.overlayX) > entry.contentRect.width - 10) {
@@ -162,17 +161,17 @@ export class OverlayView extends ObservableReactComponent<{}> {
 
     @action
     addWindow(contents: JSX.Element, options: OverlayElementOptions): OverlayDisposer {
-        const remove = action(() => {
-            const index = this._elements.indexOf(contents);
+        const remove = action((wincontents: JSX.Element) => {
+            const index = this._elements.indexOf(wincontents);
             if (index !== -1) this._elements.splice(index, 1);
         });
         const wincontents = (
-            <OverlayWindow onClick={remove} key={Utils.GenerateGuid()} overlayOptions={options}>
+            <OverlayWindow onClick={() => remove(wincontents)} key={Utils.GenerateGuid()} overlayOptions={options}>
                 {contents}
             </OverlayWindow>
         );
         this._elements.push(wincontents);
-        return remove;
+        return () => remove(wincontents);
     }
 
     removeOverlayDoc = (docs: Doc | Doc[]) => toList(docs).every(Doc.RemFromMyOverlay);
-- 
cgit v1.2.3-70-g09d2

