I want to catch google.script.run while it is running, so I can block the user from clicking and activating the function multiple times.
Is something like this possible?
while(google.script.run.function()){
alert("Wait for the function to finish")
}
Disabling a button:
function lfunko() {
return "Button is disabled"
}
function launchMyDialog() {
const html = '<input type="button" id="btn" value="Click Me" onclick="myfunk();" /><div id="msg"></div><script>function myfunk(){document.getElementById("btn").disabled = true;google.script.run.withSuccessHandler((msg) => {document.getElementById("msg").innerHTML = msg;}).lfunko();}console.log("Code");</script>';
SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutput(html),"Sample Dialog")
}
Demo: