Problem/Motivation

When automatic refresh of alerts is turned on, all DOM elements are replaced on every call.

I think this is undesirable, because it can cause animations and other initialization behavior to repeat. It's necessary if an alert was edited since the last refresh, but otherwise it should not be.

Steps to reproduce

Apply the patch for Issue #3337688, turn on automatic site updates with a fairly frequent interval like 15 seconds, and then create at least one alert. Watch how all alerts are re-inserted to the DOM, even when they have not changed.

Proposed resolution

Use the "changed" timestamp field on alert entities to track what version of an alert was last rendered. If the timestamp matches between an existing alert DOM element and the latest alert data, do not replace/re-insert the alert markup.

API changes

No API changes specifically, but this would change the frontend behavior of the module. The event sitewide-alert-rendered will currently fire for every alert still present whenever an automatic refresh occurs. With this change, the event would only fire if the alert was not previously rendered or if it is updated to a newer version with a more recent timestamp.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

bvoynick created an issue. See original summary.

bvoynick’s picture

Assigned: bvoynick » Unassigned
Status: Active » Needs review

MR added. Note that fix in #3337688 must also be committed for this, to fix all alerts being regarded as stale.

smustgrave’s picture

Version: 2.x-dev » 3.0.x-dev
Status: Needs review » Needs work

Seems like something that's good candidate for 3.0.x

Will need a reroll

smustgrave’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.