diff options
author | bobzel <zzzman@gmail.com> | 2024-09-02 09:26:37 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2024-09-02 09:26:37 -0400 |
commit | cda69e48361fce8d71a4dc66edd9dd976a27f52d (patch) | |
tree | 82b9a1a5967ae88a9534f89f7eaed3aeb289652f /src/client/util/SharingManager.tsx | |
parent | c01828308714874589d1f60c33ca59df4c656c0c (diff) | |
parent | a958577d4c27b276aa37484e3f895e196138b17c (diff) |
Merge branch 'master' into alyssa-starter
Diffstat (limited to 'src/client/util/SharingManager.tsx')
-rw-r--r-- | src/client/util/SharingManager.tsx | 23 |
1 files changed, 10 insertions, 13 deletions
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 => { |