Matt Hamilton avatar Matt Hamilton committed 89db004

Minor fixes published

Comments (0)

Files changed (5)

Source/Halfwit2/Halfwit2.csproj

     <PublisherName>Mad Props!</PublisherName>
     <CreateWebPageOnPublish>true</CreateWebPageOnPublish>
     <WebPage>publish.htm</WebPage>
-    <ApplicationRevision>56</ApplicationRevision>
+    <ApplicationRevision>57</ApplicationRevision>
     <ApplicationVersion>2.0.0.%2a</ApplicationVersion>
     <UseApplicationTrust>false</UseApplicationTrust>
     <PublishWizardCompleted>true</PublishWizardCompleted>

Source/Halfwit2/ViewModels/SavedSearchViewModel.cs

         public SavedSearchViewModel(SearchViewModel host, TwitterSavedSearch search)
         {
             _host = host;
-            _id = search.Id;
+            Id = search.Id;
             Text = search.Query;
             DeleteCommand = new RelayCommand(Delete);
         }
 
-        long _id;
         SearchViewModel _host;
 
         void Delete()
         {
-            _host.Service.DeleteSavedSearchAsync(_id);
+            _host.Delete(this);
         }
 
+        public long Id { get; private set; }
         public string Text { get; private set; }
         public ICommand DeleteCommand { get; private set; }
     }

Source/Halfwit2/ViewModels/Timelines/SearchViewModel.cs

                 Header = "Search";
                 Uri = BaseUri + "search";
                 Status = String.Empty;
-                Pollers[0].Reset();
                 return;
             }
 
                 Uri = BaseUri + "search/" + _searchText;
 
                 Status = "Searching for " + _searchText + "...";
-                Pollers[0].Poll();
             }
             Pollers[0].Poll();
         }
         public ICommand PollCommand { get; private set; }
         public ICommand SaveCommand { get; private set; }
 
+        public void Delete(SavedSearchViewModel item)
+        {
+            Service.DeleteSavedSearchAsync(item.Id).ContinueOnUIThreadWith(task =>
+            {
+                if (task.IsFaulted)
+                {
+                    Status = task.ErrorMessage();
+                    return;
+                }
+
+                var response = task.Result;
+                if (response.StatusCode != System.Net.HttpStatusCode.OK)
+                {
+                    Status = response.ErrorMessage;
+                    return;
+                }
+
+                _searches.Remove(item);
+            });
+        }
+
         public string Text
         {
             get { return _text; }

Source/Halfwit2/ViewModels/Timelines/TimelineViewModel.cs

         void UserAuthenticated(UserAuthenticatedEvent e)
         {
             this.Clear();
-            foreach (var poller in Pollers) poller.Reset();
         }
 
         void poller_PollCompleted(object sender, TwitterPollCompletedEventArgs e)
         protected void Clear()
         {
             _items.Clear();
+            foreach (var poller in Pollers) poller.Reset();
         }
 
         protected virtual void OnRefresh()

Source/Halfwit2/ViewModels/Timelines/UserTimelineViewModel.cs

 
         void GotUser(Task<ITwitterResponse<TwitterUser>> task)
         {
-            if (task.IsFaulted)
-            {
-                Status = task.Exception.Message;
-                return;
-            }
+            Dispatcher.Background(() =>
+                {
+                    if (task.IsFaulted)
+                    {
+                        Status = task.Exception.Message;
+                        return;
+                    }
 
-            var response = task.Result;
-            if (response.StatusCode != System.Net.HttpStatusCode.OK)
-            {
-                Status = response.ErrorMessage;
-                return;
-            }
+                    var response = task.Result;
+                    if (response.StatusCode != System.Net.HttpStatusCode.OK)
+                    {
+                        Status = response.ErrorMessage;
+                        return;
+                    }
 
-            var user = response.Result;
+                    var user = response.Result;
 
-            if (user == null)
-            {
-                Status = "Unknown error: Possible space/time continuum anomaly";
-                return;
-            }
+                    if (user == null)
+                    {
+                        Status = "Unknown error: Possible space/time continuum anomaly";
+                        return;
+                    }
 
-            Pollers[0].Reset();
+                    Header = "Tweets by " + user.Name;
+                    Uri = BaseUri + user.ScreenName;
+                    this.User = new UserViewModel(user);
 
-            Header = "Tweets by " + user.Name;
-            Uri = BaseUri + user.ScreenName;
-            this.User = new UserViewModel(user);
-
-            Status = "Retrieving tweets by " + user.Name + "...";
-            Pollers[0].Poll();
+                    Status = "Retrieving tweets by " + user.Name + "...";
+                    Pollers[0].Poll();
+                });
         }
 
         bool CanPoll()
             {
                 Clear();
                 Status = "Retrieving user information for " + Text.Trim() + "...";
-                Service.GetUserAsync(Text.Trim()).ContinueOnUIThreadWith(GotUser);
+                Service.GetUserAsync(Text.Trim()).ContinueWith(GotUser);
             }
         }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.