mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
js: Purge useless IIFEs.
With webpack, variables declared in each file are already file-local (Global variables need to be explicitly exported), so these IIFEs are no longer needed. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
committed by
Tim Abbott
parent
5f590d3500
commit
d17b577d0c
@@ -1,10 +1,6 @@
|
||||
// See https://zulip.readthedocs.io/en/latest/subsystems/pointer.html for notes on
|
||||
// how this system is designed.
|
||||
|
||||
var pointer = (function () {
|
||||
|
||||
var exports = {};
|
||||
|
||||
exports.recenter_pointer_on_display = false;
|
||||
exports.set_recenter_pointer_on_display = function (value) {
|
||||
exports.recenter_pointer_on_display = value;
|
||||
@@ -33,9 +29,9 @@ function update_pointer() {
|
||||
return channel.post({
|
||||
url: '/json/users/me/pointer',
|
||||
idempotent: true,
|
||||
data: {pointer: pointer.furthest_read},
|
||||
data: {exports: exports.furthest_read},
|
||||
success: function () {
|
||||
pointer.server_furthest_read = pointer.furthest_read;
|
||||
exports.server_furthest_read = exports.furthest_read;
|
||||
pointer_update_in_flight = false;
|
||||
},
|
||||
error: function () {
|
||||
@@ -50,7 +46,7 @@ function update_pointer() {
|
||||
|
||||
exports.send_pointer_update = function () {
|
||||
// Only bother if you've read new messages.
|
||||
if (pointer.furthest_read > pointer.server_furthest_read) {
|
||||
if (exports.furthest_read > exports.server_furthest_read) {
|
||||
update_pointer();
|
||||
}
|
||||
};
|
||||
@@ -74,7 +70,7 @@ exports.fast_forward_pointer = function () {
|
||||
idempotent: true,
|
||||
success: function (data) {
|
||||
unread_ops.mark_all_as_read(function () {
|
||||
pointer.furthest_read = data.max_message_id;
|
||||
exports.furthest_read = data.max_message_id;
|
||||
unconditionally_send_pointer_update().then(function () {
|
||||
reload.initiate({immediate: true,
|
||||
save_pointer: false,
|
||||
@@ -87,17 +83,17 @@ exports.fast_forward_pointer = function () {
|
||||
};
|
||||
|
||||
exports.initialize = function initialize() {
|
||||
pointer.server_furthest_read = page_params.pointer;
|
||||
exports.server_furthest_read = page_params.pointer;
|
||||
if (page_params.orig_initial_pointer !== undefined &&
|
||||
page_params.orig_initial_pointer > pointer.server_furthest_read) {
|
||||
pointer.server_furthest_read = page_params.orig_initial_pointer;
|
||||
page_params.orig_initial_pointer > exports.server_furthest_read) {
|
||||
exports.server_furthest_read = page_params.orig_initial_pointer;
|
||||
}
|
||||
pointer.furthest_read = pointer.server_furthest_read;
|
||||
exports.furthest_read = exports.server_furthest_read;
|
||||
|
||||
// We only send pointer updates when the user has been idle for a
|
||||
// short while to avoid hammering the server
|
||||
$(document).idle({idle: 1000,
|
||||
onIdle: pointer.send_pointer_update,
|
||||
onIdle: exports.send_pointer_update,
|
||||
keepTracking: true});
|
||||
|
||||
$(document).on('message_selected.zulip', function (event) {
|
||||
@@ -108,10 +104,10 @@ exports.initialize = function initialize() {
|
||||
// Additionally, don't advance the pointer server-side
|
||||
// if the selected message is local-only
|
||||
if (event.msg_list === home_msg_list && page_params.narrow_stream === undefined) {
|
||||
if (event.id > pointer.furthest_read) {
|
||||
if (event.id > exports.furthest_read) {
|
||||
var msg = home_msg_list.get(event.id);
|
||||
if (!msg.locally_echoed) {
|
||||
pointer.furthest_read = event.id;
|
||||
exports.furthest_read = event.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,9 +127,4 @@ exports.initialize = function initialize() {
|
||||
});
|
||||
};
|
||||
|
||||
return exports;
|
||||
}());
|
||||
if (typeof module !== 'undefined') {
|
||||
module.exports = pointer;
|
||||
}
|
||||
window.pointer = pointer;
|
||||
window.pointer = exports;
|
||||
|
||||
Reference in New Issue
Block a user