Imported Upstream version 0.2.10
[debian/pino.git] / src / timeline_list.vala
index ce4a9e2..805f362 100644 (file)
@@ -61,11 +61,10 @@ public class TimelineList : TimelineListAbstract {
                                no_fresh();
                        }
                }
-       } 
+       }
        
        public signal void fresh();
        public signal void no_fresh();
-       public signal void deleted(string message);
        
        public TimelineList(Window _parent, Accounts _accounts, TimelineType timeline_type,
                Template _template, int __items_count = 20, Icon? _icon = null,
@@ -95,6 +94,14 @@ public class TimelineList : TimelineListAbstract {
                string since_id = "";
                bool first_time = true;
                
+               //clearing temporary statuses
+               for(int i = 0; i < lst.size; i++) {
+                       if(lst.get(i).tmp) {
+                               lst.remove_at(i);
+                               i--;
+                       }
+               }
+               
                if(lst.size > 0) {
                        since_id = lst.get(0).id;
                        first_time = false;
@@ -105,12 +112,23 @@ public class TimelineList : TimelineListAbstract {
                } catch(RestError e) {
                        updating_error(e.message);
                        return result;
+               } catch(ParseError e) {
+                       updating_error(e.message);
+                       return result;
                }
                
+               debug("SIZE: %d", result.size);
+               
                if(result.size > 0) { //if we got some statuses
                        if((!_parent_focus || !act.active) && lst.size > 0) { //if this list is not visible and we have updates
+                               int self_count = 0;
+                               foreach(Status status in result) {
+                                       if(status.user_screen_name == api.account.login)
+                                               self_count++;
+                               }
                                
-                               have_fresh = true;
+                               if(self_count < result.size) //if we got not only our tweets
+                                       have_fresh = true;
                        }
                        
                        if(lst.size == 0) {
@@ -127,9 +145,7 @@ public class TimelineList : TimelineListAbstract {
                if(!parent_focus) //delete only if main window out of focus
                        delete_extra();
                
-               warning("SIZE: %d", lst.size);
-               
-               refresh();
+               refresh(true);
                
                if((act.active && _parent_focus) || last_focused == 0) {
                        if(lst.size > 0)
@@ -147,11 +163,12 @@ public class TimelineList : TimelineListAbstract {
        /* insert new status */
        public void insert_status(Status status) {
                lst.insert(0, status);
-               delete_extra();
+               //tmp_lst.add(status);
+               //delete_extra();
                
-               last_focused = (int)lst.get(0).created_at.mktime();
+               //last_focused = (int)lst.get(0).created_at.mktime();
                
-               refresh();
+               refresh(true);
        }
        
        /* delete status with some id */
@@ -159,7 +176,7 @@ public class TimelineList : TimelineListAbstract {
                try {
                        api.destroy_status(id);
                } catch(RestError e) {
-                       warning(e.message);
+                       debug(e.message);
                        updating_error(e.message);
                        return;
                }
@@ -174,19 +191,20 @@ public class TimelineList : TimelineListAbstract {
                
                last_focused = (int)lst.get(0).created_at.mktime();
                
-               refresh();
+               refresh(true);
                
                deleted(_("Your status has been deleted successfully")); //signal
        }
        
        /* get older statuses */
        protected override void get_older() {
+               debug("more");
                if(lst.size < 1)
                        return;
                
                more.set_enabled(false);
                
-               ArrayList<RestAPI.Status> result;
+               ArrayList<RestAPI.Status>? result = null;
                string max_id = lst.get(lst.size - 1).id;
                
                try {
@@ -195,6 +213,9 @@ public class TimelineList : TimelineListAbstract {
                        more.set_enabled(true);
                        updating_error(e.message);
                        return;
+               } catch(ParseError e) {
+                       updating_error(e.message);
+                       return;
                }
                
                if(result.size < 2) {
@@ -208,6 +229,6 @@ public class TimelineList : TimelineListAbstract {
                
                more.set_enabled(true);
                
-               refresh();
+               refresh(true);
        }
 }