This repository has been archived on 2025-08-18. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
Bungloo/WebKit/scripts/helper/Cache.js
Jeena Paradies c3d1ce7d24 added Cache
2012-12-11 00:46:08 +01:00

50 lines
No EOL
1.2 KiB
JavaScript

define([
"helper/Paths",
"lib/URI",
"helper/CacheStorage"
],
function(Paths, URI, CacheStorage) {
var Cache = {};
var timeout = 2 * 60 * 1000;
var followings_before_id = null;
Cache.followings = new CacheStorage("followings");
Cache.profiles = new CacheStorage("profiles");
Cache.profile_urls = new CacheStorage("profile_urls");
Cache.getFollowings = function() {
function callback(resp) {
var fs = JSON.parse(resp.responseText)
if (fs.length < 1) return;
for (var i = 0; i < fs.length; i++) {
var following = fs[i];
followings_before_id = following.id;
Cache.followings.setItem(following.entity, following)
Cache.profiles.setItem(following.entity, following);
}
}
var u = Paths.mkApiRootPath("/followings");
var url = URI(u);
if (followings_before_id) {
url.addSearch("before_id", followings_before_id);
}
Paths.getURL(url, "GET", callback);
}
// setTimeout(function(){ Cache.getAllFollowings() }, timeout);
return Cache;
});