mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
reactions: Simplify markup related to message ids.
Because of local echo, message ids can change in message rows. Having reactions use markup to indicate their message id just creates more moving parts, since we would need to handle message_id_changed events. Now our handlers just call row.get_message_id() as needed.
This commit is contained in:
@@ -475,28 +475,6 @@ set_global('message_store', {
|
||||
|
||||
}());
|
||||
|
||||
(function test_initialize() {
|
||||
var my_event = {
|
||||
old_id: 5,
|
||||
new_id: 99,
|
||||
};
|
||||
|
||||
var new_attr;
|
||||
|
||||
$(".message_reactions[data-message-id='5']").attr = function (sel, value) {
|
||||
assert.equal(sel, 'data-message-id');
|
||||
new_attr = value;
|
||||
};
|
||||
|
||||
$(document).on = function (event_name, f) {
|
||||
assert.equal(event_name, 'message_id_changed');
|
||||
f(my_event);
|
||||
};
|
||||
|
||||
reactions.initialize();
|
||||
assert.equal(new_attr, 99);
|
||||
}());
|
||||
|
||||
(function test_error_handling() {
|
||||
var error_msg;
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ $(function () {
|
||||
$("#main_div").on("click", ".message_reaction", function (e) {
|
||||
e.stopPropagation();
|
||||
var emoji_name = $(this).attr('data-emoji-name');
|
||||
var message_id = $(this).parent().attr('data-message-id');
|
||||
var message_id = rows.get_message_id(this);
|
||||
reactions.toggle_emoji_reaction(message_id, emoji_name);
|
||||
});
|
||||
|
||||
|
||||
@@ -373,9 +373,10 @@ exports.register_click_handlers = function () {
|
||||
});
|
||||
|
||||
$("#main_div").on("click", ".reactions_hover, .reaction_button", function (e) {
|
||||
var row = $(this).closest(".message_row");
|
||||
e.stopPropagation();
|
||||
emoji_picker.toggle_emoji_popover(this, rows.id(row));
|
||||
|
||||
var message_id = rows.get_message_id(this);
|
||||
emoji_picker.toggle_emoji_popover(this, message_id);
|
||||
});
|
||||
|
||||
$("body").on("click", ".actions_popover .reaction_button", function (e) {
|
||||
|
||||
@@ -330,15 +330,6 @@ exports.get_message_reactions = function (message) {
|
||||
return reactions;
|
||||
};
|
||||
|
||||
exports.initialize = function () {
|
||||
$(document).on('message_id_changed', function (event) {
|
||||
// When a message ID is changed via editing, update any
|
||||
// data-message-id references to it.
|
||||
var elts = $(".message_reactions[data-message-id='" + event.old_id + "']");
|
||||
elts.attr("data-message-id", event.new_id);
|
||||
});
|
||||
};
|
||||
|
||||
return exports;
|
||||
}());
|
||||
|
||||
|
||||
@@ -264,7 +264,6 @@ $(function () {
|
||||
activity.initialize();
|
||||
emoji.initialize();
|
||||
hotspots.initialize();
|
||||
reactions.initialize();
|
||||
compose_fade.initialize();
|
||||
pm_list.initialize();
|
||||
stream_list.initialize();
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<div class="edit_content"></div>
|
||||
{{else}}
|
||||
<div class="reactions_hover">
|
||||
<i class="icon-vector-smile reaction_button" data-msgid="{{msg/id}}" title="{{#tr this}}Add emoji reaction{{/tr}}"></i>
|
||||
<i class="icon-vector-smile reaction_button" title="{{#tr this}}Add emoji reaction{{/tr}}"></i>
|
||||
</div>
|
||||
{{/if}}
|
||||
<div class="info actions_hover">
|
||||
@@ -71,7 +71,7 @@
|
||||
</div>
|
||||
<div class="message_expander message_length_controller" title="{{t 'See the rest of this message' }}">{{t "[More...]" }}</div>
|
||||
<div class="message_condenser message_length_controller" title="{{t 'Make this message take up less space on the screen' }}">{{t "[Condense this message]" }}</div>
|
||||
<div class="message_reactions" data-message-id="{{msg/id}}">{{ partial "message_reactions" }}</div>
|
||||
<div class="message_reactions">{{ partial "message_reactions" }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user