Don't persist Grid sizes

A) there are potentially a lot of Grids, using up a lot of space
(and therefore serialization time).

B) if the code changes, the grid should also change,
and not remember old sizes
This commit is contained in:
Emil Ernerfeldt 2022-04-19 21:28:45 +02:00
parent 558891c146
commit f789159a4a

View file

@ -1,7 +1,6 @@
use crate::*; use crate::*;
#[derive(Clone, Debug, Default, PartialEq)] #[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub(crate) struct State { pub(crate) struct State {
col_widths: Vec<f32>, col_widths: Vec<f32>,
row_heights: Vec<f32>, row_heights: Vec<f32>,
@ -9,11 +8,14 @@ pub(crate) struct State {
impl State { impl State {
pub fn load(ctx: &Context, id: Id) -> Option<Self> { pub fn load(ctx: &Context, id: Id) -> Option<Self> {
ctx.data().get_persisted(id) ctx.data().get_temp(id)
} }
pub fn store(self, ctx: &Context, id: Id) { pub fn store(self, ctx: &Context, id: Id) {
ctx.data().insert_persisted(id, self); // We don't persist Grids, because
// A) there are potentially a lot of them, using up a lot of space (and therefore serialization time)
// B) if the code changes, the grid _should_ change, and not remember old sizes
ctx.data().insert_temp(id, self);
} }
fn set_min_col_width(&mut self, col: usize, width: f32) { fn set_min_col_width(&mut self, col: usize, width: f32) {