Repeater first loads then gets filtered

Hello there community… I have a problem with a repeater. When the users clicks a button it goes to page that a repeater loads. The repeater gets filtered out by the button value but for the fist seconds it shows all the items… Then it gets filtered which is what i want… What can i do to prevent the database for showing all at the first seconds?

code i use on page one is

import wixLocation from ‘wix-location’ ;
import { session } from ‘wix-storage’ ;
export function dataset1_ready() {
makeRepeater();
}
export function makeRepeater() {
$w( “#repeater1” ).forEachItem(($item, itemData, index) => {

    $item( "#Button1" ).onClick((event) => { 
        $w( "#TextBoxInput" ).value = itemData.title; 

let value = $w( “#TextBoxInput” ).value;
session.setItem( “TextBoxInput” , value);
wixLocation.to( ‘/categories’ );
});

}); 

}

code i use on the page that gets loaded

import wixData from ‘wix-data’ ;
import { session } from ‘wix-storage’ ;

$w.onReady( function () {
var sameWord = session.getItem( “TextBoxInput” );
session.clear();
//w(“#SubInput”).value = sameWord;
let filter = wixData.filter();
$w( “#dataset1” ).setFilter(
filter.eq( “label” , sameWord)
);
})

Any help would be appreciated…!!!

  1. the setFilter must be inside $w(“#dataset1”).onReady(() => { /here/ })

  2. If that doesn’t help, you can disconnect the repeater from the dataset on the editor and connect them by code once the filter promise got fulfilled,

Didn’t seem to work a lot…When it loads, just before it shows the filtered repeater, some other rows are shown… I also disconnected the dataset1, even the image connection but when this line of code comes in " let filter = wixData.filter(); $w( " #dataset1 " ).setFilter( filter.eq( “label” , sameWord) " it does a filter (only to the one repeater thats left as its not connected to anything…). There it also loads first the first row of the collection until it get replaced by the filter… I think i’m stuck… Thx

Can you please help me how to connect the dataset (an image and a text to be connected with title and image from database) through code?
thx in advance…

@bilisanas

$w("#dataset1").setFilter(
      filter.eq("label", "whtaever_you_want")
    ).then(() => {
return $w("#dataset1").getItems(0,1000);
})
.then(items => {$w("#repeater1").data = items;});

$w("#repeater1").onItemReady(($i, iData) => {
$i("#image1").src = iData.image;
$i("#text1").text = iData.title;
})