v1.0.31: fix name selection being wiped when refreshProjects fires
Selecting a name called saveCredentials, which sent refreshProjects, which re-fetched users and called populateUsers(users, globalUserId) with globalUserId still empty — immediately clearing the selection. Fix: saveCredentials now updates globalUserId immediately, and refreshProjects is only triggered by token changes (scheduleCredSave), not by name changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -195,11 +195,20 @@
|
||||
userId: document.getElementById("userId").value,
|
||||
};
|
||||
$PI.setGlobalSettings(creds);
|
||||
globalUserId = creds.userId;
|
||||
setCredStatus("Credentials saved.", "ok");
|
||||
if (creds.notionToken) {
|
||||
setStatus("Loading…", "");
|
||||
$PI.sendToPlugin({ event: "refreshProjects", token: creds.notionToken });
|
||||
}
|
||||
}
|
||||
|
||||
function scheduleCredSave() {
|
||||
clearTimeout(credSaveTimer);
|
||||
credSaveTimer = setTimeout(function() {
|
||||
saveCredentials();
|
||||
var token = document.getElementById("notionToken").value.trim();
|
||||
if (token) {
|
||||
setStatus("Loading…", "");
|
||||
$PI.sendToPlugin({ event: "refreshProjects", token: token });
|
||||
}
|
||||
}, 600);
|
||||
}
|
||||
|
||||
function populateUsers(users, userId) {
|
||||
@@ -215,11 +224,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
function scheduleCredSave() {
|
||||
clearTimeout(credSaveTimer);
|
||||
credSaveTimer = setTimeout(saveCredentials, 600);
|
||||
}
|
||||
|
||||
function save() {
|
||||
var sel = document.getElementById("projectSelect");
|
||||
var opt = sel.options[sel.selectedIndex];
|
||||
|
||||
Reference in New Issue
Block a user