aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/DocumentDecorations.tsx
diff options
context:
space:
mode:
authorMohammad Amoush <muhammedamoush@gmail.com>2019-12-07 16:57:51 -0500
committerMohammad Amoush <muhammedamoush@gmail.com>2019-12-07 16:57:51 -0500
commit01c131e8d7ecc2eac68e16a679c40b1156b41391 (patch)
tree6b35ba68c75979170bc4a14e8147157b8a7140ca /src/client/views/DocumentDecorations.tsx
parent40c40d377ec169b44e1a9691129e5c7a6b0b10e4 (diff)
Adding hang-up functionality
Diffstat (limited to 'src/client/views/DocumentDecorations.tsx')
-rw-r--r--src/client/views/DocumentDecorations.tsx16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx
index b46caf3ea..719a0203b 100644
--- a/src/client/views/DocumentDecorations.tsx
+++ b/src/client/views/DocumentDecorations.tsx
@@ -39,6 +39,8 @@ library.add(faCloudUploadAlt);
library.add(faSyncAlt);
library.add(faShare);
+export type CloseCall = (toBeDeleted: DocumentView[]) => void;
+
@observer
export class DocumentDecorations extends React.Component<{}, { value: string }> {
static Instance: DocumentDecorations;
@@ -69,6 +71,8 @@ export class DocumentDecorations extends React.Component<{}, { value: string }>
@observable public isAnimatingFetch = false;
@observable public isAnimatingPulse = false;
@observable public openHover = false;
+ @observable private addedCloseCalls: CloseCall[] = [];
+
constructor(props: Readonly<{}>) {
super(props);
@@ -77,6 +81,14 @@ export class DocumentDecorations extends React.Component<{}, { value: string }>
reaction(() => SelectionManager.SelectedDocuments().slice(), docs => this._edtingTitle = false);
}
+ addCloseCall = (handler: CloseCall) => {
+ const currentOffset = this.addedCloseCalls.length - 1;
+ this.addedCloseCalls.push((toBeDeleted: DocumentView[]) => {
+ this.addedCloseCalls.splice(currentOffset, 1);
+ handler(toBeDeleted);
+ });
+ }
+
@action titleChanged = (event: any) => { this._title = event.target.value; };
@action titleBlur = () => { this._edtingTitle = false; };
@action titleEntered = (e: any) => {
@@ -239,10 +251,12 @@ export class DocumentDecorations extends React.Component<{}, { value: string }>
e.stopPropagation();
if (e.button === 0) {
const recent = Cast(CurrentUserUtils.UserDocument.recentlyClosed, Doc) as Doc;
- SelectionManager.SelectedDocuments().map(dv => {
+ const selectedDocuments = SelectionManager.SelectedDocuments();
+ selectedDocuments.map(dv => {
recent && Doc.AddDocToList(recent, "data", dv.props.Document, undefined, true, true);
dv.props.removeDocument && dv.props.removeDocument(dv.props.Document);
});
+ this.addedCloseCalls.forEach(handler => handler(selectedDocuments));
SelectionManager.DeselectAll();
document.removeEventListener("pointermove", this.onCloseMove);
document.removeEventListener("pointerup", this.onCloseUp);