Ind.ie is now Small Technology Foundation.
Commit 0646b41f authored by Aral Balkan's avatar Aral Balkan

Now handling initial empty timeline state and transition to first message in...

Now handling initial empty timeline state and transition to first message in timeline correctly on All Friends timeline.
parent e18243fe
......@@ -16,13 +16,13 @@
<h1>All Friends</h1>
<!-- Notice to display if there are no messages yet. -->
<div data-set-if='not messages' id='notice'>
<div data-set-if='not:messages' id='notice'>
<p>This is where you will see messages from all of your friends. Messages you send will also be seen by all of your friends.</p><p>To avoid confusion, when replying to friends here, start your messages them with <em>@<their handle></em>. Although this does nothing special at the moment, it might give them a notification in the future.</p><p>Also, remember that your friends won’t see each other’s messages unless they are also friends with each other. In the future, @handle could help with discovery if we link handles to people’s public pages (thereby making it possible for your friends to discover each other through your conversations on this timeline).</p>
</div>
<div id='messages' class='messages' data-set-if='messages'>
<!-- Repeater -->
<div class='message' data-set-repeat='message messages' data-set-attribute='id message.key' >
<div id='messageRepeater' class='message' data-set-repeat='message messages' data-set-attribute='id message.key' >
<div class='messageBody' data-set-attribute='id message.key messageBodyIDFormatter'>
<div class="image-and-body">
<img class="profileImage" data-set-attribute='src message.key profileImagePathFormatter'>
......
......@@ -7,12 +7,26 @@ window.addEventListener('load', function(){
return;
}
// Check if there are no messages to begin with, remove the pre-rendered repeater.
// (It’s ID will be different if there are.)
var messageRepeater = document.getElementById('messageRepeater');
if (messageRepeater != null)
{
messageRepeater.parentNode.removeChild(messageRepeater);
}
setInterval(function(){
// console.log("Polling server for new public posts…")
var messages = document.getElementById('messages');
var newestPostID = messages.firstElementChild.getAttribute('id')
var firstMessage = messages.firstElementChild;
var newestPostID = 0;
if (firstMessage != null)
{
newestPostID = messages.firstElementChild.getAttribute('id');
}
// console.log('Getting post after ' + newestPostID)
......@@ -34,6 +48,12 @@ window.addEventListener('load', function(){
return;
}
// Make sure that the notice is hidden and that the main section is showing.
// (Set can’t handle this automatically as we are not running it on the
// entire document but only on the delta repeat block below for performance reasons.)
document.getElementById('notice').style.display = 'none';
document.getElementById('messages').style.display = 'block';
var repeaterNodeHTML =
" <div style='background-color: rgb(200, 50, 50, 0.5);' class='message' data-set-repeat='message messages' data-set-attribute='id message.key' >"
+ " <div class='messageBody' data-set-attribute='id message.key messageBodyIDFormatter'>"
......@@ -46,16 +66,16 @@ window.addEventListener('load', function(){
+ " </div>";
var messages = document.getElementById('messages');
var div = document.createElement('div')
div.setAttribute('id', posts[0]['key']+'-0')
var div = document.createElement('div');
div.setAttribute('id', posts[0]['key']+'-0');
div.innerHTML = repeaterNodeHTML
div.innerHTML = repeaterNodeHTML;
messages.insertBefore(div, messages.firstElementChild)
messages.insertBefore(div, messages.firstElementChild);
// messages.innerHTML = repeaterNodeHTML + messages.innerHTML;
repeaterNode = messages.firstElementChild
repeaterNode = messages.firstElementChild;
// Bug: Formatters are not being passed from the server correctly
// when injectData is true. As a workaround: I’m duplicating them on the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment