show full notice text for all cached notices, if we have it in cache

This commit is contained in:
Hannes Mannerheim 2015-11-25 20:36:28 +01:00
parent cc71314cdb
commit 8e210301cd
2 changed files with 13 additions and 5 deletions

View File

@ -711,6 +711,11 @@ function setNewCurrentStream(streamObject,setLocation,fallbackId,actionOnSuccess
});
}
// show full notice text for all cached notices, if we have it in cache
$.each(oldStreamState.children('.stream-item'),function(){
getFullUnshortenedHtmlForQueet($(this),true);
});
// if this is notidfications we have seen obviously seen them before
oldStreamState.children('.stream-item').removeClass('not-seen');

View File

@ -833,12 +833,15 @@ function rememberStreamStateInLocalStorage() {
·
· · · · · · · · · */
function getFullUnshortenedHtmlForQueet(streamItem) {
var queet = streamItem.children('.queet');
function getFullUnshortenedHtmlForQueet(streamItem, cacheOnly) {
if(typeof cacheOnly == 'undefined') {
var cacheOnly = false;
}
var queet = streamItem.children('.queet');
var queetId = streamItem.attr('data-quitter-id');
var attachmentMore = queet.find('span.attachment.more');
// only if actually shortened
if(attachmentMore.length>0 && streamItem.data('attachments') != 'undefined') {
if(attachmentMore.length>0 && streamItem.attr('data-attachments') != 'undefined') {
// first try localstorage cache
var cacheData = localStorageObjectCache_GET('fullQueetHtml',queetId);
if(cacheData) {
@ -846,9 +849,9 @@ function getFullUnshortenedHtmlForQueet(streamItem) {
queet.outerHTML(detectRTL(queet.outerHTML()));
}
// then try static html file attachment, that we should have in an array in a data-attachments attribute
else {
else if(cacheOnly === false){
var attachmentId = attachmentMore.attr('data-attachment-id');
$.each(streamItem.data('attachments'), function(k,attachment) {
$.each(JSON.parse(streamItem.attr('data-attachments')), function(k,attachment) {
if(attachment.id == attachmentId) {
$.get(attachment.url,function(data){
if(data) {