Advertisement
Guest User

Untitled

a guest
Apr 20th, 2017
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.55 KB | None | 0 0
  1. diff --git a/package.json b/package.json
  2. index d204f70..4f6a190 100755
  3. --- a/package.json
  4. +++ b/package.json
  5. @@ -10,41 +10,41 @@
  6. "ionic:serve": "ionic-app-scripts serve"
  7. },
  8. "dependencies": {
  9. - "@angular/common": "2.2.1",
  10. - "@angular/compiler": "2.2.1",
  11. - "@angular/compiler-cli": "2.2.1",
  12. - "@angular/core": "2.2.1",
  13. - "@angular/forms": "2.2.1",
  14. - "@angular/http": "2.2.1",
  15. - "@angular/platform-browser": "2.2.1",
  16. - "@angular/platform-browser-dynamic": "2.2.1",
  17. - "@angular/platform-server": "2.2.1",
  18. - "@ionic/storage": "1.1.7",
  19. - "angular2-moment": "^1.1.0",
  20. - "angular2-emojify": "0.1.0",
  21. - "ionic-angular": "2.3.0",
  22. - "ionic-native": "2.9.0",
  23. + "@angular/common": "4.0.0",
  24. + "@angular/compiler": "4.0.0",
  25. + "@angular/compiler-cli": "4.0.0",
  26. + "@angular/core": "4.0.0",
  27. + "@angular/forms": "4.0.0",
  28. + "@angular/http": "4.0.0",
  29. + "@angular/platform-browser": "4.0.0",
  30. + "@angular/platform-browser-dynamic": "4.0.0",
  31. + "@ionic-native/camera": "^3.5.0",
  32. + "@ionic-native/core": "3.4.2",
  33. + "@ionic-native/splash-screen": "3.4.2",
  34. + "@ionic-native/status-bar": "3.4.2",
  35. + "@ionic-native/transfer": "^3.4.4",
  36. + "@ionic/storage": "2.0.1",
  37. + "ionic-angular": "3.0.1",
  38. "ionicons": "3.0.0",
  39. - "rxjs": "5.0.0-beta.12",
  40. + "rxjs": "5.1.1",
  41. "sw-toolbox": "3.4.0",
  42. - "zone.js": "0.6.26"
  43. + "zone.js": "^0.8.4"
  44. },
  45. "devDependencies": {
  46. - "@ionic/app-scripts": "1.0.0",
  47. - "typescript": "2.0.9"
  48. + "@ionic/app-scripts": "1.3.0",
  49. + "typescript": "~2.2.1"
  50. },
  51. "cordovaPlugins": [
  52. - "cordova-plugin-whitelist",
  53. - "cordova-plugin-console",
  54. - "cordova-plugin-statusbar",
  55. "cordova-plugin-device",
  56. "cordova-plugin-splashscreen",
  57. - "cordova-plugin-inappbrowser",
  58. - "cordova-plugin-file-transfer",
  59. - "cordova-plugin-actionsheet",
  60. - "cordova-plugin-camera",
  61. + "cordova-plugin-console",
  62. + "cordova-plugin-whitelist",
  63. + "cordova-plugin-statusbar",
  64. "ionic-plugin-keyboard"
  65. ],
  66. "cordovaPlatforms": [],
  67. - "description": "TootyFruity: An Ionic project"
  68. + "description": "scratch: An Ionic project",
  69. + "config": {
  70. + "ionic_webpack": "./webpack.config.js"
  71. + }
  72. }
  73. diff --git a/src/components/media-attachments/media-attachments.ts b/src/components/media-attachments/media-attachments.ts
  74. index c6fed33..4155f40 100644
  75. --- a/src/components/media-attachments/media-attachments.ts
  76. +++ b/src/components/media-attachments/media-attachments.ts
  77. @@ -1,6 +1,6 @@
  78. import { Platform } from 'ionic-angular';
  79. import { ImageSliderPage } from '../../pages/image-slider/image-slider';
  80. -import { ModalController } from 'ionic-angular/components/modal/modal';
  81. +import { ModalController } from 'ionic-angular';
  82. import { MediaAttachment } from '../../apiClasses/media-attachment';
  83. import { Component, ElementRef, Input } from '@angular/core';
  84.  
  85. @@ -46,7 +46,7 @@ export class MediaAttachmentsComponent {
  86. if(!this.isiOS) {
  87. video.webkitRequestFullscreen();
  88. }
  89. - });
  90. + });
  91. }
  92. }
  93.  
  94. diff --git a/src/components/slidable-toot/slidable-toot.ts b/src/components/slidable-toot/slidable-toot.ts
  95. index 9aafd8b..344f14e 100644
  96. --- a/src/components/slidable-toot/slidable-toot.ts
  97. +++ b/src/components/slidable-toot/slidable-toot.ts
  98. @@ -2,9 +2,9 @@ import { Utility } from '../../providers/utility';
  99. import { UserProfilePage } from '../../pages/user-profile/user-profile';
  100. import { TootDetailPage } from '../../pages/toot-detail/toot-detail';
  101. import { Account } from '../../apiClasses/account';
  102. -import { ToastController } from 'ionic-angular/components/toast/toast';
  103. +import { ToastController } from 'ionic-angular';
  104. import { ReplyTootPage } from '../../pages/reply-toot/reply-toot';
  105. -import { ModalController } from 'ionic-angular/components/modal/modal';
  106. +import { ModalController } from 'ionic-angular';
  107. import { ItemSliding, NavController } from 'ionic-angular';
  108. import { APIProvider } from '../../providers/APIProvider';
  109. import { Toot } from '../../apiClasses/toot';
  110. @@ -40,7 +40,7 @@ export class SlidableTootComponent {
  111. this.navController.push(UserProfilePage, {'mention' : this.toot.mentions[i]});
  112. }
  113. }
  114. - });
  115. + });
  116.  
  117. }
  118. }
  119. @@ -58,7 +58,7 @@ export class SlidableTootComponent {
  120. document.getElementById(toot.id).className += ' newly_unboosted';
  121. setTimeout(() => {
  122. document.getElementById(toot.id).className = originalClass;
  123. - toot.reblogged = false;
  124. + toot.reblogged = false;
  125. }, 1500);
  126. })
  127. } else {
  128. @@ -68,7 +68,7 @@ export class SlidableTootComponent {
  129. .subscribe(() => {
  130. let originalClass = document.getElementById(toot.id).className;
  131. document.getElementById(toot.id).className += ' newly_boosted'
  132. - toot.reblogged = true;
  133. + toot.reblogged = true;
  134. setTimeout(() => {
  135. document.getElementById(toot.id).className = originalClass;
  136. }, 2000);
  137. @@ -108,12 +108,12 @@ export class SlidableTootComponent {
  138. toot.favourited = true;
  139. setTimeout(() => {
  140. document.getElementById(toot.id).className = originalClass;
  141. -
  142. +
  143. }, 2000);
  144. },
  145. error => console.log(JSON.stringify(error))
  146. );
  147. -
  148. +
  149. }
  150. }
  151.  
  152. @@ -136,7 +136,7 @@ export class SlidableTootComponent {
  153. document.getElementById(toot.id).className = originalClass
  154. }, 2000)
  155. }
  156. -
  157. +
  158.  
  159. showPrivateInfoToast(slidingItem: ItemSliding){
  160. let toast = this.toaster.create({
  161. @@ -145,7 +145,7 @@ export class SlidableTootComponent {
  162. position: 'top'
  163. });
  164. toast.present();
  165. - slidingItem.close();
  166. + slidingItem.close();
  167. }
  168.  
  169. goToUserProfile(account: Account){
  170. diff --git a/src/components/toot-form/toot-form.ts b/src/components/toot-form/toot-form.ts
  171. index 6504885..12e24ba 100644
  172. --- a/src/components/toot-form/toot-form.ts
  173. +++ b/src/components/toot-form/toot-form.ts
  174. @@ -1,12 +1,17 @@
  175. import { ImageSliderPage } from '../../pages/image-slider/image-slider';
  176. -import { ModalController } from 'ionic-angular/components/modal/modal';
  177. -import { Camera, CameraOptions, FileUploadResult } from 'ionic-native/dist/esm';
  178. +import { Camera, CameraOptions } from '@ionic-native/camera';
  179. +
  180. import { UploadedMedia } from '../../apiClasses/uploaded-media';
  181. import { Component, Input } from '@angular/core';
  182. -import { NavController, NavParams, Platform, ToastController, ViewController } from 'ionic-angular';
  183. +import {
  184. + NavController, NavParams, Platform, ToastController, ViewController, ModalController, ActionSheetController,
  185. + ActionSheetOptions,
  186. +
  187. +} from 'ionic-angular';
  188. import { TootForm } from '../../apiClasses/tootForm'
  189. -import { Keyboard, ActionSheet } from 'ionic-native';
  190. import { APIProvider } from '../../providers/APIProvider';
  191. +import {Keyboard} from '@ionic-native/keyboard';
  192. +import {FileUploadResult} from "@ionic-native/transfer";
  193. /*
  194. Generated class for the TootForm component.
  195.  
  196. @@ -21,7 +26,7 @@ export class TootFormComponent {
  197.  
  198. @Input()
  199. newToot: TootForm;
  200. -
  201. +
  202. spoilerFieldState: string = 'hidden';
  203. @Input()
  204. spoilerToggle: Boolean;
  205. @@ -33,22 +38,23 @@ export class TootFormComponent {
  206. attachedMedia: UploadedMedia[] = [];
  207.  
  208.  
  209. - constructor(platform: Platform, public modalController: ModalController, public toaster: ToastController,
  210. - public navCtrl: NavController, public navParams: NavParams, private mastodon: APIProvider,
  211. - public viewCtrl: ViewController) {
  212. + constructor(platform: Platform, public modalController: ModalController, public toaster: ToastController,
  213. + public navCtrl: NavController, public navParams: NavParams, private mastodon: APIProvider,
  214. + public viewCtrl: ViewController, public camera: Camera,
  215. + public keyboard: Keyboard, public asc: ActionSheetController) {
  216. let options : any = {}
  217. - options.sourceType = Camera.PictureSourceType.PHOTOLIBRARY;
  218. - options.mediaType=Camera.MediaType.ALLMEDIA;
  219. + options.sourceType = camera.PictureSourceType.PHOTOLIBRARY;
  220. + options.mediaType=camera.MediaType.ALLMEDIA;
  221. options.quality = 100;
  222. if(platform.is('ios')){
  223. console.log('platform is ios, setting image destination type to native...')
  224. - options.destinationType=Camera.DestinationType.NATIVE_URI;
  225. + options.destinationType=camera.DestinationType.NATIVE_URI;
  226. } else {
  227. - options.destinationType=Camera.DestinationType.FILE_URI;
  228. + options.destinationType=camera.DestinationType.FILE_URI;
  229. }
  230. this.picturePickerOptions = options;
  231.  
  232. - Keyboard.disableScroll(true);
  233. + keyboard.disableScroll(true);
  234. this.newToot = new TootForm();
  235. }
  236.  
  237. @@ -69,7 +75,7 @@ export class TootFormComponent {
  238. duration: 3000,
  239. position: 'top'
  240. });
  241. - toast.present();
  242. + toast.present();
  243. } else if(this.remainingCharacters < 0) {
  244. let toast = this.toaster.create({
  245. message: 'Wow! You used too many characters, try shortening it down',
  246. @@ -77,7 +83,7 @@ export class TootFormComponent {
  247. position: 'top'
  248. });
  249. toast.present();
  250. - }
  251. + }
  252. else {
  253. console.log('posting new toot...')
  254. console.log(this.newToot.spoiler_text)
  255. @@ -93,7 +99,7 @@ export class TootFormComponent {
  256. if(this.newToot.in_reply_to_id == null) {
  257. localStorage.setItem('lastVisibility', this.newToot.visibility);
  258. }
  259. - toast.present();
  260. + toast.present();
  261. this.newToot = new TootForm();
  262. },
  263. error => console.log(JSON.stringify(error))
  264. @@ -117,7 +123,7 @@ export class TootFormComponent {
  265. this.newToot.spoiler_text = null;
  266. this.spoilerFieldState = 'hidden'
  267. }
  268. - Keyboard.disableScroll(true);
  269. + this.keyboard.disableScroll(true);
  270. }
  271.  
  272. countTootLength(){
  273. @@ -125,7 +131,7 @@ export class TootFormComponent {
  274. let tootContentLength = 0;
  275. if(this.newToot.spoiler_text) {
  276. spoilerTextLength = this.newToot.spoiler_text.length;
  277. - }
  278. + }
  279. if(this.newToot.status){
  280. tootContentLength = this.newToot.status.length
  281. }
  282. @@ -146,12 +152,14 @@ export class TootFormComponent {
  283. return;
  284. }
  285. let buttonLabels = ['Fast Upload', 'Full Size (and GIFs!)'];
  286. - ActionSheet.show({
  287. + let as = this.asc.create({
  288. 'title': 'How do you want to upload?',
  289. 'buttonLabels': buttonLabels,
  290. 'addCancelButtonWithLabel': 'Cancel',
  291. 'androidTheme' : 5
  292. - }).then((buttonIndex: number) => {
  293. + } as ActionSheetOptions);
  294. +
  295. + as.present().then((buttonIndex: number) => {
  296. switch(buttonIndex){
  297. case(1):
  298. this.picturePickerOptions.quality = 60;
  299. @@ -170,7 +178,7 @@ export class TootFormComponent {
  300. }
  301.  
  302. singleImagePicker(){
  303. - Camera.getPicture(this.picturePickerOptions).then((imgURL) => {
  304. + this.camera.getPicture(this.picturePickerOptions).then((imgURL) => {
  305. this.uploadMedia(imgURL);
  306. }, (err) => { console.log(JSON.stringify(err))});
  307. }
  308. @@ -188,7 +196,7 @@ export class TootFormComponent {
  309. });
  310. toast.present();
  311. return null;
  312. - }
  313. + }
  314. promise.then((data) => {
  315. if(data){
  316. if(!this.newToot.media_ids){
  317. @@ -200,9 +208,9 @@ export class TootFormComponent {
  318. this.newToot.status = this.newToot.status + " " + attachment.text_url;
  319. else
  320. this.newToot.status = " " + attachment.text_url;
  321. - console.log(JSON.stringify(this.newToot.media_ids));
  322. + console.log(JSON.stringify(this.newToot.media_ids));
  323. this.attachedMedia.push(attachment);
  324. - this.countTootLength();
  325. + this.countTootLength();
  326. this.isUploading = false;
  327. }
  328. }, (error) => {
  329. @@ -213,23 +221,23 @@ export class TootFormComponent {
  330. }
  331.  
  332. removeAttachment(media:UploadedMedia){
  333. -
  334. +
  335. //remove attachment from view
  336. let index = this.attachedMedia.indexOf(media);
  337. this.attachedMedia.splice(index,1);
  338. -
  339. +
  340. //remove attachment from newToot object
  341. index = this.newToot.media_ids.indexOf(media.id)
  342. this.newToot.media_ids.splice(index,1);
  343. -
  344. +
  345.  
  346. let startOfMediaURL = this.newToot.status.indexOf(media.text_url);
  347. let status_part_one = this.newToot.status.substring(0,startOfMediaURL -1)
  348. -
  349. -
  350. +
  351. +
  352. let status_part_two = this.newToot.status.substring(startOfMediaURL + media.text_url.length)
  353.  
  354. -
  355. +
  356. console.log("old status: " + this.newToot.status);
  357. this.newToot.status = status_part_one + status_part_two;
  358. console.log("p1 '" + status_part_one+"'");
  359. @@ -249,5 +257,5 @@ export class TootFormComponent {
  360. let myModal = this.modalController.create(ImageSliderPage, { 'mediaAttachments' : this.attachedMedia, 'slideFromNumber': index});
  361. myModal.present();
  362. }
  363. -
  364. +
  365. }
  366. diff --git a/src/pages/account-switcher/account-switcher.ts b/src/pages/account-switcher/account-switcher.ts
  367. index b9ddb97..c09d863 100644
  368. --- a/src/pages/account-switcher/account-switcher.ts
  369. +++ b/src/pages/account-switcher/account-switcher.ts
  370. @@ -2,10 +2,9 @@ import { SwitcherService } from '../../providers/switcherService';
  371. import { Utility } from '../../providers/utility';
  372. import { APIProvider } from '../../providers/APIProvider';
  373. import { LoginPage } from '../login/login';
  374. -import { ModalController } from 'ionic-angular/components/modal/modal';
  375. import { AuthedAccount } from '../../apiClasses/authedAccount';
  376. import { Component } from '@angular/core';
  377. -import { NavController, NavParams, ViewController } from 'ionic-angular';
  378. +import { NavController, NavParams, ViewController, ModalController } from 'ionic-angular';
  379.  
  380. /*
  381. Generated class for the AccountSwitcher page.
  382. @@ -49,7 +48,7 @@ export class AccountSwitcherPage {
  383.  
  384. removeAccount(account:AuthedAccount){
  385. let accountList: AuthedAccount[] = JSON.parse(localStorage.getItem('accountList'));
  386. -
  387. +
  388. for(let i = 0; i < accountList.length; i++){
  389. if(accountList[i].accessToken == account.accessToken) {
  390. accountList.splice(i,1);
  391. diff --git a/src/pages/home/home.ts b/src/pages/home/home.ts
  392. index b13d040..3df2c85 100755
  393. --- a/src/pages/home/home.ts
  394. +++ b/src/pages/home/home.ts
  395. @@ -1,10 +1,10 @@
  396. import { Subscription } from 'rxjs/Rx';
  397. import { SwitcherService } from '../../providers/switcherService';
  398. -import { PopoverController } from 'ionic-angular/components/popover/popover';
  399. +import { PopoverController } from 'ionic-angular';
  400. import { AccountSwitcherPage } from '../account-switcher/account-switcher';
  401. import { AuthedAccount } from '../../apiClasses/authedAccount';
  402. import { Utility } from '../../providers/utility';
  403. -import { ToastController } from 'ionic-angular/components/toast/toast';
  404. +import { ToastController } from 'ionic-angular';
  405. import { APIProvider } from '../../providers/APIProvider';
  406. import { Component, OnDestroy, Renderer, ViewChild } from '@angular/core';
  407. import { Content, InfiniteScroll, ModalController, NavController } from 'ionic-angular';
  408. @@ -25,7 +25,7 @@ export class HomePage implements OnDestroy{
  409. timelineSwitching: boolean = false;
  410. @ViewChild(Content) content: Content;
  411.  
  412. - constructor(public utility: Utility, public navCtrl: NavController, private renderer: Renderer, public toaster: ToastController,
  413. + constructor(public utility: Utility, public navCtrl: NavController, private renderer: Renderer, public toaster: ToastController,
  414. private mastodon: APIProvider, public modalController: ModalController, public popOverController: PopoverController, private switcherService : SwitcherService) {
  415. this.currentAccount = utility.getCurrentAccount();
  416. let tootCache = this.currentAccount.tootCache;
  417. @@ -48,7 +48,7 @@ export class HomePage implements OnDestroy{
  418. this.loadTimeline();
  419. }
  420. })
  421. -
  422. +
  423. }
  424.  
  425. public cacheContent(){
  426. @@ -81,8 +81,8 @@ export class HomePage implements OnDestroy{
  427. actualTootID(toot: Toot): string {
  428. if(toot.reblog)
  429. return toot.reblog.id;
  430. - else
  431. - return toot.id;
  432. + else
  433. + return toot.id;
  434. }
  435.  
  436. doRefresh(refresher) {
  437. @@ -114,9 +114,9 @@ export class HomePage implements OnDestroy{
  438. if(newToots.length < 20) {
  439. this.toots = newToots.concat(this.toots);
  440. } else {
  441. - this.toots = newToots;
  442. + this.toots = newToots;
  443. }
  444. - }
  445. + }
  446. setTimeout(() => {
  447. console.log('refresh completed');
  448. refresher.complete();
  449. @@ -149,7 +149,7 @@ export class HomePage implements OnDestroy{
  450. error => {
  451. console.log(JSON.stringify(error))
  452. infiniteScroll.complete();
  453. - }
  454. + }
  455. );
  456. }
  457.  
  458. diff --git a/src/pages/image-slider/image-slider.ts b/src/pages/image-slider/image-slider.ts
  459. index c20fb99..f72b916 100644
  460. --- a/src/pages/image-slider/image-slider.ts
  461. +++ b/src/pages/image-slider/image-slider.ts
  462. @@ -1,4 +1,4 @@
  463. -import { ModalController } from 'ionic-angular/components/modal/modal';
  464. +import { ModalController } from 'ionic-angular';
  465. import { MediaAttachment } from '../../apiClasses/media-attachment';
  466. import { Component } from '@angular/core';
  467. import { NavController, NavParams, ViewController } from 'ionic-angular';
  468. @@ -12,12 +12,12 @@ export class ImageSliderPage {
  469. slideFromNumber: number;
  470. constructor(
  471. public navCtrl: NavController,
  472. - public navParams: NavParams,
  473. + public navParams: NavParams,
  474. public viewCtrl: ViewController,
  475. public modalController: ModalController) {
  476. this.mediaAttachments = navParams.get('mediaAttachments');
  477. this.slideFromNumber = navParams.get('slideFromNumber');
  478. -
  479. +
  480. }
  481.  
  482. ionViewDidLoad() {
  483. diff --git a/src/pages/user-profile/user-profile.ts b/src/pages/user-profile/user-profile.ts
  484. index 7d8c2fe..125e69a 100644
  485. --- a/src/pages/user-profile/user-profile.ts
  486. +++ b/src/pages/user-profile/user-profile.ts
  487. @@ -5,7 +5,7 @@ import { Utility } from '../../providers/utility';
  488. import { UserListPage } from '../user-list/user-list';
  489. import { UserOptionsPage } from '../user-options/user-options';
  490. import { TootPage } from '../toot/toot';
  491. -import { ModalController } from 'ionic-angular/components/modal/modal';
  492. +import { ModalController } from 'ionic-angular';
  493. import { Relationships } from '../../apiClasses/relationships';
  494. import { Mention } from '../../apiClasses/mention';
  495. import { APIProvider } from '../../providers/APIProvider';
  496. @@ -36,7 +36,7 @@ export class UserProfilePage {
  497.  
  498. constructor(private utility:Utility, private modalController: ModalController, public navCtrl: NavController,
  499. public navParams: NavParams, private mastodon: APIProvider, public popOverController: PopoverController, private switcherService: SwitcherService) {
  500. -
  501. +
  502. let paramUser = navParams.get('account');
  503. let paramMention: Mention = navParams.get('mention');
  504.  
  505. @@ -47,12 +47,12 @@ export class UserProfilePage {
  506. this.getToots();
  507. this.loadRelationships();
  508. }
  509. - // user comes from Mention
  510. + // user comes from Mention
  511. else if(paramMention && paramMention.id != loggedInUser.id){
  512. this.user = new Account();
  513. this.user.acct = paramMention.acct;
  514. this.mastodon.getAccount(paramMention.id)
  515. - .map(
  516. + .map(
  517. res => {
  518. return JSON.parse(res['_body'])
  519. })
  520. @@ -63,7 +63,7 @@ export class UserProfilePage {
  521. this.loadRelationships();
  522. }
  523. )
  524. - }
  525. + }
  526. // is logged in user
  527. else {
  528. this.loggedInUser = loggedInUser;
  529. @@ -190,7 +190,7 @@ export class UserProfilePage {
  530. error => {
  531. console.log(JSON.stringify(error))
  532. infiniteScroll.complete();
  533. - }
  534. + }
  535. );
  536. }
  537.  
  538. @@ -226,7 +226,7 @@ export class UserProfilePage {
  539.  
  540. showFollowers(){
  541. this.navCtrl.push(UserListPage, {title: "Followers", id: this.user.id});
  542. -
  543. +
  544. }
  545.  
  546. showFollowing(){
  547. diff --git a/src/providers/APIProvider.ts b/src/providers/APIProvider.ts
  548. index 90f07fd..676d8ee 100644
  549. --- a/src/providers/APIProvider.ts
  550. +++ b/src/providers/APIProvider.ts
  551. @@ -1,9 +1,9 @@
  552. import { Utility } from './utility';
  553. import { AuthedAccount } from '../apiClasses/authedAccount';
  554. -import { FileUploadOptions, FileUploadResult } from 'ionic-native/dist/esm';
  555. +import { FileUploadOptions, FileUploadResult } from '@ionic-native/transfer';
  556. import { TootForm } from '../apiClasses/tootForm';
  557. import { RequestOptionsArgs } from '@angular/http/src/interfaces';
  558. -import { Transfer } from 'ionic-native';
  559. +import { Transfer } from '@ionic-native/transfer';
  560. import { Observable } from 'rxjs/Rx';
  561. import { Injectable } from '@angular/core';
  562. import { Headers, Http, RequestOptions, Response, URLSearchParams } from '@angular/http';
  563. @@ -13,12 +13,12 @@ import 'rxjs/add/operator/catch';
  564.  
  565. @Injectable()
  566. export class APIProvider {
  567. - fileTransfer: Transfer;
  568. currentAccount: AuthedAccount;
  569.  
  570. mediaUploadsProgress:any = {};
  571.  
  572. - constructor(public http: Http, public storage: Storage, public utility: Utility) {
  573. + constructor(public http: Http, public storage: Storage, public utility: Utility,
  574. + public transfer: Transfer) {
  575. this.currentAccount = utility.getCurrentAccount();
  576.  
  577. let headers = new Headers({ 'Accept': 'application/json' });
  578. @@ -127,7 +127,7 @@ export class APIProvider {
  579. }
  580.  
  581. uploadMedia(fileURL: string): Promise<FileUploadResult>{
  582. - this.fileTransfer = new Transfer();
  583. + let fileTransfer = this.transfer.create();
  584. let options: any = {};
  585. let mediaType = fileURL.substring(fileURL.lastIndexOf('.'));
  586. //.GIF?BSDFH
  587. @@ -144,16 +144,16 @@ export class APIProvider {
  588. options.fileName = "tootyFruity_image.jpg"
  589. break;
  590. case('.png'):
  591. - options.mimeType = "image/png"
  592. + options.mimeType = "image/png"
  593. options.fileName = "tootyFruity_image.png"
  594. break;
  595. case('.gif'):
  596. - options.mimeType = "image/gif"
  597. + options.mimeType = "image/gif"
  598. options.fileName = "tootyFruity_image.gif"
  599. options.chunkedMode = false;
  600. break;
  601. default:
  602. - return null;
  603. + return null;
  604. }
  605. options.headers = {'Authorization' : 'Bearer '+ this.currentAccount.accessToken}
  606. console.log(fileURL);
  607. @@ -168,7 +168,7 @@ export class APIProvider {
  608. // console.log(JSON.stringify(this.mediaUploadsProgress))
  609. // }
  610. // })
  611. - return this.fileTransfer.upload(fileURL, this.currentAccount.instanceUrl + "/api/v1/media", uploadOptions);
  612. + return fileTransfer.upload(fileURL, this.currentAccount.instanceUrl + "/api/v1/media", uploadOptions);
  613. }
  614.  
  615. getTimeline(type: string, max_id?: string, since_id?: string): Observable<Response> {
  616. @@ -192,7 +192,7 @@ export class APIProvider {
  617. postToot(newToot:TootForm): Observable<Response>{
  618. let body = {'status': newToot.status,
  619. 'visibility': newToot.visibility};
  620. -
  621. +
  622. if(newToot.in_reply_to_id != null){
  623. body['in_reply_to_id'] = newToot.in_reply_to_id;
  624. }
  625. @@ -206,7 +206,7 @@ export class APIProvider {
  626. }
  627. body['media_ids'] = newToot.media_ids;
  628. }
  629. - return this.postRequest('/api/v1/statuses',body);
  630. + return this.postRequest('/api/v1/statuses',body);
  631. }
  632.  
  633.  
  634. @@ -247,7 +247,7 @@ export class APIProvider {
  635. private postRequest(apiUrl:string, body:any): Observable<Response>{
  636. let requestOptions = this.finalizeRequestOptions();
  637. return this.http.post(this.currentAccount.instanceUrl + apiUrl, body, requestOptions);
  638. - }
  639. + }
  640.  
  641. preAuthPost(api_url: string, body: any): Observable<any>{
  642. let contentTypeHeaders = new Headers(['Content-type', 'application/json'])
  643. @@ -255,10 +255,10 @@ export class APIProvider {
  644. console.log(api_url)
  645. return this.http.post(api_url, body, request)
  646. .map(this.extractData)
  647. - .catch(err => {
  648. + .catch(err => {
  649. console.log(JSON.stringify(err));
  650. return Observable.throw(err); // observable needs to be returned or exception raised
  651. - })
  652. + })
  653. }
  654.  
  655. private finalizeRequestOptions(requestOptions?: RequestOptionsArgs){
  656. @@ -277,5 +277,5 @@ export class APIProvider {
  657. if (body.data == undefined) return body
  658. else return body.data;
  659. }
  660. -
  661. +
  662. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement