@@ -66,7 +66,7 @@ class Storage:
66
66
def __init__ (self ) -> None :
67
67
self ._general = Storage ._create_persistent_dict ('general' )
68
68
self ._users : Dict [str , PersistentDict ] = {}
69
- self ._tabs : Dict [str , PersistentDict ] = {}
69
+ self ._tabs : Dict [str , ObservableDict ] = {}
70
70
71
71
@staticmethod
72
72
def _create_persistent_dict (id : str ) -> PersistentDict : # pylint: disable=redefined-builtin
@@ -163,13 +163,19 @@ def tab(self) -> observables.ObservableDict:
163
163
async def _create_tab_storage (self , tab_id : str ) -> None :
164
164
"""Create tab storage for the given tab ID."""
165
165
if tab_id not in self ._tabs :
166
- self ._tabs [tab_id ] = Storage ._create_persistent_dict (f'tab-{ tab_id } ' )
167
- await self ._tabs [tab_id ].initialize ()
166
+ if Storage .redis_url :
167
+ self ._tabs [tab_id ] = Storage ._create_persistent_dict (f'tab-{ tab_id } ' )
168
+ await self ._tabs [tab_id ].initialize ()
169
+ else :
170
+ self ._tabs [tab_id ] = ObservableDict ()
168
171
169
172
def copy_tab (self , old_tab_id : str , tab_id : str ) -> None :
170
173
"""Copy the tab storage to a new tab. (For internal use only.)"""
171
174
if old_tab_id in self ._tabs :
172
- self ._tabs [tab_id ] = Storage ._create_persistent_dict (f'tab-{ tab_id } ' )
175
+ if Storage .redis_url :
176
+ self ._tabs [tab_id ] = Storage ._create_persistent_dict (f'tab-{ tab_id } ' )
177
+ else :
178
+ self ._tabs [tab_id ] = ObservableDict ()
173
179
self ._tabs [tab_id ].update (self ._tabs [old_tab_id ])
174
180
175
181
async def prune_tab_storage (self ) -> None :
0 commit comments