Skip to content

Commit

Permalink
[desktop]: Fix device menu when one of devices is not connected
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagohm committed Jan 7, 2024
1 parent ade5301 commit 38f1e3f
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { MenuItem, MessageService } from 'primeng/api'
import { SEPARATOR_MENU_ITEM } from '../../constants'
import { Device } from '../../types/device.types'
import { DialogMenuComponent } from '../dialog-menu/dialog-menu.component'
import { compareDevice } from '../../utils/comparators'

@Component({
selector: 'neb-device-list-menu',
Expand All @@ -29,7 +30,7 @@ export class DeviceListMenuComponent {
const model: MenuItem[] = []

return new Promise<T | undefined>((resolve) => {
if (devices.length <= 0 || !devices.find(e => e.connected)) {
if (devices.length <= 0) {
resolve(undefined)
this.message.add({ severity: 'warn', detail: 'Please connect your equipment first!' })
return
Expand All @@ -47,7 +48,7 @@ export class DeviceListMenuComponent {
model.push(SEPARATOR_MENU_ITEM)
}

for (const device of devices) {
for (const device of devices.sort(compareDevice)) {
model.push({
icon: 'mdi mdi-connection',
label: device.name,
Expand Down

0 comments on commit 38f1e3f

Please sign in to comment.