Compare commits

...

2 commits

View file

@ -270,7 +270,7 @@ namespace Buypeeb {
} }
} }
private void UpdateItem(string id, bool refilterWhenDone = false) { private void UpdateItem(string id, bool renderListWhenDone = false) {
var item = this.settings.watchlist[id]; var item = this.settings.watchlist[id];
if (item.updatedRecently) { if (item.updatedRecently) {
// the item has been updated recently, and force is not true // the item has been updated recently, and force is not true
@ -284,9 +284,10 @@ namespace Buypeeb {
this.UpdateThread(id); this.UpdateThread(id);
}).ContinueWith(task => { }).ContinueWith(task => {
taskLimit.Release(); taskLimit.Release();
if (refilterWhenDone) { if (renderListWhenDone) {
var m = (TreeModelFilter)this.itemTreeView.Model; Gtk.Application.Invoke(delegate {
m.Refilter(); this.RenderList();
});
} }
}); });
} }
@ -441,6 +442,11 @@ namespace Buypeeb {
} }
private void RenderList() { private void RenderList() {
string id = null;
if (this.selectedItem != null) {
id = this.selectedItem.id;
}
this.items.Clear(); this.items.Clear();
var values = this.settings.watchlist.Values; var values = this.settings.watchlist.Values;
IOrderedEnumerable<YahooAuctionsItem> sorted; IOrderedEnumerable<YahooAuctionsItem> sorted;
@ -481,6 +487,14 @@ namespace Buypeeb {
var m = (TreeModelFilter)this.itemTreeView.Model; var m = (TreeModelFilter)this.itemTreeView.Model;
m.Refilter(); m.Refilter();
if (id != null) {
// attempt to reselect the item we were just looking at
var pathAndIter = this.GetRow(id);
if (pathAndIter.path != null) {
this.itemTreeView.Selection.SelectPath(pathAndIter.path);
}
}
} }
// event handlers // event handlers
@ -498,7 +512,7 @@ namespace Buypeeb {
// TODO: better. do better. // TODO: better. do better.
Regex rx = new Regex(@"^http.+yahoo.+"); Regex rx = new Regex(@"^http.+yahoo.+");
if (rx.IsMatch(url)) { if (rx.IsMatch(url)) {
this.UpdateItem(this.settings.Watch(url, name).id); this.UpdateItem(this.settings.Watch(url, name).id, true);
this.RenderList(); this.RenderList();
} }
else { else {
@ -730,11 +744,7 @@ namespace Buypeeb {
if (this.settings.displayFavouritesAtTopOfList) { if (this.settings.displayFavouritesAtTopOfList) {
var id = this.selectedItem.id; var id = this.selectedItem.id;
// re-render the list, to ensure the favourites get pushed to the top
this.RenderList(); this.RenderList();
// attempt to reselect the item we were just looking at
var pathAndIter = this.GetRow(id);
this.itemTreeView.Selection.SelectPath(pathAndIter.path);
} }
else { else {
// i don't know why this is necessary // i don't know why this is necessary