Skip to content

Commit

Permalink
Adds open by appId and type (#29)
Browse files Browse the repository at this point in the history
* Minor spelling mistakes and promises now return booleans instead of strings

* Add opening of app by type and appId to work around app searching
  • Loading branch information
stijnbernards authored May 14, 2020
1 parent addb1b1 commit 1aab508
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions src/samsung.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,36 @@ class Samsung {
return this._sendPromise(getMsgInstalledApp())
}

public openAppByAppIdAndType(
appId: string,
type: number,
done?: (error: Error | { code: string } | null, result: WSData | null) => void
) {
this._send(
getMsgLaunchApp({app_type: type, appId, icon: '', is_lock: 0, name: ''}),
done
)
}

public openAppByAppIdAndTypePromise(
appId: string,
type: number,
) {
return new Promise<WSData | null>((resolve, reject) => {
this.openAppByAppIdAndType(
appId,
type,
(err, res) => {
if (err) {
reject(err)
}

resolve(res)
}
)
})
}

public openApp(
appId: string,
done?: (err: Error | { code: string } | null, res: WSData | string | null) => void
Expand Down Expand Up @@ -239,14 +269,14 @@ class Samsung {
(err, response) => {
if (!err) {
this.LOGGER.log(
'Link sended',
'Link sent',
{ status: response.statusCode, body: response.body, headers: response.headers },
'openYouTubeLink'
)
resolve('Link sended')
resolve('Link sent')
} else {
this.LOGGER.error('While send a link, somthing went wrong', { err }, 'openYouTubeLink')
reject('While send a link, somthing went wrong')
reject(err)
}
}
)
Expand Down

0 comments on commit 1aab508

Please sign in to comment.