aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/DocumentDecorations.tsx
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2020-02-10 10:42:00 -0500
committerbob <bcz@cs.brown.edu>2020-02-10 10:42:00 -0500
commit4bf20cf3d17989f7e5aa99c405bad96227f16fde (patch)
tree8e22e1e85c1c17425f14953ee64311b9488312a0 /src/client/views/DocumentDecorations.tsx
parent79d701589ff4bee4d7534b7112b4f959af743769 (diff)
parenta411e92f6e7b486108f5d06564a2cdbbe91ae5ad (diff)
Merge branch 'master' into new_importer
Diffstat (limited to 'src/client/views/DocumentDecorations.tsx')
-rw-r--r--src/client/views/DocumentDecorations.tsx14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx
index a0ba16ea4..4ec1659cc 100644
--- a/src/client/views/DocumentDecorations.tsx
+++ b/src/client/views/DocumentDecorations.tsx
@@ -35,6 +35,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;
@@ -59,6 +61,8 @@ export class DocumentDecorations extends React.Component<{}, { value: string }>
@observable public pullIcon: IconProp = "arrow-alt-circle-down";
@observable public pullColor: string = "white";
@observable public openHover = false;
+ @observable private addedCloseCalls: CloseCall[] = [];
+
constructor(props: Readonly<{}>) {
super(props);
@@ -69,6 +73,14 @@ export class DocumentDecorations extends React.Component<{}, { value: string }>
@action titleChanged = (event: any) => this._accumulatedTitle = event.target.value;
+ addCloseCall = (handler: CloseCall) => {
+ const currentOffset = this.addedCloseCalls.length - 1;
+ this.addedCloseCalls.push((toBeDeleted: DocumentView[]) => {
+ this.addedCloseCalls.splice(currentOffset, 1);
+ handler(toBeDeleted);
+ });
+ }
+
titleBlur = undoBatch(action((commit: boolean) => {
this._edtingTitle = false;
if (commit) {
@@ -225,6 +237,8 @@ export class DocumentDecorations extends React.Component<{}, { value: string }>
const recent = Cast(CurrentUserUtils.UserDocument.recentlyClosed, Doc) as Doc;
const selected = SelectionManager.SelectedDocuments().slice();
SelectionManager.DeselectAll();
+ this.addedCloseCalls.forEach(handler => handler(selected));
+
selected.map(dv => {
recent && Doc.AddDocToList(recent, "data", dv.props.Document, undefined, true, true);
dv.props.removeDocument && dv.props.removeDocument(dv.props.Document);