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

Fixed regression with received messages not appearing in the All Friends and...

Fixed regression with received messages not appearing in the All Friends and Private Conversation timelines. Namespaced the timeline routes on the private web server. Remove extraneous parentheses on promise catch methods.
parent 36f83f7e
......@@ -376,7 +376,7 @@ class Commands
return responseObject
.catch ((error)=>
.catch (error)=>
log.error "Error getting POST response:"
console.log error
......@@ -397,7 +397,6 @@ class Commands
# @ws.send(messageObjectAsJSONString, {binary: true})
return responseObject
)
shutdown: =>
......@@ -660,7 +659,7 @@ class Commands
return @returnJSONResponse(id, responseJSON)
.catch ((error)=>
.catch (error) =>
log.error "Error getting POST response:"
console.log error
......@@ -679,7 +678,6 @@ class Commands
@ws.send(messageObjectAsJSONString, {binary: true})
return false
)
#
......@@ -698,7 +696,7 @@ class Commands
console.log responseJSON
return @returnJSONResponse(id, responseJSON)
.catch ((error)=>
.catch (error) =>
log.error "Error getting response:"
console.log error
......@@ -716,7 +714,6 @@ class Commands
@ws.send(messageObjectAsJSONString, {binary: true})
return false
)
#
# Takes a JSON response object and returns it via the web socket. Chainable.
......
......@@ -82,6 +82,7 @@ class Migrations
# Not really an error; person just has earlier version
# of Heartbeat than the first one where we implemented migrations.
console.log "No data schema version in database yet. (Version 0)."
.finally =>
if "#{@dataSchemaVersionInDatabase}" == "#{@dataSchemaVersion}"
console.log "Heartbeat data schema version is up to date (#{@dataSchemaVersionInDatabase}). Not running migrations."
......@@ -130,10 +131,12 @@ class Migrations
# Bail — we cannot migrate the data schema to the latest version. We can’t recover from this.
# Person either has to use the older version or file a bug report.
throw new Error "Migrations failed. Cannot continue."
.catch (error) =>
# Backing up the sync folders failed. Bail.
# Not going to risk messing up the person’s current configuration / data.
throw new Error "Sync folder migration snapshot failed. Cannot continue."
.catch (error) =>
# Backing up the database folders failed. Bail.
# Not going to risk messing up the person’s current configuration / data.
......
......@@ -24,7 +24,7 @@
request = require 'superagent-as-promised'
StreamWeaver = require './StreamWeaver'
path = require 'path-extra'
fs = require 'fs-extra'
fs = require 'fs-extra-as-promised'
MainModel = require './MainModel'
class PulseEventPipe
......@@ -156,6 +156,9 @@ class PulseEventPipe
messageFileName = event.data.name
messageRepository = event.data.repo
console.log "Message file name: #{messageFileName}"
console.log "Message repository: #{messageRepository}"
# Data from message file name
fileNameOfChangedFile = messageFileName.substr messageFileName.lastIndexOf('/')+1
......@@ -225,11 +228,12 @@ class PulseEventPipe
console.log "About to weave into the #{user} timeline."
@readMessageAndWeaveIntoTimeline pathToMessageIndexFile, messageID, user, user
.catch (error) =>
console.log "Error reading message and weaving into timeline: #{error}"
# Massage the event type to signal to Cocoa that the timeline needs to be updated.
event.type = "ConversationTimelineUpdated"
eventsToSendToCocoa.push event
continue
......@@ -274,7 +278,6 @@ class PulseEventPipe
console.log 'Info: Pulse event: Config saved.'
continue
numRelevantEvents = eventsToSendToCocoa.length
# Debug
......@@ -297,8 +300,9 @@ class PulseEventPipe
# else
# console.log "No relevant Pulse events to send to Cocoa client at this time."
.catch ((error) =>
.catch (error) =>
console.log '⚠️ Could not reach Pulse events API. Retrying…'
console.log error
currentTime = new Date()
......@@ -306,16 +310,13 @@ class PulseEventPipe
console.log "Pulse has been down for #{timeThatPulseHasBeenDownInSeconds} seconds."
# if timeThatPulseHasBeenDownInSeconds > 10
# @delegate.pulseFlatlinedAndNeedsToBeShockedBackToLife
# console.log error
@poll()
)
readMessageAndWeaveIntoTimeline: (pathToMessageIndexFile, messageID, user, timeline) =>
console.log "About to readMessageAndWeaveIntoTimeline. path: #{pathToMessageIndexFile}, messageID: #{messageID}, user: #{user}, timeline: #{timeline}"
fs.readFileAsync(pathToMessageIndexFile, {encoding: 'utf8'})
.then (data) =>
console.log "Read the #{timeline} message file:"
......@@ -330,5 +331,7 @@ class PulseEventPipe
# Weave into the LevelDB database.
@streamWeaver.weaveMessage messageID, data, timeline
.catch (error) =>
console.log "Error reading message index file at #{pathToMessageIndexFile} (messageID: #{messageID}, user: #{user}, timeline: #{timeline}."
module.exports = PulseEventPipe
......@@ -15,7 +15,7 @@ module.exports = (app) ->
console.log "Looking up posts since key #{key} on timeline #{timeline}."
streamWeaver.getPostsAfter(key, timeline).then (messages) ->
streamWeaver.getPostsAfter(timeline, key).then (messages) ->
# console.log 'Found new posts: '
# console.log messages
......
......@@ -33,7 +33,7 @@ window.addEventListener('load', function(){
// TODO: Do not hard code this URL.
// TODO: Fix Set injectData so we don’t have to use this metadata injection workaround.
superagent
.get('http://127.0.0.1:42003/timeline/posts-after/'+newestPostID+'/allfriends')
.get('http://127.0.0.1:42003/timeline/posts-after/allfriends/'+newestPostID)
.end(function(error, posts) {
//
// Optimisation: clone the repeater seed node and only apply the set
......
// Thanks to Karim (http://stackoverflow.com/a/4793630)
function insertAfter(referenceNode, newNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}
window.addEventListener('load', function(){
// Set: don’t run in Node.
......@@ -12,7 +17,9 @@ window.addEventListener('load', function(){
// console.log("Polling server for new public posts…")
var messages = document.getElementById('messages');
var newestPostID = messages.firstElementChild.getAttribute('id')
// The latest message is at the bottom for conversation-style timelines.
var newestPostID = messages.lastElementChild.getAttribute('id')
// console.log('Getting post after ' + newestPostID)
......@@ -23,7 +30,7 @@ window.addEventListener('load', function(){
// TODO: Do not hard code this URL.
// TODO: Fix Set injectData so we don’t have to use this metadata injection workaround.
superagent
.get('http://127.0.0.1:42003/timeline/posts-after/'+newestPostID+'/'+person)
.get('http://127.0.0.1:42003/timeline/posts-after/'+person+'/'+newestPostID)
.end(function(error, posts) {
//
// Optimisation: clone the repeater seed node and only apply the set
......@@ -54,11 +61,12 @@ window.addEventListener('load', function(){
div.innerHTML = repeaterNodeHTML
messages.insertBefore(div, messages.firstElementChild)
// Insert new items at the end.
insertAfter(messages.firstElementChild, div)
// messages.innerHTML = repeaterNodeHTML + messages.innerHTML;
repeaterNode = messages.firstElementChild
repeaterNode = messages.lastElementChild
// Bug: Formatters are not being passed from the server correctly
// when injectData is true. As a workaround: I’m duplicating them on the
......@@ -80,5 +88,5 @@ window.addEventListener('load', function(){
// Update the repeater node
set(repeaterNode, {messages: posts})
});
}, 5000);
}, 2000);
});
......@@ -19,7 +19,7 @@ window.addEventListener('load', function(){
// TODO: Do not hard code this URL.
// TODO: Fix Set injectData so we don’t have to use this metadata injection workaround.
superagent
.get('http://127.0.0.1:42003/timeline/posts-after/'+newestPostID+'/private')
.get('http://127.0.0.1:42003/timeline/posts-after/private/'+newestPostID)
.end(function(error, posts) {
//
// Optimisation: clone the repeater seed node and only apply the set
......
......@@ -19,7 +19,7 @@ window.addEventListener('load', function(){
// TODO: Do not hard code this URL.
// TODO: Fix Set injectData so we don’t have to use this metadata injection workaround.
superagent
.get('http://127.0.0.1:42003/timeline/posts-after/'+newestPostID+'/public')
.get('http://127.0.0.1:42003/timeline/posts-after/public/'+newestPostID)
.end(function(error, posts) {
//
// Optimisation: clone the repeater seed node and only apply the set
......
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