(Help Needed) Code selects selection tag but the data is not sorted

Wix studio, Redirecting to our work page after selecting a text category on the home page. The page loads and selects that corresponding selection tag but the repeaters are not filtered by the selection tag unless you select and reselect the selection tag.

import { session } from "wix-storage-frontend";

$w.onReady(function () {

    let value = session.getItem("category");

    if (value) {
        console.log("session:  " + value);

        $w("#dataset1").onReady(() => {
            console.log("The dataset projects is ready");
            // Get the current item in the dynamic dataset
            let currentItem = value;

            // Get the array of values from the selection tags
            let tagOptions = $w("#selectionTags1").options;

            // Find the index of the matching value in the selection tag options
            let selectedIndex = tagOptions.findIndex(option => option.value === currentItem);

            console.log("selectedIndex: " + selectedIndex);

            // If a match is found, set it as the selected index
            if (selectedIndex !== -1) {
                $w("#selectionTags1").selectedIndices = [selectedIndex];
            }
         });
    }

    $w("#selectionTags1").onChange((event) => {
        session.clear();
        let selectedIndices = $w("#selectionTags1").selectedIndices;
        if (selectedIndices.length > 1) {
            // Deselect all but the last selected tag
            $w("#selectionTags1").selectedIndices = [selectedIndices[selectedIndices.length - 1]];
        }
    });
});

Solution found

$w(“#dataset1”).refresh().then(() => {
console.log("Dataset refreshed to show the correct data for: " + currentItem);
}).catch((err) => {
console.log("Error refreshing dataset: " + err);