aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/SharingManager.tsx
diff options
context:
space:
mode:
authorNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2024-10-01 03:58:47 -0400
committerNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2024-10-01 03:58:47 -0400
commit6d35629dd8f997208130981aac1daf36bc83b134 (patch)
tree7b7e3baac15e5f7b4fcb48d90372c48d4552ae4c /src/client/util/SharingManager.tsx
parentcf45abf8ada938caddb226c825166d4acdee3086 (diff)
parentba01c7376ed4a2b817a26a430faf4041524aef35 (diff)
Merge branch 'master' of https://github.com/brown-dash/Dash-Web into nathan-starter
Diffstat (limited to 'src/client/util/SharingManager.tsx')
-rw-r--r--src/client/util/SharingManager.tsx23
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 => {