Skip to content

Commit 1aab508

Browse files
Adds open by appId and type (#29)
* Minor spelling mistakes and promises now return booleans instead of strings * Add opening of app by type and appId to work around app searching
1 parent addb1b1 commit 1aab508

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

src/samsung.ts

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,36 @@ class Samsung {
179179
return this._sendPromise(getMsgInstalledApp())
180180
}
181181

182+
public openAppByAppIdAndType(
183+
appId: string,
184+
type: number,
185+
done?: (error: Error | { code: string } | null, result: WSData | null) => void
186+
) {
187+
this._send(
188+
getMsgLaunchApp({app_type: type, appId, icon: '', is_lock: 0, name: ''}),
189+
done
190+
)
191+
}
192+
193+
public openAppByAppIdAndTypePromise(
194+
appId: string,
195+
type: number,
196+
) {
197+
return new Promise<WSData | null>((resolve, reject) => {
198+
this.openAppByAppIdAndType(
199+
appId,
200+
type,
201+
(err, res) => {
202+
if (err) {
203+
reject(err)
204+
}
205+
206+
resolve(res)
207+
}
208+
)
209+
})
210+
}
211+
182212
public openApp(
183213
appId: string,
184214
done?: (err: Error | { code: string } | null, res: WSData | string | null) => void
@@ -239,14 +269,14 @@ class Samsung {
239269
(err, response) => {
240270
if (!err) {
241271
this.LOGGER.log(
242-
'Link sended',
272+
'Link sent',
243273
{ status: response.statusCode, body: response.body, headers: response.headers },
244274
'openYouTubeLink'
245275
)
246-
resolve('Link sended')
276+
resolve('Link sent')
247277
} else {
248278
this.LOGGER.error('While send a link, somthing went wrong', { err }, 'openYouTubeLink')
249-
reject('While send a link, somthing went wrong')
279+
reject(err)
250280
}
251281
}
252282
)

0 commit comments

Comments
 (0)