Compare commits

..

No commits in common. "82c666296a9a32d46d21395c51c4e56c64aed155" and "49119fc6dcf7d23fa3a2d1198891853c14aa9994" have entirely different histories.

3 changed files with 7 additions and 60 deletions

View file

@ -55,7 +55,6 @@ namespace Buypeeb {
static SemaphoreSlim taskLimit = new SemaphoreSlim(6);
private Queue<string> updateQueue = new Queue<string>();
private IEnumerable<YahooAuctionsItem> filterQuery;
private IEnumerable<YahooAuctionsItem> outdatedItemQuery;
private YahooAuctionsItem selectedItem {
get {
@ -116,14 +115,6 @@ namespace Buypeeb {
this.filterChecks[name].Active = false;
}
// only returns items that meet all of the following:
// - marked as "ready", as in, they aren't in the process of updating
// - not updated since the interval
this.outdatedItemQuery =
from item in this.settings.watchlist.Values.ToList()
where item.ready && this.settings.ItemNotUpdatedSinceInterval(item)
select item;
// father forgive me for i have lynned
this.filterQuery =
from item in this.settings.watchlist.Values.ToList()
@ -164,7 +155,6 @@ namespace Buypeeb {
this.RenderList();
this.UpdateItems();
GLib.Timeout.Add(1000, new GLib.TimeoutHandler(UpdateSelectionEndTime));
GLib.Timeout.Add(10000, new GLib.TimeoutHandler(AutoUpdateItems));
DeleteEvent += WindowShutdown;
}
@ -203,11 +193,11 @@ namespace Buypeeb {
if (!Directory.Exists(this.location)) {
Directory.CreateDirectory(this.location);
}
using (StreamWriter fs = File.CreateText(p)) {
fs.Write(j);
if (!File.Exists(p)) {
var fs = File.CreateText(p);
fs.Close();
}
File.WriteAllText(System.IO.Path.Combine(this.location, "userdata.json"), j);
}
private void UpdateThread(string id) {
@ -529,10 +519,10 @@ namespace Buypeeb {
if (sd.Run() == (int)ResponseType.Accept) {
try {
if (!File.Exists(sd.Filename)) {
using (StreamWriter fs = File.CreateText(sd.Filename)) {
fs.Write(JsonSerializer.Serialize(this.settings, jsonOptions));
}
var fs = File.CreateText(sd.Filename);
fs.Close();
}
File.WriteAllText(sd.Filename, JsonSerializer.Serialize(this.settings, jsonOptions));
}
catch (Exception e) {
Console.WriteLine(e);
@ -684,24 +674,6 @@ namespace Buypeeb {
return true;
}
private bool AutoUpdateItems() {
if (this.queueActive) {
// don't autoupdate if the queue is active
return true;
}
foreach (var item in this.outdatedItemQuery) {
updateQueue.Enqueue(item.id);
}
if (updateQueue.TryPeek(out string _)) {
// there's at least one item in the queue
this.ProcessUpdateQueue();
}
return true;
}
// column renderers
private void RenderColumnFavourite(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.ITreeModel model, Gtk.TreeIter iter) {

View file

@ -27,29 +27,5 @@ namespace Buypeeb {
this.watchlist[id] = new YahooAuctionsItem(id, name);
return this.watchlist[id];
}
// TRUE if the item hasn't been updated for at least interval seconds
// for example, if the interval is 10, and the item hasn't been updated since 20 seconds ago, this will be TRUE
public bool ItemNotUpdatedSinceInterval(YahooAuctionsItem item) {
int seconds = 1000;
if (item.favourite) {
if (item.endingSoon) {
seconds = this.favouriteUpdateIntervalCritical;
}
else {
seconds = this.favouriteUpdateInterval;
}
}
else {
if (item.endingSoon) {
seconds = this.updateIntervalCritical;
}
else {
seconds = this.updateInterval;
}
}
var later = item.lastUpdated.AddSeconds(seconds);
return DateTime.Compare(later, DateTime.UtcNow) < 0;
}
}
}

View file

@ -53,7 +53,6 @@ namespace Buypeeb {
public bool endingToday { get { return this.endDate.DayOfYear == DateTime.UtcNow.DayOfYear; } }
public bool hasWinPrice { get { return this.winPrice != 0; } }
private bool success { get; set; } // TODO: custom setter that throws an exception if set to false or something idk
public bool endingSoon { get { return DateTime.Compare(DateTime.UtcNow.AddMinutes(10), this.endDate) > 0; } }
public YahooAuctionsItem(string id, string name) {
this.id = id;