From 8e210301cd6001d186056706919043d7099d6920 Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Wed, 25 Nov 2015 20:36:28 +0100 Subject: [PATCH] show full notice text for all cached notices, if we have it in cache --- js/dom-functions.js | 5 +++++ js/misc-functions.js | 13 ++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/js/dom-functions.js b/js/dom-functions.js index 9e5d8e5..5599816 100644 --- a/js/dom-functions.js +++ b/js/dom-functions.js @@ -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'); diff --git a/js/misc-functions.js b/js/misc-functions.js index 9060cb8..8b98866 100644 --- a/js/misc-functions.js +++ b/js/misc-functions.js @@ -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) {