-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathloadMoreAssets.ts
More file actions
47 lines (41 loc) · 1.22 KB
/
loadMoreAssets.ts
File metadata and controls
47 lines (41 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import * as vscode from "vscode";
import { CloudinaryTreeDataProvider } from "../tree/treeDataProvider";
/**
* Registers the 'load more assets' command to handle pagination in the Cloudinary tree.
* @param context - VS Code extension context.
* @param provider - Instance of CloudinaryTreeDataProvider used to fetch and update asset nodes.
*/
function registerLoadMore(
context: vscode.ExtensionContext,
provider: CloudinaryTreeDataProvider
) {
context.subscriptions.push(
vscode.commands.registerCommand(
"cloudinary.loadMoreAssets",
async (folderPath: string, nextCursor: string) => {
if (!nextCursor) {
vscode.window.showErrorMessage("No more assets to load.");
return;
}
const newAssets = await provider.fetchFoldersAndAssets(
folderPath,
nextCursor,
true
);
if (newAssets.length === 0) {
vscode.window.showErrorMessage("No additional assets found.");
return;
}
provider.updateLoadMoreItem(folderPath, nextCursor);
provider.refresh(
{
folderPath,
nextCursor
},
true
);
}
)
);
}
export default registerLoadMore;