Creating a Custom Variable for Scope
async function() {
const STORAGE_KEY_NAME = "recurrence_limiter";
const RECCURNC_LIMITER = this.getFrontendVariable("user_doc_id");
const MAX_STORAGE_SIZE = 3;
let existing_ids = await this.storage.read(STORAGE_KEY_NAME) || "";
if(existing_ids && RECCURNC_LIMITER != null && RECCURNC_LIMITER != "" && existing_ids.indexOf(RECCURNC_LIMITER) >= 0){
return false; //this value was received previously
} else if(RECCURNC_LIMITER && RECCURNC_LIMITER != null && RECCURNC_LIMITER != "") {
existing_ids += RECCURNC_LIMITER+";";
if(existing_ids.split(";").length > MAX_STORAGE_SIZE){
existing_ids = existing_ids.split(";");
existing_ids.shift();
existing_ids = existing_ids.join(";");
}
this.storage.write(STORAGE_KEY_NAME, existing_ids, Date.now()+94608000000);
return true; //this value is new
}
return null;
}Last updated
Was this helpful?