diff --git a/WebKit/scripts/controller/Conversation.js b/WebKit/scripts/controller/Conversation.js index 16953a2..bb99b0e 100644 --- a/WebKit/scripts/controller/Conversation.js +++ b/WebKit/scripts/controller/Conversation.js @@ -72,9 +72,9 @@ function(HostApp, Core, Paths, URI) { var url = URI(Paths.mkApiRootPath("/posts/" + id)); Paths.getURL(url.toString(), "GET", callback, null); - } else if(this.followings.followings[entity]) { + } else if(this.cache.followings[entity]) { - getRemoteStatus(this.followings.followings[entity].profile); + getRemoteStatus(this.cache.followings[entity].profile); } else { diff --git a/WebKit/scripts/controller/Mentions.js b/WebKit/scripts/controller/Mentions.js index af09832..20ca384 100644 --- a/WebKit/scripts/controller/Mentions.js +++ b/WebKit/scripts/controller/Mentions.js @@ -33,8 +33,8 @@ function(HostApp, Timeline) { var status = statuses[i]; var name; - if(this.followings.followings[status.entity]) { - name = this.followings.followings[status.entity].profile["https://tent.io/types/info/basic/v0.1.0"].name; + if(this.cache.followings[status.entity]) { + name = this.cache.followings[status.entity].profile["https://tent.io/types/info/basic/v0.1.0"].name; } HostApp.notificateUserAboutMention(status.content.text, name || status.entity, status.id, status.entity); diff --git a/WebKit/scripts/controller/Profile.js b/WebKit/scripts/controller/Profile.js index 120c3d1..74591bb 100644 --- a/WebKit/scripts/controller/Profile.js +++ b/WebKit/scripts/controller/Profile.js @@ -26,7 +26,7 @@ function(HostApp, Core, Paths, URI) { this.profile_template.entity.innerHTML = this.entity; this.profile_template.entity.href = this.entity; - this.setFollowingButton(!!this.followings.followings[this.entity]); + this.setFollowingButton(!!this.cache.followings[this.entity]); this.getProfile(); } @@ -313,14 +313,14 @@ function(HostApp, Core, Paths, URI) { Profile.prototype.toggleFollow = function() { var _this = this; - var callback = function(resp) { _this.followings.getAllFollowings(); debug(resp.responseText) }; + var callback = function(resp) { _this.cache.getAllFollowings(); debug(resp.responseText) }; - if (this.followings.followings[this.entity]) { + if (this.cache.followings[this.entity]) { - var url = URI(Paths.mkApiRootPath("/followings/" + this.followings.followings[this.entity].id)); + var url = URI(Paths.mkApiRootPath("/followings/" + this.cache.followings[this.entity].id)); Paths.getURL(url.toString(), "DELETE", callback); this.setFollowingButton(false); - delete this.followings.followings[this.entity]; + delete this.cache.followings[this.entity]; } else { diff --git a/WebKit/scripts/helper/Core.js b/WebKit/scripts/helper/Core.js index 00e9ddf..d55e24e 100644 --- a/WebKit/scripts/helper/Core.js +++ b/WebKit/scripts/helper/Core.js @@ -3,15 +3,15 @@ define([ "helper/Paths", "lib/URI", "helper/HostApp", - "helper/Followings", + "helper/Cache", "lib/Timeago" ], -function(jQuery, Paths, URI, HostApp, Followings) { +function(jQuery, Paths, URI, HostApp, Cache) { function Core() { - this.followings = new Followings(); + this.cache = new Cache(); } @@ -207,9 +207,9 @@ function(jQuery, Paths, URI, HostApp, Followings) { } - if (this.followings.followings[status.entity]) { + if (this.cache.followings[status.entity]) { - profile(this.followings.followings[status.entity].profile); + profile(this.cache.followings[status.entity].profile); } else { @@ -234,9 +234,9 @@ function(jQuery, Paths, URI, HostApp, Followings) { return false; } - if (this.followings.followings[status.__repost.entity]) { + if (this.cache.followings[status.__repost.entity]) { - var basic = this.followings.followings[status.__repost.entity].profile["https://tent.io/types/info/basic/v0.1.0"]; + var basic = this.cache.followings[status.__repost.entity].profile["https://tent.io/types/info/basic/v0.1.0"]; template.reposted_by.innerText = basic.name; } else { @@ -420,7 +420,13 @@ function(jQuery, Paths, URI, HostApp, Followings) { "content": { "entity": entity, "id": id - } + }, + "mentions": [ + { + "entity": entity, + "post": id + } + ] }; Paths.getURL(url.toString(), "POST", callback, JSON.stringify(data)); @@ -577,9 +583,9 @@ function(jQuery, Paths, URI, HostApp, Followings) { } } - if (_this.followings.followings[mention.entity]) { + if (_this.cache.followings[mention.entity]) { - profile(_this.followings.followings[mention.entity].profile) + profile(_this.cache.followings[mention.entity].profile) } else { diff --git a/WebKit/scripts/helper/Followings.js b/WebKit/scripts/helper/Followings.js deleted file mode 100644 index b446f28..0000000 --- a/WebKit/scripts/helper/Followings.js +++ /dev/null @@ -1,48 +0,0 @@ -define([ - "helper/Paths", - "lib/URI" -], - -function(Paths, URI) { - - function Followings() { - - this.timeout = 2 * 60 * 1000; - this.followings = {}; - this.before_id = null; - - var _this = this; - this.intervall = setInterval(function() { _this.getAllFollowings(); }, this.timeout); - - this.getAllFollowings(); - } - - Followings.prototype.getAllFollowings = function() { - - var _this = this; - - var callback = function(resp) { - - var fs = JSON.parse(resp.responseText) - - if (fs.length < 1) return; - - for (var i = 0; i < fs.length; i++) { - - var following = fs[i]; - _this.before_id = following.id; - _this.followings[following.entity] = following; - } - } - - var url = URI(Paths.mkApiRootPath("/followings")); - if (this.before_id) { - url.addSearch("before_id", this.before_id); - } - - Paths.getURL(url, "GET", callback); - } - - return Followings; - -}); \ No newline at end of file