X-Git-Url: http://git.roojs.org/?p=gitlive;a=blobdiff_plain;f=RooRepo.vala;h=eb4740684450124ebd9303a074863ac3fc12a2c4;hp=b8c270a993883d02e2b3b45f38ee8c13e54355a9;hb=refs%2Fheads%2Fwip_alan_T5632_cache_project_listing;hpb=be03b94f3378a241e9b0769abd68eae2d9f55601 diff --git a/RooRepo.vala b/RooRepo.vala index b8c270a9..eb474068 100644 --- a/RooRepo.vala +++ b/RooRepo.vala @@ -5,29 +5,35 @@ static RooRepo _RooRepo ; public class RooRepo : Object { - - + public string id; // not really important that they are numbers.. public string project_id; public string description; public string shortname; + // -- static below... + const string roourl = "https://roojs.com/admin.php/Roo"; + static Gee.ArrayList _repos; // only available for singletonn. + static int loadcount = 0; + static RooRepo init() { if (_RooRepo == null) { _RooRepo = new RooRepo(); + RooRepo.loadcount = 0; RooRepo.load(); } return _RooRepo; } - static Gee.ArrayList _repos; // only available for singletonn. - static public Gee.ArrayList() { + + public static Gee.ArrayList repos() { RooRepo.init(); return RooRepo._repos; } - public RooRepo add(Json.Object t) + + static RooRepo add(Json.Object t) { var add = new RooRepo(); add.id = t.get_string_member("id"); @@ -38,6 +44,16 @@ public class RooRepo : Object GLib.debug("ADD project %s : %s : %s", add.id, add.shortname, add.project_id); return add; } + + public static void reload() /// has to be called on singleton.. + { + RooRepo.loadcount = 0; + RooRepo.init(); + if (RooRepo.loadcount == 0 ) { + RooRepo.load(); + } + } + static void load() // only called from above { @@ -84,7 +100,7 @@ public class RooRepo : Object // got a valid result... for(var i = 0; i < rd.get_length(); i++) { - _this.add(rd.get_object_element(i)); + RooRepo.add(rd.get_object_element(i)); }