diff --git a/customize.dist/src/less2/include/buttons.less b/customize.dist/src/less2/include/buttons.less index 8d906de62..bcbff499e 100644 --- a/customize.dist/src/less2/include/buttons.less +++ b/customize.dist/src/less2/include/buttons.less @@ -52,6 +52,22 @@ } } + div.cp-button-confirm { + display: inline-block; + button { + margin: 0; + } + .cp-button-timer { + height: 3px; + & > div { + height: 100%; + background-color: @colortheme_alertify-primary; + &.danger, &.btn-danger, &.danger-alt, &.btn-danger-alt { + background-color: @colortheme_alertify-red; + } + } + } + } button:not(.pure-button):not(.md-button):not(.mdl-button) { @@ -89,6 +105,7 @@ white-space: normal; font-weight: bold; } + &.danger, &.btn-danger { background-color: @colortheme_alertify-red; border-color: @colortheme_alertify-red-border; @@ -98,6 +115,15 @@ } } + &.danger-alt, &.btn-danger-alt { + border-color: @colortheme_alertify-red; + color: @colortheme_alertify-red; + &:hover, &:active { + color: @colortheme_alertify-red-color; + background-color: contrast(@colortheme_modal-bg, darken(@colortheme_alertify-red, 10%), lighten(@colortheme_alertify-red, 10%)); + } + } + &.safe, &.btn-safe { background-color: @colortheme_alertify-green; border-color: @colortheme_alertify-green-border; diff --git a/customize.dist/src/less2/include/modals-ui-elements.less b/customize.dist/src/less2/include/modals-ui-elements.less index 3e6855fbe..e13263d36 100644 --- a/customize.dist/src/less2/include/modals-ui-elements.less +++ b/customize.dist/src/less2/include/modals-ui-elements.less @@ -26,6 +26,42 @@ // Properties modal .cp-app-prop { margin-bottom: 10px; + .cp-app-prop-size-container { + height: 20px; + background-color: @colortheme_logo-2; + margin: 10px 0; + padding: 0; + div { + height: 20px; + margin: 0; + padding: 0; + background-color: #CCCCCC; + } + } + .cp-app-prop-size-legend { + color: @colortheme_modal-fg; + display: flex; + margin: 10px 0; + & > div { + display: flex; + align-items: center; + flex-basis: 50%; + margin: 0; + padding: 0; + } + .cp-app-prop-history-size-color, .cp-app-prop-contents-size-color { + display: inline-block; + height: 20px; + width: 20px; + margin-right: 10px; + } + .cp-app-prop-history-size-color { + background-color: #CCCCCC; + } + .cp-app-prop-contents-size-color { + background-color: @colortheme_logo-2; + } + } } .cp-app-prop-content { diff --git a/lib/hk-util.js b/lib/hk-util.js index 69832a544..0a661c6c8 100644 --- a/lib/hk-util.js +++ b/lib/hk-util.js @@ -599,6 +599,7 @@ const handleGetHistory = function (Env, Server, seq, userId, parsed) { var config = parsed[2]; var metadata = {}; var lastKnownHash; + var txid; // clients can optionally pass a map of attributes // if the channel already exists this map will be ignored @@ -606,6 +607,7 @@ const handleGetHistory = function (Env, Server, seq, userId, parsed) { if (config && typeof config === "object" && !Array.isArray(parsed[2])) { lastKnownHash = config.lastKnownHash; metadata = config.metadata || {}; + txid = config.txid; if (metadata.expire) { metadata.expire = +metadata.expire * 1000 + (+new Date()); } @@ -655,11 +657,12 @@ const handleGetHistory = function (Env, Server, seq, userId, parsed) { msgCount++; // avoid sending the metadata message a second time if (isMetadataMessage(msg) && metadata_cache[channelName]) { return readMore(); } + if (txid) { msg[0] = txid; } Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(msg)], readMore); }, (err) => { if (err && err.code !== 'ENOENT') { if (err.message !== 'EINVAL') { Log.error("HK_GET_HISTORY", err); } - const parsedMsg = {error:err.message, channel: channelName}; + const parsedMsg = {error:err.message, channel: channelName, txid: txid}; Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(parsedMsg)]); return; } @@ -707,7 +710,7 @@ const handleGetHistory = function (Env, Server, seq, userId, parsed) { } // End of history message: - let parsedMsg = {state: 1, channel: channelName}; + let parsedMsg = {state: 1, channel: channelName, txid: txid}; Server.send(userId, [0, HISTORY_KEEPER_ID, 'MSG', userId, JSON.stringify(parsedMsg)]); }); diff --git a/storage/file.js b/storage/file.js index cb29d7fab..6162f4a8b 100644 --- a/storage/file.js +++ b/storage/file.js @@ -975,10 +975,11 @@ var trimChannel = function (env, channelName, hash, _cb) { if (msgHash === hash) { // everything from this point on should be retained retain = true; - return void tempStream.write(msgObj.buff, function () { + return void tempStream.write(s_msg + '\n', function () { readMore(); }); } + readMore(); }; readMessagesBin(env, channelName, 0, handler, w(function (err) { diff --git a/www/common/common-interface.js b/www/common/common-interface.js index 14b06527f..fca655360 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -599,6 +599,59 @@ define([ } }); }; + UI.confirmButton = function (originalBtn, config, _cb) { + config = config || {}; + var cb = Util.once(Util.mkAsync(_cb)); + + var classes = 'btn ' + (config.classes || 'btn-primary'); + + var button = h('button', { + "class": classes, + title: config.title || '' + }, Messages.areYouSure || "Are you sure?"); // XXX + var $button = $(button); + + var div = h('div', { + "class": config.classes || '' + }); + var timer = h('div.cp-button-timer', div); + + var content = h('div.cp-button-confirm', [ + button, + timer + ]); + + var to; + + var done = function (res) { + cb(res); + clearTimeout(to); + $(content).remove(); + $(originalBtn).show(); + }; + + $button.click(function () { + done(true); + }); + + var TIMEOUT = 3000; + var INTERVAL = 10; + var i = 1; + + var todo = function () { + var p = 100 * ((TIMEOUT - (i * INTERVAL)) / TIMEOUT); + if (i++ * INTERVAL >= TIMEOUT) { + done(false); + return; + } + $(div).css('width', p+'%'); + to = setTimeout(todo, INTERVAL); + }; + to = setTimeout(todo, INTERVAL); + + $(originalBtn).hide().after(content); + }; + UI.proposal = function (content, cb) { var buttons = [{ diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 38261a1e1..fca273e4f 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -30,6 +30,13 @@ define([ }); } + UIElements.prettySize = function (bytes) { + var kB = Util.bytesToKilobytes(bytes); + if (kB < 1024) { return kB + Messages.KB; } + var mB = Util.bytesToMegabytes(bytes); + return mB + Messages.MB; + }; + UIElements.updateTags = function (common, href) { var existing, tags; NThen(function(waitFor) { @@ -704,6 +711,9 @@ define([ var $d = $('