11use std:: collections:: { HashMap , HashSet } ;
2+ use std:: str:: FromStr ;
23use std:: sync:: Arc ;
34
5+ use crate :: folder_observe:: ViewChangeSender ;
46use anyhow:: bail;
7+ use collab:: core:: collab:: CollabVersion ;
58use collab:: preclude:: {
69 Any , Map , MapExt , MapPrelim , MapRef , ReadTxn , Subscription , TransactionMut ,
710} ;
@@ -12,8 +15,6 @@ use tokio::sync::Mutex;
1215use tracing:: { instrument, trace} ;
1316use uuid:: Uuid ;
1417
15- use crate :: folder_observe:: ViewChangeSender ;
16-
1718use crate :: revision:: RevisionMapping ;
1819use crate :: section:: { Section , SectionItem , SectionMap } ;
1920use crate :: space_info:: SpaceInfo ;
@@ -33,6 +34,7 @@ const VIEW_LAST_EDITED_TIME: &str = "last_edited_time";
3334const VIEW_LAST_EDITED_BY : & str = "last_edited_by" ;
3435const VIEW_IS_LOCKED : & str = "is_locked" ;
3536const VIEW_EXTRA : & str = "extra" ;
37+ const COLLAB_VERSION : & str = "version" ;
3638// const VIEW_LAST_VIEWED_TIME: &str = "last_viewed_time";
3739
3840pub fn timestamp ( ) -> i64 {
@@ -556,8 +558,12 @@ pub(crate) fn view_from_map_ref<T: ReadTxn>(
556558 let is_locked = map_ref. get_with_txn ( txn, VIEW_IS_LOCKED ) ;
557559 let extra = map_ref. get_with_txn ( txn, VIEW_EXTRA ) ;
558560
561+ let version: Option < String > = map_ref. get_with_txn ( txn, COLLAB_VERSION ) ;
562+ let version = version. and_then ( |v| Uuid :: from_str ( & v) . ok ( ) ) ;
563+
559564 Some ( View {
560565 id,
566+ version,
561567 parent_view_id,
562568 name,
563569 children,
@@ -783,6 +789,8 @@ impl<'a, 'b, 'c> ViewUpdate<'a, 'b, 'c> {
783789pub struct View {
784790 /// The id of the view
785791 pub id : collab_entity:: uuid_validation:: ViewId ,
792+ /// The version of the view, used when corresponding page has been reverted to past state.
793+ pub version : Option < CollabVersion > ,
786794 /// The id for given parent view
787795 pub parent_view_id : String ,
788796 /// The name that display on the left sidebar
@@ -822,6 +830,7 @@ impl View {
822830 ) -> Self {
823831 Self {
824832 id : view_id,
833+ version : None ,
825834 parent_view_id,
826835 name,
827836 children : Default :: default ( ) ,
0 commit comments