diff --git a/www/common/common-messaging.js b/www/common/common-messaging.js index ffb0fe75e..8a846482a 100644 --- a/www/common/common-messaging.js +++ b/www/common/common-messaging.js @@ -60,6 +60,7 @@ define([ common.whenRealtimeSyncs(common.getRealtime(), cb); }; + // TODO set this up as an observable data structure var getFriendList = Msg.getFriendList = function (common) { var proxy = common.getProxy(); if (!proxy.friends) { proxy.friends = {}; } @@ -83,6 +84,132 @@ define([ var channels = Msg.channels = window.channels = {}; var UI = Msg.UI = {}; + + // TODO extract into UI method + var createChatBox = function (common, $container, curvePublic, ui) { + var data = getFriend(common, curvePublic); + + // Input + var channel = channels[data.channel]; + + var $header = $('
', { + 'class': 'header', + }).appendTo($container); + + var $avatar = $('
', {'class': 'avatar'}).appendTo($header); + + // more history... + $('', { + 'class': 'more-history', + }) + .text('get more history') + .click(function () { + console.log("GETTING HISTORY"); + channel.getPreviousMessages(); + }) + .appendTo($header); + + var $removeHistory = $('', { + 'class': 'remove-history fa fa-eraser', + title: common.Messages.contacts_removeHistoryTitle + }) + .click(function () { + common.confirm(common.Messages.contacts_confirmRemoveHistory, function (yes) { + if (!yes) { return; } + common.clearOwnedChannel(data.channel, function (e) { + if (e) { + console.error(e); + common.alert(common.Messages.contacts_removeHistoryServerError); + return; + } + }); + }); + }); + $removeHistory.appendTo($header); + + $('
', {'class': 'messages'}).appendTo($container); + var $inputBlock = $('
', {'class': 'input'}).appendTo($container); + + var $input = $('