Files
zulip/static/js/hash_util.js
Abhijeet Kaur 2bf3324395 frontend: Add ability to search by "group-pm-with" search operator.
This allows user to view all group private conversation messages
with a specific user. That is, it views all the the group private
messages from groups which include the given user.

Add search suggestion for group-pm-with. Add operator name
and description in "Search operators" tab.

Add change in tab name to "Group Messages" when using this operator.
Add frontend_tests for group-pm-with search operator.

Fixes: #3882.
2017-09-24 11:58:48 -04:00

46 lines
1.2 KiB
JavaScript

var hash_util = (function () {
var exports = {};
// Some browsers zealously URI-decode the contents of
// window.location.hash. So we hide our URI-encoding
// by replacing % with . (like MediaWiki).
exports.encodeHashComponent = function (str) {
return encodeURIComponent(str)
.replace(/\./g, '%2E')
.replace(/%/g, '.');
};
exports.encode_operand = function (operator, operand) {
if ((operator === 'group-pm-with') || (operator === 'pm-with') || (operator === 'sender')) {
var slug = people.emails_to_slug(operand);
if (slug) {
return slug;
}
}
return exports.encodeHashComponent(operand);
};
exports.decodeHashComponent = function (str) {
return decodeURIComponent(str.replace(/\./g, '%'));
};
exports.decode_operand = function (operator, operand) {
if ((operator === 'group-pm-with') || (operator === 'pm-with') || (operator === 'sender')) {
var emails = people.slug_to_emails(operand);
if (emails) {
return emails;
}
}
return exports.decodeHashComponent(operand);
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = hash_util;
}