forked from GNUsocial/gnu-social
Initial fix for #2479: New post should be displayed on timeline only if it belongs there (AJAX post)
Previously we pushed out your latest post into the currently visible timeline regardless of whether it belonged there or not. This could be pretty confusing! Currently we don't have clearly machine-readable info on the page and returned notice HTML to determine whether it belongs, but we can do a couple checks easily which I've added: * public timeline (always show) * 'and friends' timeline (show for your own page only) * profile timeline (show for your own page only) Other places that should be added in the future: * group timelines if it's a group your posting to * tag timelines if the post contains the tag * reply & friends timelines for people you've mentioned Currently those aren't easy since the mention/group target links in the notice HTML are using the canonical form with user or group ID, while the available navigation links we can use to identify the current page use the names.
This commit is contained in:
parent
a0b35f35b4
commit
54d723adc1
39
js/util.js
39
js/util.js
@ -258,9 +258,10 @@ var SN = { // StatusNet
|
|||||||
form.append('<p class="form_response success">'+result+'</p>');
|
form.append('<p class="form_response success">'+result+'</p>');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// New notice post was successful. If on our timeline, show it!
|
||||||
|
var notice = document._importNode($('li', data)[0], true);
|
||||||
var notices = $('#notices_primary .notices');
|
var notices = $('#notices_primary .notices');
|
||||||
if (notices.length > 0) {
|
if (notices.length > 0 && SN.U.belongsOnTimeline(notice)) {
|
||||||
var notice = document._importNode($('li', data)[0], true);
|
|
||||||
if ($('#'+notice.id).length === 0) {
|
if ($('#'+notice.id).length === 0) {
|
||||||
var notice_irt_value = $('#'+SN.C.S.NoticeInReplyTo).val();
|
var notice_irt_value = $('#'+SN.C.S.NoticeInReplyTo).val();
|
||||||
var notice_irt = '#notices_primary #notice-'+notice_irt_value;
|
var notice_irt = '#notices_primary #notice-'+notice_irt_value;
|
||||||
@ -281,6 +282,8 @@ var SN = { // StatusNet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// Not on a timeline that this belongs on?
|
||||||
|
// Just show a success message.
|
||||||
result = document._importNode($('title', data)[0], true);
|
result = document._importNode($('title', data)[0], true);
|
||||||
result_title = result.textContent || result.innerHTML;
|
result_title = result.textContent || result.innerHTML;
|
||||||
form.append('<p class="form_response success">'+result_title+'</p>');
|
form.append('<p class="form_response success">'+result_title+'</p>');
|
||||||
@ -707,6 +710,38 @@ var SN = { // StatusNet
|
|||||||
Delete: function() {
|
Delete: function() {
|
||||||
$.cookie(SN.C.S.StatusNetInstance, null);
|
$.cookie(SN.C.S.StatusNetInstance, null);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the current page is a timeline where the current user's
|
||||||
|
* posts should be displayed immediately on success.
|
||||||
|
*
|
||||||
|
* @fixme this should be done in a saner way, with machine-readable
|
||||||
|
* info about what page we're looking at.
|
||||||
|
*/
|
||||||
|
belongsOnTimeline: function(notice) {
|
||||||
|
var action = $("body").attr('id');
|
||||||
|
if (action == 'public') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var profileLink = $('#nav_profile a').attr('href');
|
||||||
|
if (profileLink) {
|
||||||
|
var authorUrl = $(notice).find('.entry-title .author a.url').attr('href');
|
||||||
|
if (authorUrl == profileLink) {
|
||||||
|
if (action == 'all' || action == 'showstream') {
|
||||||
|
// Posts always show on your own friends and profile streams.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @fixme tag, group, reply timelines should be feasible as well.
|
||||||
|
// Mismatch between id-based and name-based user/group links currently complicates
|
||||||
|
// the lookup, since all our inline mentions contain the absolute links but the
|
||||||
|
// UI links currently on the page use malleable names.
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user