Skip to content

Commit

Permalink
fix(manager): paste only trigger copy and move, not include delete
Browse files Browse the repository at this point in the history
  • Loading branch information
ElonH committed Jun 1, 2020
1 parent 2b2a94d commit 180ff3a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
10 changes: 8 additions & 2 deletions src/app/pages/manager/clipboard/clipboard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,14 @@ export class Clipboard {
return this.data.size;
}

public clear() {
this.data.clear();
public clear(...opers: IManipulate[]) {
if (opers.length === 0) this.data.clear();
else
this.values
.filter((x) => opers.some((y) => x.oper === y))
.forEach((x) => {
this.data.delete(x.key);
});
}

public static genKey(remote: string, path: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/manager/manager.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export class ManagerComponent implements OnInit {
private pasteDeploy() {
this.pasteTrigger.pipe(withLatestFrom(this.nav$.getOutput())).subscribe(([, dstNode]) => {
if (dstNode[1].length !== 0) throw Error("can't not get destination.");
this.taskService.createTask(dstNode[0]);
this.taskService.createTask(dstNode[0], 'copy', 'move');
});
}

Expand Down
23 changes: 14 additions & 9 deletions src/app/pages/manager/tasks/task.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import {
OperationsMovefileFlow,
OperationsMovefileFlowInNode,
} from 'src/app/@dataflow/rclone';
import { ClipboardService, Clipboard, ClipboardItem } from '../clipboard/clipboard.service';
import {
ClipboardService,
Clipboard,
ClipboardItem,
IManipulate,
} from '../clipboard/clipboard.service';
import { Subject, from, Observable } from 'rxjs';
import {
withLatestFrom,
Expand All @@ -33,20 +38,20 @@ export abstract class TasksPoolFlow extends NothingFlow<TasksPoolNode> {}
providedIn: 'root',
})
export class TaskService {
private createTrigger = new Subject<NavigationFlowOutNode>();
public createTask(dst: NavigationFlowOutNode) {
this.createTrigger.next(dst);
private createTrigger = new Subject<[NavigationFlowOutNode, IManipulate[]]>();
public createTask(dst: NavigationFlowOutNode, ...opers: IManipulate[]) {
this.createTrigger.next([dst, opers]);
}

private deployCreate() {
this.createTrigger
.pipe(withLatestFrom(this.cbService.clipboard$.getOutput()))
.subscribe(([dst, cbNode]) => {
.subscribe(([[dst, opers], cbNode]) => {
if (cbNode[1].length !== 0) return;
cbNode[0].clipboard.values.forEach((x) =>
this.tasksPool.add(x.oper, x.srcRemote, x.srcItem, dst)
);
this.cbService.clear();
cbNode[0].clipboard.values
.filter((x) => opers.some((y) => y === x.oper))
.forEach((x) => this.tasksPool.add(x.oper, x.srcRemote, x.srcItem, dst));
this.cbService.clear(...opers);
this.cbService.commit();
this.postTrigger.next(1);
});
Expand Down

0 comments on commit 180ff3a

Please sign in to comment.