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/util/SharingManager.tsx | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

(limited to 'src/client/util/SharingManager.tsx')

diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx
index c2a52cae9..117d7935e 100644
--- a/src/client/util/SharingManager.tsx
+++ b/src/client/util/SharingManager.tsx
@@ -1,13 +1,10 @@
-/* eslint-disable jsx-a11y/label-has-associated-control */
-/* eslint-disable jsx-a11y/no-static-element-interactions */
-/* eslint-disable jsx-a11y/click-events-have-key-events */
 import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
 import { Button, IconButton, Size, Type } from 'browndash-components';
 import { concat, intersection } from 'lodash';
 import { action, computed, makeObservable, observable, runInAction } from 'mobx';
 import { observer } from 'mobx-react';
 import * as React from 'react';
-import Select from 'react-select';
+import Select, { MultiValue } from 'react-select';
 import * as RequestPromise from 'request-promise';
 import { ClientUtils } from '../../ClientUtils';
 import { Utils } from '../../Utils';
@@ -27,6 +24,7 @@ import { SearchUtil } from './SearchUtil';
 import './SharingManager.scss';
 import { SnappingManager } from './SnappingManager';
 import { undoable } from './UndoManager';
+import { LinkManager } from './LinkManager';
 
 export interface User {
     email: string;
@@ -64,7 +62,7 @@ interface ValidatedUser {
 }
 
 @observer
-export class SharingManager extends React.Component<{}> {
+export class SharingManager extends React.Component<object> {
     // eslint-disable-next-line no-use-before-define
     public static Instance: SharingManager;
     private shareDocumentButtonRef: React.RefObject<HTMLButtonElement> = React.createRef(); // ref for the share button, used for the position of the popup
@@ -90,7 +88,7 @@ export class SharingManager extends React.Component<{}> {
     //     return this.targetDoc ? this.targetDoc['acl_' + PublicKey] !== SharingPermissions.None : false;
     // }
 
-    constructor(props: {}) {
+    constructor(props: object) {
         super(props);
         makeObservable(this);
         SharingManager.Instance = this;
@@ -108,8 +106,8 @@ export class SharingManager extends React.Component<{}> {
      * Handles changes in the users selected in react-select
      */
     @action
-    handleUsersChange = (selectedOptions: any) => {
-        this.selectedUsers = selectedOptions as UserOptions[];
+    handleUsersChange = (selectedOptions: MultiValue<UserOptions> /* , actionMeta: ActionMeta<UserOptions> */) => {
+        this.selectedUsers = Array.from(selectedOptions);
     };
 
     /**
@@ -490,12 +488,12 @@ export class SharingManager extends React.Component<{}> {
             const docs = await DocServer.GetRefFields(raw.reduce((list, user) => [...list, user.sharingDocumentId, user.linkDatabaseId], [] as string[]));
             raw.map(
                 action((newUser: User) => {
-                    const sharingDoc = docs[newUser.sharingDocumentId];
-                    const linkDatabase = docs[newUser.linkDatabaseId];
+                    const sharingDoc = docs.get(newUser.sharingDocumentId);
+                    const linkDatabase = docs.get(newUser.linkDatabaseId);
                     if (sharingDoc instanceof Doc && linkDatabase instanceof Doc) {
                         if (!this.users.find(user => user.user.email === newUser.email)) {
                             this.users.push({ user: newUser, sharingDoc, linkDatabase, userColor: StrCast(sharingDoc.userColor) });
-                            // LinkManager.addLinkDB(linkDatabase);
+                            LinkManager.Instance.addLinkDB(linkDatabase);
                         }
                     }
                 })
@@ -539,9 +537,8 @@ export class SharingManager extends React.Component<{}> {
     // eslint-disable-next-line react/no-unused-class-component-methods
     shareWithAddedMember = (group: Doc, emailId: string, retry: boolean = true) => {
         const user = this.users.find(({ user: { email } }) => email === emailId)!;
-        const self = this;
         if (group.docsShared) {
-            if (!user) retry && this.populateUsers().then(() => self.shareWithAddedMember(group, emailId, false));
+            if (!user) retry && this.populateUsers().then(() => this.shareWithAddedMember(group, emailId, false));
             else {
                 DocListCastAsync(user.sharingDoc[storage]).then(userdocs =>
                     DocListCastAsync(group.docsShared).then(dl => {
-- 
cgit v1.2.3-70-g09d2

