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.

message_edit_history: Replace loading spinners with deleted file placeholder.

17AnuragMishra72fa1ce8c079
diff --git a/api_docs/message-formatting.md b/api_docs/message-formatting.md
index 7d33b3e0153..a4704a3d6cf 100644
--- a/api_docs/message-formatting.md
+++ b/api_docs/message-formatting.md
@@ -222,6 +222,10 @@ backlogged, an individual message containing multiple image previews
may be re-rendered multiple times as each image finishes thumbnailing
and triggers a message update.
+Clients displaying message-edit history should rewrite image-loading
+placeholder images in edit history to the generic deleted-file image
+(`/static/images/errors/file-not-exist.png`).
+
### Transcoded images
Image elements whose formats are not widely supported by web browsers
diff --git a/web/src/message_edit_history.ts b/web/src/message_edit_history.ts
index d335dbcf53b..d13d1f21e3e 100644
--- a/web/src/message_edit_history.ts
+++ b/web/src/message_edit_history.ts
@@ -297,6 +297,23 @@ export function fetch_and_render_message_history(message: Message): void {
.each(function () {
rendered_markdown.update_elements($(this));
});
+
+ // When an image is deleted before thumbnailing is completed, we can
+ // end up with the loading spinner HTML syntax stuck in message edit
+ // history indefinitely. Mask this by replacing thumbnailing loading
+ // spinners in edit history with the deleted image placeholder.
+ $("#message-history-overlay")
+ .find("img.image-loading-placeholder")
+ .each(function () {
+ const $img = $(this);
+ $img.attr("src", "/static/images/errors/image-not-exist.png");
+ $img.attr(
+ "alt",
+ $t({defaultMessage: "This file does not exist or has been deleted."}),
+ );
+ $img.removeClass("image-loading-placeholder");
+ });
+
const first_element_id = content_edit_history[0]!.timestamp;
messages_overlay_ui.set_initial_element(
String(first_element_id),