refactor: unify streaming
Build Test / test (pull_request) Successful in 26s
JS Unit Tests / test (pull_request) Successful in 27s
PHP Unit Tests / test (pull_request) Successful in 1m8s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-03-06 22:53:08 -05:00
parent 5bfe5dd249
commit cceaf809d9
10 changed files with 205 additions and 130 deletions
+12 -5
View File
@@ -268,22 +268,29 @@ export const useServicesStore = defineStore('mailServicesStore', () => {
* @param secret - optional secret for discovery
* @param location - optional location for discovery
* @param provider - optional provider identifier for discovery
* @param onService - called for each discovered service as it arrives
*
* @returns Promise with list of discovered service objects
* @returns Promise resolving to { total } when the stream completes
*/
async function discover(
identity: string,
secret: string | undefined,
location: string | undefined,
provider: string | undefined,
): Promise<ServiceObject[]> {
onService?: (service: ServiceObject) => void,
): Promise<{ total: number }> {
transceiving.value = true
try {
const services = await serviceService.discover({identity, secret, location, provider})
const result = await serviceService.discover(
{ identity, secret, location, provider },
(service: ServiceObject) => {
onService?.(service)
}
)
console.debug('[Mail Manager][Store] - Successfully discovered', services.length, 'services')
return services
console.debug('[Mail Manager][Store] - Successfully discovered', result.total, 'services')
return result
} catch (error: any) {
console.error('[Mail Manager][Store] - Failed to discover service:', error)
throw error