File tree Expand file tree Collapse file tree 4 files changed +18
-3
lines changed
services/livesync/playground Expand file tree Collapse file tree 4 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 55 "ANDROID_DEBUG_UI_MAC" : " Google Chrome" ,
66 "USE_POD_SANDBOX" : false ,
77 "DISABLE_HOOKS" : false ,
8- "UPLOAD_PLAYGROUND_FILES_ENDPOINT" : " https://play.nativescript.org/api/files"
8+ "UPLOAD_PLAYGROUND_FILES_ENDPOINT" : " https://play.nativescript.org/api/files" ,
9+ "SHORTEN_URL_ENDPOINT" : " https://play.nativescript.org/api/shortenurl?longUrl=%s"
910}
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export class Configuration extends ConfigBase implements IConfiguration { // Use
99 ANDROID_DEBUG_UI : string = null ;
1010 USE_POD_SANDBOX : boolean = false ;
1111 UPLOAD_PLAYGROUND_FILES_ENDPOINT : string = null ;
12+ SHORTEN_URL_ENDPOINT : string = null ;
1213
1314 /*don't require logger and everything that has logger as dependency in config.js due to cyclic dependency*/
1415 constructor ( protected $fs : IFileSystem ) {
Original file line number Diff line number Diff line change @@ -383,6 +383,7 @@ interface IConfiguration extends Config.IConfig {
383383 ANDROID_DEBUG_UI : string ;
384384 USE_POD_SANDBOX : boolean ;
385385 UPLOAD_PLAYGROUND_FILES_ENDPOINT : string ;
386+ SHORTEN_URL_ENDPOINT : string ;
386387}
387388
388389interface IApplicationPackage {
Original file line number Diff line number Diff line change 11import { PlaygroundStoreUrls } from "./preview-app-constants" ;
2+ import * as util from "util" ;
23
34export class PlaygroundQrCodeGenerator implements IPlaygroundQrCodeGenerator {
45 constructor ( private $previewSdkService : IPreviewSdkService ,
5- private $qrCodeTerminalService : IQrCodeTerminalService ) { }
6+ private $httpClient : Server . IHttpClient ,
7+ private $qrCodeTerminalService : IQrCodeTerminalService ,
8+ private $config : IConfiguration ) {
9+ }
610
711 public async generateQrCodeForiOS ( ) : Promise < void > {
812 await this . generateQrCode ( PlaygroundStoreUrls . APP_STORE_URL ) ;
@@ -17,7 +21,15 @@ export class PlaygroundQrCodeGenerator implements IPlaygroundQrCodeGenerator {
1721 }
1822
1923 private async generateQrCode ( url : string ) : Promise < void > {
20- // TODO: Shorten url before generate QR code
24+ const shortenUrlEndpoint = util . format ( this . $config . SHORTEN_URL_ENDPOINT , url ) ;
25+ try {
26+ const response = await this . $httpClient . httpRequest ( shortenUrlEndpoint ) ;
27+ const responseBody = JSON . parse ( response . body ) ;
28+ url = responseBody . shortURL || url ;
29+ } catch ( e ) {
30+ // use the longUrl
31+ }
32+
2133 this . $qrCodeTerminalService . generate ( url ) ;
2234 }
2335}
You can’t perform that action at this time.
0 commit comments