Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/client/file.ts
1503 views
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { redux } from "../app-framework";
7
import { required, defaults } from "@cocalc/util/misc";
8
9
export class FileClient {
10
constructor() {}
11
12
// Returns true if the given file in the given project is currently
13
// marked as deleted.
14
public is_deleted(path: string, project_id: string): boolean {
15
return !!redux
16
.getProjectStore(project_id)
17
?.get("recentlyDeletedPaths")
18
?.get(path);
19
}
20
21
public set_deleted(_filename, _project_id): void {
22
throw Error("set_deleted doesn't make sense for the frontend");
23
}
24
25
// Mark the given file with the given action.
26
public async mark_file(opts: {
27
project_id: string;
28
path: string;
29
action: string;
30
ttl?: number;
31
}): Promise<void> {
32
opts = defaults(opts, {
33
project_id: required,
34
path: required,
35
action: required,
36
ttl: 120,
37
});
38
await redux
39
.getActions("file_use")
40
?.mark_file(opts.project_id, opts.path, opts.action, opts.ttl);
41
}
42
}
43
44