mock-provider.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import { Injectable } from "@angular/core";
  2. import { Storage } from "@ionic/storage";
  3. import * as tweets from './tweet.json';
  4. @Injectable()
  5. export class MockProvider {
  6. friends;
  7. userId: string;
  8. mockTweets;
  9. constructor(
  10. private storage: Storage
  11. ) {
  12. this.storage.get("userId").then(userId => (this.userId = userId));
  13. }
  14. /**
  15. * Retrives the public and private tweets for a user
  16. * Since it is loaded in batches of 20 public tweets, public and private tweet are used as reference to load next 20 tweets
  17. * @param userId user id
  18. * @param oldestPublicTweet oldest public tweet
  19. * @param oldestPrivateTweet oldest private tweet
  20. */
  21. public async loadUserTimeline(
  22. userId,
  23. oldestPublicTweet?,
  24. oldestPrivateTweet?
  25. )
  26. {
  27. }
  28. /**
  29. * Retrieves the home feed for the logged in user
  30. * Since it is loaded in batches of 20 public tweets, public and private tweet are used as reference to load next 20 tweets
  31. * @param oldestPublicTweet oldest public tweet
  32. * @param oldestPrivateTweet oldest private tweet
  33. */
  34. public async loadHomeTimeline(oldestPublicTweet?, oldestPrivateTweet?) {
  35. console.log('hometime line called',tweets);
  36. this.mockTweets = tweets;
  37. return tweets;
  38. // Fetch tweets from Twitter
  39. // Determine start and end of time interval to look for private tweets
  40. // Fetch user's friends
  41. // Extract friends user ids and add own user id
  42. // Fetch ipfs hashs for period
  43. // Combine and sort tweets
  44. }
  45. public async replyTweet(){
  46. }
  47. public async writeTweet(twt:string){
  48. console.log('inside writetweet',this.mockTweets[0]);
  49. console.log('inside writetweet obj is:',this.mockTweets[0].full_text);
  50. let newTweet = Object.assign({}, this.mockTweets[0]);
  51. newTweet.full_text = twt;
  52. console.log('new tweet ',newTweet);
  53. tweets.push(newTweet);
  54. // this.mockTweets.push(newTweet);
  55. // var newTweet =JSON.parse(tweet[0]);
  56. // newTweet.full_text = tweet;
  57. // console.log('writing tweeet',tweets.push(newTweet));
  58. // this.loadHomeTimeline();
  59. }
  60. private async fetchPrivateTweets(privateTweetsData: object[]) {
  61. }
  62. }