@@ -143,12 +143,12 @@ const WithIssues = (superclass, object_path) => class extends superclass {
143143} ;
144144
145145/**
146- * Extends the given class with methods to get and track the progress over D-Bus
146+ * Extends the given class with methods to get and track the service status
147147 *
148148 * @template {!WithHTTPClient} T
149+ * @param {T } superclass - superclass to extend
149150 * @param {string } status_path - status resource path (e.g., "/manager/status").
150151 * @param {string } service_name - service name (e.g., "org.opensuse.Agama.Manager1").
151- * @param {T } superclass - superclass to extend
152152 */
153153const WithStatus = ( superclass , status_path , service_name ) =>
154154 class extends superclass {
@@ -192,12 +192,14 @@ const WithStatus = (superclass, status_path, service_name) =>
192192 */
193193
194194/**
195- * Extends the given class with methods to get and track the progress over D-Bus
196- * @param {string } object_path - object_path
195+ * Extends the given class with methods to get and track the service progress
196+ *
197+ * @template {!WithHTTPClient} T
197198 * @param {T } superclass - superclass to extend
198- * @template {!WithDBusClient} T
199+ * @param {string } progress_path - status resource path (e.g., "/manager/status").
200+ * @param {string } service_name - service name (e.g., "org.opensuse.Agama.Manager1").
199201 */
200- const WithProgress = ( superclass , object_path ) =>
202+ const WithProgress = ( superclass , progress_path , service_name ) =>
201203 class extends superclass {
202204 /**
203205 * Returns the service progress
@@ -206,12 +208,14 @@ const WithProgress = (superclass, object_path) =>
206208 * the current step and whether the service finished or not.
207209 */
208210 async getProgress ( ) {
209- const proxy = await this . client . proxy ( PROGRESS_IFACE , object_path ) ;
211+ const { current_step, max_steps, current_title, finished } = await this . client . get (
212+ progress_path ,
213+ ) ;
210214 return {
211- total : proxy . TotalSteps ,
212- current : proxy . CurrentStep [ 0 ] ,
213- message : proxy . CurrentStep [ 1 ] ,
214- finished : proxy . Finished ,
215+ total : max_steps ,
216+ current : current_step ,
217+ message : current_title ,
218+ finished,
215219 } ;
216220 }
217221
@@ -222,13 +226,16 @@ const WithProgress = (superclass, object_path) =>
222226 * @return {import ("./dbus").RemoveFn } function to disable the callback
223227 */
224228 onProgressChange ( handler ) {
225- return this . client . onObjectChanged ( object_path , PROGRESS_IFACE , ( changes ) => {
226- const { TotalSteps, CurrentStep, Finished } = changes ;
227- if ( TotalSteps === undefined && CurrentStep === undefined && Finished === undefined ) {
228- return ;
229+ return this . client . onEvent ( "Progress" , ( progress ) => {
230+ if ( progress ?. service === service_name ) {
231+ const { current_step, max_steps, current_title, finished } = progress ;
232+ handler ( {
233+ total : max_steps ,
234+ current : current_step ,
235+ message : current_title ,
236+ finished,
237+ } ) ;
229238 }
230-
231- this . getProgress ( ) . then ( handler ) ;
232239 } ) ;
233240 }
234241 } ;
0 commit comments