mcongrove / ChariTi

Please do not use: this is out-dated
Other
113 stars 85 forks source link

Detail navigation error #193

Closed mcongrove closed 10 years ago

mcongrove commented 10 years ago

While viewing a detail screen ('next' and 'previous' article IDs are already retrieved), the database table is updated by the model which does a delete+insert, overwriting the current data with new posts that have a higher ID. This causes the 'next' and 'previous' IDs to be pointing to articles that no longer have those IDs, and causes the error.

rogerwhite commented 10 years ago

Can't reproduce:

SIMLULATOR: iphone, ipad DEVICES: iphone, ipad mini, ipad 4 FACEBOOK IDs TRIED WITH : 4

mcongrove commented 10 years ago

I actually just got this to reproduce; iPhone retina-tall simulator. It's still hard to get it to happen, but it occasionally will. First you have to open Facebook tab, then click on the 2nd post from the top, then navigate down. I think you might also have to delete the app from the sim and re-install it first, or something... not sure.

00000154

mcongrove commented 10 years ago

Got it... It happens when the model is downloading new data while you're in an article. For instance, you're viewing a post with a UID of 2 out of 20 (so hitting the down arrow will navigate to UID 3)... While viewing the post, the model downloads new data, and it deletes the database table before doing the inserts. UID 3 no longer exists, because the new posts have higher UIDs (21-41).

[DEBUG] :  APP.handleNavigation | facebook
[DEBUG] :  FACEBOOK.fetch
[DEBUG] :  HTTP.request http://www.facebook.com/feeds/page.php?format=json&id=20594753592
[DEBUG] :  facebook @click 23
[DEBUG] :  facebook_article.init | {"id":23,"index":2}
[DEBUG] :  FACEBOOK.init(2)
[DEBUG] :  FACEBOOK.getArticle
[DEBUG] :  facebook_article.handleData
[DEBUG] :  FACEBOOK.getNextArticle
[DEBUG] :  FACEBOOK.getPreviousArticle
[DEBUG] :  FACEBOOK.handleData
[DEBUG] :  FACEBOOK.getAllArticles(2)
[DEBUG] :  facebook.handleData
[DEBUG] :  facebook_article @next
[DEBUG] :  facebook_article.init | {"id":24,"index":2}
[DEBUG] :  FACEBOOK.init(2)
[DEBUG] :  FACEBOOK.getArticle
[DEBUG] :  facebook_article.handleData
[DEBUG] :  FACEBOOK.getNextArticle
[DEBUG] :  FACEBOOK.getPreviousArticle
[ERROR] :  Script Error {
[ERROR] :      backtrace = "#0 () at file:///Users/matthewcongrove/Library/Application%20Support/iPhone%20Simulator/7.0/Applications/56B3FA50-2D7A-4077-A576-300308F5C696/ChariTi.app/alloy/controllers/facebook_article.js:83\n#1 Controller() at file:///Users/matthewcongrove/Library/Application%20Support/iPhone%20Simulator/7.0/Applications/56B3FA50-2D7A-4077-A576-300308F5C696/ChariTi.app/alloy/controllers/facebook_article.js:128\n#2 () at file:///Users/matthewcongrove/Library/Application%20Support/iPhone%20Simulator/7.0/Applications/56B3FA50-2D7A-4077-A576-300308F5C696/ChariTi.app/alloy.js:214\n#3 () at file:///Users/matthewcongrove/Library/Application%20Support/iPhone%20Simulator/7.0/Applications/56B3FA50-2D7A-4077-A576-300308F5C696/ChariTi.app/core.js:266\n#4 () at file:///Users/matthewcongrove/Library/Application%20Support/iPhone%20Simulator/7.0/Applications/56B3FA50-2D7A-4077-A576-300308F5C696/ChariTi.app/alloy/controllers/facebook_article.js:116";
[ERROR] :      line = 88;
[ERROR] :      message = "'undefined' is not an object (evaluating '_data.date')";
[ERROR] :      name = TypeError;
[ERROR] :      sourceId = 327894528;
[ERROR] :      sourceURL = "file:///Users/matthewcongrove/Library/Application%20Support/iPhone%20Simulator/7.0/Applications/56B3FA50-2D7A-4077-A576-300308F5C696/ChariTi.app/alloy/controllers/facebook_article.js";
[ERROR] :  }

Solutions are to block navigation while data is being downloaded, reset the UID index to 0 when doing the insert, doing some sort of replace/update instead of an delete+insert... any other ideas, guys?

mcongrove commented 10 years ago

Apparently this was left over from when we had a refresh button instead of a pull-to-refresh. That meant that we displayed old data while new data was being downloaded, leading to the missing IDs.

I removed the ability to see old data while new data loaded in order to kill some global event leaks (since we now have pull-to-refresh), and inadvertently fixed this with commit c73172ad5625163a22cb844097d99a882655ca1b.

Yaaay.

rogerwhite commented 10 years ago

Awesome.