mirror of
https://github.com/Iheuzio/gpt-contextfiles.git
synced 2025-07-18 14:00:48 +00:00
fix(redundant-code): Fixing redundant code
This commit is contained in:
parent
572b4a39f7
commit
b756de10e4
36
extension.js
36
extension.js
@ -268,7 +268,24 @@ function activate(context) {
|
||||
};
|
||||
webviewView.webview.html = getWebviewContent();
|
||||
webviewView.webview.onDidReceiveMessage(async message => {
|
||||
if (message.command === 'submitQuestion') {
|
||||
if (message.command === 'toggleFileSelection') {
|
||||
const uri = message.uri;
|
||||
const file = selectedFiles.find(file => file.uri.fsPath === uri);
|
||||
if (file) {
|
||||
file.toggleSelected();
|
||||
fileDataProvider.refresh();
|
||||
}
|
||||
} else if (message.command === 'clearSelectedFiles') {
|
||||
const clearedFiles = selectedFiles.filter(file => file.selected === false);
|
||||
selectedFiles.length = 0; // Clear the array
|
||||
clearedFiles.forEach(file => {
|
||||
fileDataProvider.refresh();
|
||||
});
|
||||
webviewView.webview.html = getWebviewContent();
|
||||
} else if (message.command === 'refreshFiles') {
|
||||
fileDataProvider.refresh();
|
||||
webviewView.webview.html = getWebviewContent();
|
||||
} else if (message.command === 'submitQuestion') {
|
||||
const question = message.text;
|
||||
const selectedUris = message.selectedUris;
|
||||
|
||||
@ -313,23 +330,6 @@ function activate(context) {
|
||||
console.error("Failed to get OpenAI response:", error);
|
||||
webviewView.webview.html = getWebviewContent(`Failed to get response from OpenAI API. Error: ${error.message}`, question);
|
||||
}
|
||||
} else if (message.command === 'toggleFileSelection') {
|
||||
const uri = message.uri;
|
||||
const file = selectedFiles.find(file => file.uri.fsPath === uri);
|
||||
if (file) {
|
||||
file.toggleSelected();
|
||||
fileDataProvider.refresh();
|
||||
}
|
||||
} else if (message.command === 'clearSelectedFiles') {
|
||||
const clearedFiles = selectedFiles.filter(file => file.selected === false);
|
||||
selectedFiles.length = 0; // Clear the array
|
||||
clearedFiles.forEach(file => {
|
||||
fileDataProvider.refresh();
|
||||
});
|
||||
webviewView.webview.html = getWebviewContent();
|
||||
} else if (message.command === 'refreshFiles') {
|
||||
fileDataProvider.refresh();
|
||||
webviewView.webview.html = getWebviewContent();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user