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.

lightbox: Address edge case where media may be unavailable.

Karl Stolley708d07a88564
diff --git a/web/src/lightbox.ts b/web/src/lightbox.ts
index 4f57227fb49..05d2e88c8e8 100644
--- a/web/src/lightbox.ts
+++ b/web/src/lightbox.ts
@@ -652,6 +652,17 @@ export function initialize(): void {
);
}
+ // If $original_media_element comes back empty, that means that
+ // something in the message list has changed (e.g., a moved or
+ // deleted message, or the deletion of a media element that was
+ // available when the lightbox opened). In that event, we continue
+ // to display whatever media is up in the lightbox, and remove
+ // the thumbnail from the media list.
+ if ($original_media_element.length === 0) {
+ $(this).remove();
+ return;
+ }
+
open_image($original_media_element);
if (!$(".image-list .image.selected").hasClass("lightbox_video") || !is_video) {