From 0bd3af2bc86fef7907becaca8933f23c67e0369c Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Mon, 13 Feb 2017 12:42:57 -0800 Subject: [PATCH] Create narrow.update_email(). --- frontend_tests/node_tests/narrow.js | 21 +++++++++++++++++++++ static/js/narrow.js | 7 +++++++ 2 files changed, 28 insertions(+) diff --git a/frontend_tests/node_tests/narrow.js b/frontend_tests/node_tests/narrow.js index edd34f7569..86e802d86f 100644 --- a/frontend_tests/node_tests/narrow.js +++ b/frontend_tests/node_tests/narrow.js @@ -200,3 +200,24 @@ function set_filter(operators) { assert.equal(hide_id,'.empty_feed_notice'); assert.equal(show_id, '#empty_search_narrow_message'); }()); + +(function test_update_email() { + var steve = { + email: 'steve@foo.com', + user_id: 43, + full_name: 'Steve', + }; + + people.add(steve); + set_filter([ + ['pm-with', 'steve@foo.com'], + ['sender', 'steve@foo.com'], + ['stream', 'steve@foo.com'], // try to be tricky + ]); + narrow.update_email(steve.user_id, 'showell@foo.com'); + var filter = narrow.filter(); + assert.deepEqual(filter.operands('pm-with'), ['showell@foo.com']); + assert.deepEqual(filter.operands('sender'), ['showell@foo.com']); + assert.deepEqual(filter.operands('stream'), ['steve@foo.com']); +}()); + diff --git a/static/js/narrow.js b/static/js/narrow.js index ad058e16e2..b9e7239a62 100644 --- a/static/js/narrow.js +++ b/static/js/narrow.js @@ -32,6 +32,13 @@ exports.operators = function () { return current_filter.operators(); }; +exports.update_email = function (user_id, new_email) { + if (current_filter !== undefined) { + current_filter.update_email(user_id, new_email); + } +}; + + /* Operators we should send to the server. */ exports.public_operators = function () { if (current_filter === undefined) {