Skip to content

Commit

Permalink
core:fontend:stores:video: Move to OneMoreTime
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoMario109 authored and joaoantoniocardoso committed Sep 30, 2024
1 parent b32cc73 commit f27c983
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions core/frontend/src/store/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import {

import message_manager, { MessageLevel } from '@/libs/message-manager'
import Notifier from '@/libs/notifier'
import { OneMoreTime } from '@/one-more-time'
import store from '@/store'
import { video_manager_service } from '@/types/frontend_services'
import {
CreatedStream, Device, StreamStatus,
} from '@/types/video'
import back_axios, { backend_offline_error } from '@/utils/api'
import { callPeriodically, stopCallingPeriodically } from '@/utils/helper_functions'

export interface Thumbnail {
source: string | undefined
Expand Down Expand Up @@ -45,6 +45,10 @@ class VideoStore extends VuexModule {

private sources_to_request_thumbnail: Set<string> = new Set()

fetchThumbnailsTask = new OneMoreTime(
{ delay: 1000, autostart: false },
)

@Mutation
setUpdatingStreams(updating: boolean): void {
this.updating_streams = updating
Expand Down Expand Up @@ -214,7 +218,7 @@ class VideoStore extends VuexModule {
@Action
startGetThumbnailForDevice(source: string): void {
if (this.sources_to_request_thumbnail.size === 0) {
callPeriodically(this.fetchThumbnails, 1000)
this.fetchThumbnailsTask.resume()
}
this.sources_to_request_thumbnail.add(source)
}
Expand All @@ -228,12 +232,15 @@ class VideoStore extends VuexModule {
this.sources_to_request_thumbnail.delete(source)

if (this.sources_to_request_thumbnail.size === 0) {
stopCallingPeriodically(this.fetchThumbnails)
this.fetchThumbnailsTask.stop()
}
}
}

export { VideoStore }

const video: VideoStore = getModule(VideoStore)

video.fetchThumbnailsTask.setAction(video.fetchThumbnails)

export default video

0 comments on commit f27c983

Please sign in to comment.