mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-03 03:12:31 +00:00
fix: ensure active feed refreshes when hashtag preferences change
* Update `refreshAllVideoGrids` in `js/app.js` to detect the currently active feed (For You, Kids, Explore, or Recent) and invoke the corresponding loader, preventing staleness when interacting with the UI. * Refactor `HashtagPreferencesService` mutation methods (`addInterest`, etc.) to be `async` and await the `publish()` call, ensuring state is persisted before returning. * Remove redundant `persistPreferencesFromMenu` call in `TagPreferenceMenuController`, relying on the service's internal persistence logic. * Update unit tests for `HashtagPreferencesService` and `TagPreferenceMenuController` to align with the async behavior. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
71e0ecd605
commit
f77c89baf6
5 files changed
+44
-38
No files matched your search
@@ -121,7 +121,7 @@ describe("TagPreferenceMenuController", () => {
|
||||
});
|
||||
|
||||
describe("handleMenuAction", () => {
|
||||
it("should call service method, notify update, publish, and notify update again", async () => {
|
||||
it("should call service method and notify update", async () => {
|
||||
const tag = "bitcoin";
|
||||
const action = TAG_PREFERENCE_ACTIONS.ADD_INTEREST;
|
||||
|
||||
@@ -130,11 +130,11 @@ describe("TagPreferenceMenuController", () => {
|
||||
assert.strictEqual(mockHashtagPreferences.addInterest.mock.calls.length, 1);
|
||||
assert.strictEqual(mockHashtagPreferences.addInterest.mock.calls[0].arguments[0], tag);
|
||||
|
||||
// onPreferenceUpdate should be called twice (optimistic + confirmed)
|
||||
assert.strictEqual(mockCallbacks.onPreferenceUpdate.mock.calls.length, 2);
|
||||
// onPreferenceUpdate should be called once
|
||||
assert.strictEqual(mockCallbacks.onPreferenceUpdate.mock.calls.length, 1);
|
||||
|
||||
// publish should be called
|
||||
assert.strictEqual(mockHashtagPreferences.publish.mock.calls.length, 1);
|
||||
// publish should not be called by controller directly
|
||||
assert.strictEqual(mockHashtagPreferences.publish.mock.calls.length, 0);
|
||||
});
|
||||
|
||||
it("should handle error and call showError", async () => {
|
||||
|
||||
Reference in new issue
Block a user