handle group/{id}/id urls, always cache user array headers, window.following as object with local id as key (instead of array) for easier lookup by id
This commit is contained in:
parent
df99f9bbaa
commit
1ba3c6bd29
|
@ -147,11 +147,9 @@ function getFromAPI(stream, actionOnSuccess) {
|
|||
|
||||
displayOrHideUnreadNotifications(request.getResponseHeader('Qvitter-Notifications'));
|
||||
|
||||
// profile card from user array, also cache it
|
||||
// parse and cache any user arrays in header
|
||||
var userArray = false;
|
||||
if(request.getResponseHeader('Qvitter-User-Array') !== null) {
|
||||
|
||||
// while waiting for this data user might have changed stream, so only proceed if current stream still is this one
|
||||
if(window.currentStream == stream) {
|
||||
var qvitterUserArrayHeader = request.getResponseHeader('Qvitter-User-Array');
|
||||
|
||||
// quitter.se fix
|
||||
|
@ -159,17 +157,15 @@ function getFromAPI(stream, actionOnSuccess) {
|
|||
qvitterUserArrayHeader = qvitterUserArrayHeader.replace(new RegExp('http:\\\\/\\\\/' + window.siteRootDomain, 'g'), 'https:\/\/' + window.siteRootDomain);
|
||||
}
|
||||
|
||||
var userArray = iterateRecursiveReplaceHtmlSpecialChars($.parseJSON(qvitterUserArrayHeader));
|
||||
userArray = iterateRecursiveReplaceHtmlSpecialChars($.parseJSON(qvitterUserArrayHeader));
|
||||
userArrayCacheStore(userArray);
|
||||
addProfileCardToDOM(buildProfileCard(userArray));
|
||||
}
|
||||
}
|
||||
|
||||
data = convertEmptyObjectToEmptyArray(data);
|
||||
data = iterateRecursiveReplaceHtmlSpecialChars(data);
|
||||
searchForUserDataToCache(data);
|
||||
|
||||
actionOnSuccess(data);
|
||||
actionOnSuccess(data, userArray);
|
||||
},
|
||||
error: function(data) {
|
||||
actionOnSuccess(false);
|
||||
|
|
|
@ -562,11 +562,16 @@ function setNewCurrentStream(streamObject,setLocation,actionOnSuccess) {
|
|||
}
|
||||
|
||||
// get stream
|
||||
getFromAPI(streamObject.stream, function(queet_data){
|
||||
getFromAPI(streamObject.stream, function(queet_data, userArray){
|
||||
if(queet_data) {
|
||||
// while waiting for this data user might have changed stream, so only proceed if current stream still is this one
|
||||
if(window.currentStream == streamObject.stream) {
|
||||
|
||||
// profile card from user array
|
||||
if(userArray) {
|
||||
addProfileCardToDOM(buildProfileCard(userArray));
|
||||
}
|
||||
|
||||
// show group profile card if this is a group stream
|
||||
if(streamObject.name == 'group notice stream'
|
||||
|| streamObject.name == 'group member list'
|
||||
|
|
|
@ -548,14 +548,7 @@ function searchForUserDataToCache(obj) {
|
|||
|
||||
function appendUserToMentionsSuggestionsArray(user) {
|
||||
|
||||
var userAlreadyExist = false;
|
||||
$.each(window.following, function(){
|
||||
if(user.id == this.id) {
|
||||
userAlreadyExist = true;
|
||||
}
|
||||
});
|
||||
|
||||
if(!userAlreadyExist) {
|
||||
if(typeof window.following[user.id] == 'undefined') {
|
||||
|
||||
// in the window.following array, we use "false" as url if it's a user from this instance
|
||||
if(user.is_local) {
|
||||
|
@ -565,14 +558,15 @@ function appendUserToMentionsSuggestionsArray(user) {
|
|||
var url = guessInstanceUrlWithoutProtocolFromProfileUrlAndNickname(user.statusnet_profile_url,user.screen_name);
|
||||
}
|
||||
|
||||
var userToAdd = Object();
|
||||
userToAdd.avatar = user.profile_image_url;
|
||||
userToAdd.id = user.id;
|
||||
userToAdd.name = user.name;
|
||||
userToAdd.url = url;
|
||||
userToAdd.username = user.screen_name;
|
||||
var userToAdd = {
|
||||
avatar: user.profile_image_url,
|
||||
id: user.id,
|
||||
name: user.name,
|
||||
url: url,
|
||||
username: user.screen_name
|
||||
};
|
||||
|
||||
window.following.push(userToAdd);
|
||||
window.following[user.id] = userToAdd;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -819,14 +819,13 @@ function doLogin(streamObjectToSet) {
|
|||
}
|
||||
|
||||
// get all users i'm following for autosuggestion
|
||||
window.following = new Array();
|
||||
window.groupMemberships = new Array();
|
||||
window.following = new Object();
|
||||
window.groupMemberships = new Object();
|
||||
window.groupNicknamesAndLocalAliases = new Array();
|
||||
|
||||
getFromAPI('qvitter/allfollowing/' + window.loggedIn.screen_name + '.json',function(data){
|
||||
|
||||
if(data.users) {
|
||||
var i=0;
|
||||
$.each(data.users,function(k,v){
|
||||
if(v[2] === false) { var avatar = window.defaultAvatarStreamSize; }
|
||||
else { var avatar = v[2]; }
|
||||
|
@ -835,13 +834,11 @@ function doLogin(streamObjectToSet) {
|
|||
v[3] = v[3].substring(v[3].indexOf('://')+3,v[3].lastIndexOf(v[1])-1);
|
||||
}
|
||||
v[0] = v[0] || v[1]; // if name is null we go with username there too
|
||||
window.following[i] = { 'id': k,'name': v[0], 'username': v[1],'avatar': avatar, 'url':v[3] };
|
||||
i++;
|
||||
window.following[k] = { 'id': k,'name': v[0], 'username': v[1],'avatar': avatar, 'url':v[3] };
|
||||
});
|
||||
}
|
||||
|
||||
if(data.groups) {
|
||||
var i=0;
|
||||
$.each(data.groups,function(k,v){
|
||||
if(v[2] === false || v[2] === null) { var avatar = window.defaultAvatarStreamSize; }
|
||||
else { var avatar = v[2]; }
|
||||
|
@ -851,9 +848,8 @@ function doLogin(streamObjectToSet) {
|
|||
v[3] = v[3].substring(0, v[3].indexOf('/'));
|
||||
}
|
||||
v[0] = v[0] || v[1]; // if name is null we go with username there too
|
||||
window.groupMemberships[i] = { 'id': k,'name': v[0], 'username': v[1],'avatar': avatar, 'url':v[3] };
|
||||
window.groupNicknamesAndLocalAliases[i] = v[1];
|
||||
i++;
|
||||
window.groupMemberships[k] = { 'id': k,'name': v[0], 'username': v[1],'avatar': avatar, 'url':v[3] };
|
||||
window.groupNicknamesAndLocalAliases[k] = v[1];
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -217,6 +217,15 @@ function pathToStreamRouter(path) {
|
|||
return streamObject;
|
||||
}
|
||||
|
||||
// group/{id }/id
|
||||
if(pathSplit.length == 3 && pathSplit[0] == 'group' && /^[0-9]+$/.test(pathSplit[1]) && pathSplit[2] == 'id') {
|
||||
streamObject.name = 'group notice stream by id';
|
||||
streamObject.id = pathSplit[1];
|
||||
streamObject.streamHeader = replaceHtmlSpecialChars(path);
|
||||
streamObject.stream = 'statusnet/groups/timeline/' + streamObject.id + '.json';
|
||||
return streamObject;
|
||||
}
|
||||
|
||||
// group/{group_nickname}/members
|
||||
if(pathSplit.length == 3 && pathSplit[0] == 'group' && /^[a-zA-Z0-9]+$/.test(pathSplit[1]) && pathSplit[2] == 'members') {
|
||||
streamObject.name = 'group member list';
|
||||
|
|
Loading…
Reference in New Issue
Block a user