mirror of https://github.com/zulip/zulip.git
Move checking all/everyone message to util.js module.
Create is_all_or_everyone_mentioned function in util.js.
This commit is contained in:
parent
d8f108a5cf
commit
5c82e53b9a
|
@ -8,7 +8,6 @@ var is_composing_message = false;
|
||||||
// get an error message too.
|
// get an error message too.
|
||||||
// undefined: no @all/@everyone in message; false: user typed @all/@everyone; true: user clicked YES
|
// undefined: no @all/@everyone in message; false: user typed @all/@everyone; true: user clicked YES
|
||||||
var user_acknowledged_all_everyone;
|
var user_acknowledged_all_everyone;
|
||||||
var all_everyone_re = /(@\*{2}(all|everyone)\*{2})|(@(all|everyone))/;
|
|
||||||
|
|
||||||
var message_snapshot;
|
var message_snapshot;
|
||||||
var empty_subject_placeholder = "(no topic)";
|
var empty_subject_placeholder = "(no topic)";
|
||||||
|
@ -377,7 +376,7 @@ exports.restore_message = function () {
|
||||||
compose.start(snapshot_copy.type, snapshot_copy);
|
compose.start(snapshot_copy.type, snapshot_copy);
|
||||||
|
|
||||||
if (snapshot_copy.content !== undefined &&
|
if (snapshot_copy.content !== undefined &&
|
||||||
all_everyone_re.test(snapshot_copy.content)) {
|
util.is_all_or_everyone_mentioned(snapshot_copy.content)) {
|
||||||
show_all_everyone_warnings();
|
show_all_everyone_warnings();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -775,7 +774,7 @@ function validate_stream_message() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if @all or @everyone is in the message
|
// check if @all or @everyone is in the message
|
||||||
if (all_everyone_re.test(exports.message_content())) {
|
if (util.is_all_or_everyone_mentioned(exports.message_content())) {
|
||||||
if (user_acknowledged_all_everyone === undefined ||
|
if (user_acknowledged_all_everyone === undefined ||
|
||||||
user_acknowledged_all_everyone === false) {
|
user_acknowledged_all_everyone === false) {
|
||||||
// user has not seen a warning message yet if undefined
|
// user has not seen a warning message yet if undefined
|
||||||
|
|
|
@ -232,6 +232,11 @@ exports.execute_early = function (func) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.is_all_or_everyone_mentioned = function (message_content) {
|
||||||
|
var all_everyone_re = /(@\*{2}(all|everyone)\*{2})|(@(all|everyone))/;
|
||||||
|
return all_everyone_re.test(message_content);
|
||||||
|
};
|
||||||
|
|
||||||
return exports;
|
return exports;
|
||||||
}());
|
}());
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
|
|
Loading…
Reference in New Issue