project-robius / robrix

A multi-platform Matrix chat client written in pure Rust using the Makepad UI toolkit and the Robius app dev framework
MIT License
93 stars 17 forks source link

Clear Timeline caches on live DSL reload #60

Open kevinaboos opened 7 months ago

kevinaboos commented 7 months ago

The TimelineUiState has two sets of cached draw items: content_drawn_since_last_update and profile_drawn_since_last_update. Both of these need to be wiped upon a DSL live reload, otherwise there are weird results displayed until you scroll them off screen or otherwise re-draw them.

The media_cache does not need to be modified.

Implementation ideas

This can be achieved by implementing the LiveHook trait for the Timeline widget struct, and then handling the case when apply.from is ApplyFrom::UpdateFromDoc.


impl LiveHook for Timeline {
    fn after_apply(&mut self, cx: &mut Cx, apply: &mut Apply, _index: usize, _nodes: &[LiveNode]) {
        if let ApplyFrom::UpdateFromDoc {..} = apply.from {
            // TODO: clear caches here
        }
    }
}