Browse code

FIX: nepamatanie si konverzacie

Cinan Rakosnik authored on 19/05/2013 at 15:25:12
Showing 2 changed files
... ...
@@ -1,4 +1,6 @@
1 1
 .conversation.clear.border
2 2
   .messages#height-setter-2
3
+    -for view in @history
4
+      #{view}
3 5
   -if @showWriter
4 6
     != JST['backbone/templates/chat/message_writer']()
5 7
\ No newline at end of file
... ...
@@ -16,7 +16,10 @@ class Xmpp.Views.Chat.WindowView extends Backbone.View
16 16
     @historyStack = []
17 17
 
18 18
   render: ->
19
-    $(@el).html(@template(showWriter: true))
19
+    historyStackHtml = _.map(@historyStack, (view) ->
20
+      view.render().el.outerHTML
21
+    )
22
+    $(@el).html(@template(showWriter: true, history: historyStackHtml))
20 23
     @show()
21 24
     return this
22 25
 
... ...
@@ -70,4 +73,11 @@ class Xmpp.Views.Chat.WindowView extends Backbone.View
70 70
   appendMessage: (user, date, msg) ->
71 71
     messageView = new Xmpp.Views.Chat.MessageView(user: user, date: date, message: msg)
72 72
     $(@el).find('.messages').append(messageView.render().el)
73
-    App.UI.resizeMessages()
74 73
\ No newline at end of file
74
+    App.UI.resizeMessages()
75
+    @log(messageView)
76
+
77
+  log: (view) ->
78
+    if (@historyStack.length + 1 >= @maxHistoryLength)
79
+      @historyStack = @historyStack.slice(@historyStack.length - @maxHistoryLength + 1)
80
+
81
+    @historyStack.push(view)
75 82
\ No newline at end of file