Need submit twice on collection to working

I have a strange situation with submitting data on collection:
On the site I have a counter (#text53) which shows the activated members in a category (here ‘Band’)

coded like this:

export function text50_viewportEnter(event, $w) {

let category = $w(“#dropdown1”).value;
let counter = 0;

wixData.query(“Members”)
.eq(“_id”, wixUsers.currentUser.id)
.isEmpty(“membercategory”)
.count()
.then((empty) => {
if (empty===1){
$w(“#text50”).text = “–”;
$w(“#button10”).disable();}
else {
wixData.query(“Members”)
.eq(“membercategory”, category)
.between(“validityday”, 0,31)
.count()
.then((number) => {
counter = number;
$w(“#text50”).text = counter.toString();
if (counter >20){
$w(“#html1”).hide()
$w(“#button10”).disable();
}
});
}
});

The new member can activate with “Activate” button, configured like this:


and have an onClick event like this (write the date of the activation into collection, field ‘lastpaymentdate’):

export function button10_click(event, $w) {

$w(“#dynamicDataset”).setFieldValue(“lastpaymentdate”, new Date());
let originalDate10 = $w(“#text46”).text;
let newDate10 = originalDate10.split(’ ‘).splice(0, 4).join(’ ‘);
$w(’#text46’).text = newDate10;

E.g. now there is 11 activated ‘band’ member


and a new member push the ‘Activate’ button once, there is a link to say it was successful and then reload this original site, but the counter still shows 11 - while I can see the date in the collection at this member:


Then I push the ‘activate’ button again so link to a page to say it was successfull and then back this site again and yupeee now the counter calculated with the new active member after the second ‘activate’ button’:


Can anybody tell me why the counter works fine only after the second submitting? And how can avoid it, because no member will push it twice this way it will not working.

site url: www.wedmet.net

Thx,
Imre