dataset setFilter .then() not executing in expected order

Hi all - I am hoping someone can help me with the below. I have a function which updates the filter for a dataset connected to a repeater. In theory, once the repeater is updated with the newly filtered dataset I use .then() to run a separate repeaterFormat() function that uses .forEachItem() to format each repeater item depending on it’s content. Both these functions works perfectly well separately, but I am finding that, despite using .then(), the repeaterFormat() function is running prior to the repeater items updating, meaning that the newly filtered data isn’t formatted. See my code below.

export function repeaterFilter(event) {
    $w('#datasetRepeater').setFilter(wixData.filter()
            .eq("course", course)
            .eq("section", section)
            .or(
                wixData.filter()
                .eq("course", course)
                .eq("subHeader", true)
            )
        )
        .then(() => {
            repeaterFormat();     // THIS IS RUNNING BEFORE THE REPEATER HAS UPDATED WITH THE NEW FILTER  
        })
        .catch((err) => {
            console.log(err);
        });
}

I have found that by wrapping the repeaterFormat() function in a timeout it delays the function enough so that the newly filtered data is formatted. However, I am not confident that this will always work and it’s obviously not the best way to handle it.

setTimeout(function () {
  repeaterFormat();
}, 800); 

I have also tried async/await, but with no luck. Is there something I am missing here? Perhaps a way in which I can get repeaterFormat() to run once the repeater has been updated, rather than when the filter is complete?

Any help would be much appreciated. Thanks