Hi,
In this article https://support.wix.com/en/article/corvid-best-practices-for-building-a-corvid-website it is recommended to try breaking the code in small parts every time it is feasible.
If I understood this correctly, in the code below, it would be better to use LINE1&LINE2 where they are, than at the end of the code
Is this right ?. And if it is, is there a performance issue that does small code blocks work better than large ones ??
Best,
// CODIGO INCLUYE VISUALIZACIÓN DE USUARIO Y DE NOMCOM Y LUEGO ANTES DE REDIRIGIR A DINAMICA EL INSERT SEGÚN EL CIRCUITO SELECCIONADO
import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';
import {session} from 'wix-storage';
let userEmail;
let userId;
let flagcircuito;
let toInsert
$w.onReady(function () {
wixData.query("Members/PrivateMembersData")
.eq("_id", wixUsers.currentUser.id)
.find()
.then( (results) => {
userEmail = results.items[0].loginEmail;
userId = results.items[0]._id;
//$w('#text71').text = userEmail;
});
$w('#dynamicDataset').onReady( () => {
$w('#dynamicDataset').getCurrentItem();
toInsert = {
"title": $w('#dynamicDataset').getCurrentItem().title,
"nomCom": $w('#dynamicDataset').getCurrentItem().nomCom,
"codorig": "ROJA",
"userEmail": userEmail,
"userId": userId
};
wixData.insert("clubbitLogorig", toInsert) // INSERT COE (FIRST INSERT)
// .then( (results) => {
}) // ------------------------------------------------------LINE 1
}) // ------------------------------------------------------LINE 2
$w("#repeater1").onItemReady(($w, dataItem, index) => {
$w('#box71').onClick(() => {
$w('#dataset1').getCurrentItem();
if (($w('#dataset1').getCurrentItem().codcirc === 1)) {
toInsert = {
"title": $w('#dataset1').getCurrentItem().title,
"nomcom": $w('#dataset1').getCurrentItem().nomcom,
"codorig": "ROJA",
"codcirc": 1,
"userEmail": userEmail,
"userId": userId,
"nodocircid": $w('#dataset1').getCurrentItem()._id,
};
wixData.insert("clubbitLogcirc", toInsert) // (SECOND INSERT)
session.setItem("flagcircuito", $w('#dataset1').getCurrentItem().nomcirc);
let linkToDynamicPage = dataItem["link-clubbitnodo-1-title"];
wixLocation.to(linkToDynamicPage)
}
***************************
// code continues