Skip to content

Commit

Permalink
Added more logging to chatgpt.clearChats()
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlui committed May 17, 2024
1 parent 2d11474 commit 93b39bc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions chatgpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
const validMethods = ['api', 'dom'];
method = (method || 'dom').trim().toLowerCase(); // set to 'dom' by default
if (method && !validMethods.includes(method))
return console.log(`Method argument must be one of: [${ validMethods }]`);
return console.error(`Method argument must be one of: [${validMethods}]`);

if (method == 'dom') {
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
Expand All @@ -396,6 +396,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
deleteBtn = settingsBtns[settingsBtns.length - 1];
deleteBtn.click(); await delay(10);
document.querySelector('button[class*="danger"').click(); // confirm clear
return console.info('Chats successfully cleared.');
} catch (err) {
console.error(err.message); console.info('Using backend API method instead.');
this.clearChats('api');
Expand All @@ -415,7 +416,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
console.info('Chats successfully cleared'); resolve();
};
xhr.send(JSON.stringify({ is_visible: false }));
}).catch(reject);
}).catch(err => reject(new Error(err.message)));
});
}
},
Expand Down

0 comments on commit 93b39bc

Please sign in to comment.