-
Notifications
You must be signed in to change notification settings - Fork 128
frontend: video-manager: Add block list support for MCM sources #3846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -245,6 +245,42 @@ class VideoStore extends VuexModule { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Action | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async blockSource(source: string): Promise<void> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await back_axios({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| method: 'post', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| url: `${this.API_URL}/block_source`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| timeout: 10000, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| params: { source_string: source }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .then(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.fetchDevices() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.fetchStreams() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .catch((error) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const message = `Could not block video source: ${error.message}.` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| notifier.pushError('VIDEO_SOURCE_BLOCK_FAIL', message) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+248
to
+264
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Avoid mixing async/await with .then/.catch and consider awaiting the subsequent fetches. Given this is already an async function using await, prefer a try/catch instead of .then/.catch for consistency and readability. That also lets you
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Action | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async unblockSource(source: string): Promise<void> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await back_axios({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| method: 'post', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| url: `${this.API_URL}/unblock_source`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| timeout: 10000, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| params: { source_string: source }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .then(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.fetchDevices() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.fetchStreams() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .catch((error) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const message = `Could not unblock video source: ${error.message}.` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| notifier.pushError('VIDEO_SOURCE_UNBLOCK_FAIL', message) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+266
to
+282
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Mirror the blockSource refactor here for consistency and clearer control flow. Please apply the same structure you use in
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Action | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async resetSettings(): Promise<void> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await back_axios({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Consider handling transient toggle state or disabling the switch while the block/unblock request is in flight.
As written, users can toggle the switch multiple times while
toggleBlockedis still waiting on the backend, which can trigger overlapping block/unblock calls and leave the UI out of sync. A simpleblocking/unblockingflag wired to:loading/:disabledon the v-switch (or reusingupdating_streamsif it fits) would prevent this and make the interaction more reliable.Suggested implementation:
To fully address the race condition, ensure that
toggleBlockedmanagesupdating_streams(or a dedicated flag likeblocking_source) while the block/unblock request is in flight, for example:this.updating_streams = truebefore issuing the backend request.try/finallyblock so thatthis.updating_streamsis reset tofalseregardless of success/failure.device.blockedstate or re-fetching device data so the UI stays in sync with the backend.If
updating_streamsis not appropriate for this purpose, introduce a newblocking_sourcedata property and bind:disabled/:loadingto that instead, updating it intoggleBlockedwith the same pattern.