Advertisement
Guest User

Untitled

a guest
Jan 26th, 2018
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. return this._dbPromise.then(function(db) {
  2.     // if we're already showing posts, eg shift-refresh
  3.     // or the very first load, there's no point fetching
  4.     // posts from IDB
  5.     if (!db || indexController._postsView.showingPosts()) return;
  6.  
  7.     // TODO: get all of the wittr message objects from indexeddb,
  8.     // then pass them to:
  9.     // indexController._postsView.addPosts(messages)
  10.     // in order of date, starting with the latest.
  11.     // Remember to return a promise that does all this,
  12.     // so the websocket isn't opened until you're done!
  13.     var tx = db.transaction('wittrs');
  14.     var store = tx.objectStore('wittrs');
  15.     var timeIndex = store.index('by-date');
  16.  
  17.     return timeIndex.getAll();
  18.   }).then(function(messages) {
  19.     indexController._postsView.addPosts(messages);
  20.   });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement