Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

condense: Replace $.fn.height with using the DOM API.

evykassirer87649ddbab66
diff --git a/web/src/condense.js b/web/src/condense.js
index d8315baebe0..2f76cdd38eb 100644
--- a/web/src/condense.js
+++ b/web/src/condense.js
@@ -178,7 +178,7 @@ export function show_message_condenser($row) {
}
export function condense_and_collapse(elems) {
- const height_cutoff = message_viewport.height() * 0.65;
+ const height_cutoff = message_viewport.max_message_height();
const rows_to_resize = [];
for (const elem of elems) {
diff --git a/web/src/message_viewport.js b/web/src/message_viewport.js
index 86e6a898534..10756230cca 100644
--- a/web/src/message_viewport.js
+++ b/web/src/message_viewport.js
@@ -31,6 +31,13 @@ function make_dimen_wrapper(dimen_name, dimen_func) {
export const height = make_dimen_wrapper("height", $.fn.height);
export const width = make_dimen_wrapper("width", $.fn.width);
+// TODO: This function let's us use the DOM API instead of jquery
+// (<10x faster) for condense.js, but we want to eventually do a
+// bigger of refactor `height` and `width` above to do the same.
+export function max_message_height() {
+ return document.querySelector("html").offsetHeight * 0.65;
+}
+
// Includes both scroll and arrow events. Negative means scroll up,
// positive means scroll down.
export let last_movement_direction = 1;