mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
lightbox: Fix media title update on change in title.
Previously, when title of media element is updated the change is not reflected in lightbox view. This is because the title of the element is cached from the last time when the media element was opened in lightbox. This is fixed by invalidating a message's asset_map cache whenever the content of message is edited. Fixes #21311
This commit is contained in:
committed by
Tim Abbott
parent
4c69cf13f1
commit
0229f73fae
@@ -212,6 +212,10 @@ export function clear_for_testing(): void {
|
||||
asset_map.clear();
|
||||
}
|
||||
|
||||
export function invalidate_asset_map_of_message(message_id: number): void {
|
||||
asset_map.delete(message_id);
|
||||
}
|
||||
|
||||
function set_selected_media_element($media: JQuery<HTMLMediaElement | HTMLImageElement>): void {
|
||||
// Clear out any previously selected element
|
||||
$(".media-to-select-in-lightbox-list").removeClass("media-to-select-in-lightbox-list");
|
||||
|
@@ -17,6 +17,7 @@ import * as direct_message_group_data from "./direct_message_group_data.ts";
|
||||
import * as drafts from "./drafts.ts";
|
||||
import * as echo from "./echo.ts";
|
||||
import type {Filter} from "./filter.ts";
|
||||
import * as lightbox from "./lightbox.ts";
|
||||
import * as message_edit from "./message_edit.ts";
|
||||
import * as message_edit_history from "./message_edit_history.ts";
|
||||
import * as message_events_util from "./message_events_util.ts";
|
||||
@@ -458,6 +459,10 @@ export function update_messages(events: UpdateMessageEvent[]): void {
|
||||
|
||||
// Update raw_content, so that editing a few times in a row is fast.
|
||||
anchor_message.raw_content = event.content;
|
||||
|
||||
// Editing a message may change the titles for linked
|
||||
// media, so we must invalidate the asset map.
|
||||
lightbox.invalidate_asset_map_of_message(event.message_id);
|
||||
}
|
||||
|
||||
if (unread.update_message_for_mention(anchor_message, any_message_content_edited)) {
|
||||
|
Reference in New Issue
Block a user