Browse Source

Deleting unfollowed user's following data from storage and fixing image preview maximum width

master
erqan 11 years ago
parent
commit
098cfa8e1c
  1. 4
      css/style.css
  2. 60
      js/twister_following.js
  3. 10
      js/twister_io.js

4
css/style.css

@ -1058,10 +1058,10 @@ ol.toptrends-list {
.image-preview .image-preview
{ {
max-height: 500px; max-height: 500px;
max-width: 530px; max-width: 495px;
width: auto; width: auto;
display: block; display: block;
margin: 0 auto; margin: 0 auto 10px auto;
} }
.preview-container .preview-container
{ {

60
js/twister_following.js

@ -83,14 +83,28 @@ TwisterFollowing.prototype = {
var oneshot = false; var oneshot = false;
var i = 0; var i = 0;
if (typeof(username) !== 'undefined') { if (typeof(username) !== 'undefined') {
i = followingUsers[username]; //activate updating for only one user...
i = followingUsers.indexOf(username);
if (i > -1) if (i > -1)
oneshot = true; oneshot = true;
else else if (typeof(this.followingsFollowings[username]) !== 'undefined') {
i = 0; delete this.followingsFollowings[username];
this.save();
return;
}
} }
var updated = false;
for (var user in this.followingsFollowings) {
if (followingUsers.indexOf(user) < 0) {
delete this.followingsFollowings[user];
updated = true;
}
}
if (updated)
this.save();
for (; i < followingUsers.length; i++) { for (; i < followingUsers.length; i++) {
var ctime = new Date().getTime() / 1000; var ctime = new Date().getTime() / 1000;
@ -98,15 +112,22 @@ TwisterFollowing.prototype = {
ctime - this.followingsFollowings[followingUsers[i]]["lastUpdate"] >= this.followingsFollowings[followingUsers[i]]["updateInterval"]) { ctime - this.followingsFollowings[followingUsers[i]]["lastUpdate"] >= this.followingsFollowings[followingUsers[i]]["updateInterval"]) {
loadFollowingFromDht(followingUsers[i], 1, [], 0, function (args, following, seqNum) { loadFollowingFromDht(followingUsers[i], 1, [], 0, function (args, following, seqNum) {
var updated = false;
if (following.indexOf(args.tf.user) > -1) { if (following.indexOf(args.tf.user) > -1) {
if (args.tf.knownFollowers.indexOf(args.fu) < 0) if (args.tf.knownFollowers.indexOf(args.fu) < 0) {
args.tf.knownFollowers.push(args.fu); args.tf.knownFollowers.push(args.fu);
updated = true;
}
} else { } else {
if (args.tf.notFollowers.indexOf(args.fu) < 0) if (args.tf.notFollowers.indexOf(args.fu) < 0) {
args.tf.notFollowers.push(args.fu); args.tf.notFollowers.push(args.fu);
updated = true;
}
var tmpi = args.tf.knownFollowers.indexOf(args.fu); var tmpi = args.tf.knownFollowers.indexOf(args.fu);
if (tmpi > -1) if (tmpi > -1) {
args.tf.knownFollowers.splice(tmpi, 1); args.tf.knownFollowers.splice(tmpi, 1);
updated = true;
}
} }
$(".open-followers").attr("title", args.tf.knownFollowers.length.toString()); $(".open-followers").attr("title", args.tf.knownFollowers.length.toString());
@ -118,28 +139,42 @@ TwisterFollowing.prototype = {
args.tf.followingsFollowings[args.fu]["updateInterval"] = TwisterFollowing.minUpdateInterval; args.tf.followingsFollowings[args.fu]["updateInterval"] = TwisterFollowing.minUpdateInterval;
args.tf.followingsFollowings[args.fu]["following"] = following; args.tf.followingsFollowings[args.fu]["following"] = following;
args.tf.save(); updated = true;
} else { } else {
var diff = []; var diff = []; //diff for following
var difu = []; //diff for unfollowing
var ff = args.tf.followingsFollowings[args.fu]["following"]; var ff = args.tf.followingsFollowings[args.fu]["following"];
//is there any new following?
for (var j = 0; j < following.length; j++) { for (var j = 0; j < following.length; j++) {
if (ff.indexOf(following[j]) === -1) { if (ff.indexOf(following[j]) === -1) {
diff.push(following[j]); diff.push(following[j]);
ff.push(following[j]); ff.push(following[j]);
} }
} }
//did user unfollow someone?
for (var j = ff.length - 1; j >= 0 && ff.length > following.length; j--) {
if (following.indexOf(ff[j]) === -1) {
difu.push(ff[j]);
ff.splice(j, 1);
}
}
if (diff.length > 0) { if (diff.length > 0 || difu.length > 0) {
args.tf.followingsFollowings[args.fu]["updateInterval"] = TwisterFollowing.minUpdateInterval; args.tf.followingsFollowings[args.fu]["updateInterval"] = TwisterFollowing.minUpdateInterval;
args.tf.followingsFollowings[args.fu]["lastUpdate"] = ctime; args.tf.followingsFollowings[args.fu]["lastUpdate"] = ctime;
args.tf.save(); updated = true;
} else if (args.tf.followingsFollowings[args.fu]["updateInterval"] < TwisterFollowing.maxUpdateInterval) { } else if (args.tf.followingsFollowings[args.fu]["updateInterval"] < TwisterFollowing.maxUpdateInterval) {
args.tf.followingsFollowings[args.fu]["updateInterval"] *= 2; args.tf.followingsFollowings[args.fu]["updateInterval"] *= 2;
} }
if (updated)
args.tf.save();
} }
}, {"tf": this, "fu": followingUsers[i]}); }, {"tf": this, "fu": followingUsers[i]});
} }
if (oneshot)
break;
} }
} }
}; };
@ -339,6 +374,7 @@ function unfollow(user, cbFunc, cbArg) {
var i = followingUsers.indexOf(user); var i = followingUsers.indexOf(user);
if( i >= 0 ) { if( i >= 0 ) {
followingUsers.splice(i,1); followingUsers.splice(i,1);
twisterFollowingO.update(user);
} }
delete _isFollowPublic[user]; delete _isFollowPublic[user];
saveFollowing(); saveFollowing();
@ -750,10 +786,10 @@ function initInterfaceFollowing() {
$(".postboard-loading").fadeIn(); $(".postboard-loading").fadeIn();
loadFollowing( function(args) { loadFollowing( function(args) {
twisterFollowingO = TwisterFollowing(defaultScreenName);
showFollowingUsers(); showFollowingUsers();
requestSwarmProgress(); requestSwarmProgress();
twisterFollowingO = TwisterFollowing(defaultScreenName);
}); });
initMentionsCount(); initMentionsCount();
initDMsCount(); initDMsCount();

10
js/twister_io.js

@ -218,6 +218,15 @@ function getFullname( username, item ){
item.addClass('isFollowing'); item.addClass('isFollowing');
item.attr("title", polyglot.t("follows you")); item.attr("title", polyglot.t("follows you"));
} else if (twisterFollowingO.notFollowers.indexOf(username) === -1) { } else if (twisterFollowingO.notFollowers.indexOf(username) === -1) {
if (typeof(twisterFollowingO.followingsFollowings[username]) !== 'undefined' &&
typeof(twisterFollowingO.followingsFollowings[username]["following"]) !== 'undefined') {
if (twisterFollowingO.followingsFollowings[username]["following"].indexOf(defaultScreenName) > -1) {
twisterFollowingO.knownFollowers.push(username);
twisterFollowingO.save();
item.addClass('isFollowing');
item.attr("title", polyglot.t("follows you"));
}
} else {
loadFollowingFromDht(username, 1, [], 0, function (args, following, seqNum) { loadFollowingFromDht(username, 1, [], 0, function (args, following, seqNum) {
if (following.indexOf(args.user) > -1) { if (following.indexOf(args.user) > -1) {
item.addClass('isFollowing'); item.addClass('isFollowing');
@ -230,6 +239,7 @@ function getFullname( username, item ){
twisterFollowingO.save(); twisterFollowingO.save();
}, {"user": defaultScreenName, "item": item, "username": username}); }, {"user": defaultScreenName, "item": item, "username": username});
} }
}
$(".open-followers").attr("title", twisterFollowingO.knownFollowers.length.toString()); $(".open-followers").attr("title", twisterFollowingO.knownFollowers.length.toString());
} }

Loading…
Cancel
Save