-
Notifications
You must be signed in to change notification settings - Fork 128
frontend: video-manager: Add block list support for MCM sources #3837
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
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 }, | ||
| }) | ||
|
Comment on lines
+249
to
+255
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 (bug_risk): Avoid mixing In
Use a single @Action
async blockSource(source: string): Promise<void> {
try {
await back_axios({
method: 'post',
url: `${this.API_URL}/block_source`,
timeout: 10000,
params: { source_string: source },
})
await Promise.all([this.fetchDevices(), this.fetchStreams()])
} catch (error) {
const message = `Could not block video source: ${error.message}.`
notifier.pushError('VIDEO_SOURCE_BLOCK_FAIL', message)
}
}Same pattern for Suggested implementation: @Action
async blockSource(source: string): Promise<void> {
try {
await back_axios({
method: 'post',
url: `${this.API_URL}/block_source`,
timeout: 10000,
params: { source_string: source },
})
await Promise.all([this.fetchDevices(), this.fetchStreams()])
} catch (error: any) {
const message = `Could not block video source: ${error.message}.`
notifier.pushError('VIDEO_SOURCE_BLOCK_FAIL', message)
}
}You should apply the same pattern to
|
||
| .then(() => { | ||
| this.fetchDevices() | ||
| this.fetchStreams() | ||
| }) | ||
| .catch((error) => { | ||
| const message = `Could not block video source: ${error.message}.` | ||
| notifier.pushError('VIDEO_SOURCE_BLOCK_FAIL', message) | ||
| }) | ||
| } | ||
|
|
||
| @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) | ||
| }) | ||
| } | ||
|
|
||
| @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 (bug_risk): Consider handling in-flight toggle state to avoid repeated block/unblock requests and confusing UI feedback.
The
v-switchstays enabled andtoggleBlockeddoesn’t prevent overlapping requests, so rapid toggling can fire multipleblockSource/unblockSourcecalls whiledevice.blockedis still stale from props. This can lead to a racy final state and UI lag. Track a localblockingInProgressflag to temporarily disable the switch (or ignore further changes) while the request is in flight, and only re-enable it once the updated state is loaded.Suggested implementation:
Because I can only see the template portion of this component, a few more changes are required in the
<script>section ofVideoDevice.vue:Track in-flight state in local data
In the component’s
data()function, add theblockingInProgressflag:Update
toggleBlockedto guard against overlapping requestsLocate the existing
toggleBlockedmethod and update it roughly as follows (adjust to match your current implementation and APIs):Ensure state refresh after the API call
If
device.blockedis driven by Vuex or a parent component, make sure the block/unblock actions trigger a refresh of the device data so the prop reflects the final state. If you already have such a refresh (e.g. reloading the device list after the call), no extra work is needed.These changes ensure that rapid toggling does not send overlapping requests and the
v-switchis visually disabled while a block/unblock operation is in flight, matching your review comment.