feat: show notes icon when notes is not empty (#3893)

* feat: show notes icon when notes is not empty

* fix: redundant clone

* chore: update collab and fix after merging main
This commit is contained in:
Mathias Mogensen
2023-11-09 00:30:50 +01:00
committed by GitHub
parent 73f1c211c2
commit 17651bf64c
19 changed files with 249 additions and 156 deletions

View File

@ -59,6 +59,9 @@ pub struct RowMetaPB {
#[pb(index = 4, one_of)]
pub cover: Option<String>,
#[pb(index = 5)]
pub is_document_empty: bool,
}
impl std::convert::From<&RowDetail> for RowMetaPB {
@ -68,6 +71,7 @@ impl std::convert::From<&RowDetail> for RowMetaPB {
document_id: row_detail.document_id.clone(),
icon: row_detail.meta.icon_url.clone(),
cover: row_detail.meta.cover_url.clone(),
is_document_empty: row_detail.meta.is_document_empty.clone(),
}
}
}
@ -78,6 +82,7 @@ impl std::convert::From<RowDetail> for RowMetaPB {
document_id: row_detail.document_id,
icon: row_detail.meta.icon_url,
cover: row_detail.meta.cover_url,
is_document_empty: row_detail.meta.is_document_empty,
}
}
}
@ -96,6 +101,9 @@ pub struct UpdateRowMetaChangesetPB {
#[pb(index = 4, one_of)]
pub cover_url: Option<String>,
#[pb(index = 5, one_of)]
pub is_document_empty: Option<bool>,
}
#[derive(Debug)]
@ -104,6 +112,7 @@ pub struct UpdateRowMetaParams {
pub view_id: String,
pub icon_url: Option<String>,
pub cover_url: Option<String>,
pub is_document_empty: Option<bool>,
}
impl TryInto<UpdateRowMetaParams> for UpdateRowMetaChangesetPB {
@ -122,6 +131,7 @@ impl TryInto<UpdateRowMetaParams> for UpdateRowMetaChangesetPB {
view_id,
icon_url: self.icon_url,
cover_url: self.cover_url,
is_document_empty: self.is_document_empty,
})
}
}

View File

@ -546,6 +546,7 @@ impl DatabaseEditor {
document_id: row_document_id,
icon: row_meta.icon_url,
cover: row_meta.cover_url,
is_document_empty: row_meta.is_document_empty,
})
} else {
warn!("the row:{} is exist in view:{}", row_id.as_str(), view_id);
@ -577,7 +578,8 @@ impl DatabaseEditor {
self.database.lock().update_row_meta(row_id, |meta_update| {
meta_update
.insert_cover_if_not_none(changeset.cover_url)
.insert_icon_if_not_none(changeset.icon_url);
.insert_icon_if_not_none(changeset.icon_url)
.update_is_document_empty_if_not_none(changeset.is_document_empty);
});
// Use the temporary row meta to get rid of the lock that not implement the `Send` or 'Sync' trait.