Skip to content

[BUG]: Changing course filter on my courses tab doesnt update dropdown #971

@wanjawischmeier

Description

@wanjawischmeier

myCourses.ts broadcasts a filter change to all other tabs, but it doesnt broadcast to itself, leading to the dropdown becoming out of date.

I already have a fix for this, in myCourses.ts:

// send an update message if on the myCourses page
if (window.location.pathname === '/my/courses.php') {
    void requirePromise([
        'jquery',
        'block_myoverview/selectors',
        'core/custom_interaction_events',
    ] as const).then(([jquery, selectors, events]) =>
        // as long as moodle uses jQuery there seems to be no way to do it whithout jQuery
        jquery('.block-myoverview')
            ?.find(selectors.FILTERS)
            ?.on(
                    // ...

                    // Trigger local hooks first
                    activeFilterChangedHooks.forEach(hook => hook(filter));

                    // Then broadcast to other tabs
                    const channel = new BroadcastChannel(
                        updateActiveFilterChannelName
                    );
                    channel.postMessage(filter);
                    channel.close();
                }
            )
    );
}

This seems to work and I'll include it in my pr for course caching.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions