implemented the deletion of unnecesarry details in not chosen objects, for the sake of memory efficiency in the history
This commit is contained in:
parent
b20d7fcc76
commit
f471c6a72b
@ -167,7 +167,7 @@ class Shell:
|
||||
self.max_displayed_options = max_displayed_options
|
||||
self.option_digits: int = option_digits
|
||||
|
||||
self.current_results: Results = SearchResults
|
||||
self.current_results: Results = None
|
||||
self._result_history: List[Results] = []
|
||||
|
||||
self.genre = genre or get_genre()
|
||||
@ -296,6 +296,9 @@ class Shell:
|
||||
page: Type[Page]
|
||||
music_object: DatabaseObject
|
||||
|
||||
if self.current_results is not None:
|
||||
self.current_results.delete_details(index)
|
||||
|
||||
try:
|
||||
page, music_object = self.current_results.get_music_object_by_index(index)
|
||||
except KeyError:
|
||||
|
@ -30,6 +30,13 @@ class Results:
|
||||
# if this throws a key error, either the formated generator needs to be iterated, or the option doesn't exist.
|
||||
return self._page_by_index[index], self._by_index[index]
|
||||
|
||||
def delete_details(self, exclude_index: int):
|
||||
for index, music_object in self._by_index.items():
|
||||
if index == exclude_index:
|
||||
continue
|
||||
|
||||
music_object.strip_details()
|
||||
|
||||
|
||||
class SearchResults(Results):
|
||||
def __init__(
|
||||
|
@ -158,3 +158,6 @@ class Collection:
|
||||
@property
|
||||
def empty(self) -> bool:
|
||||
return len(self._data) == 0
|
||||
|
||||
def clear(self):
|
||||
self.__init__(element_type=self.element_type)
|
||||
|
@ -95,6 +95,10 @@ class DatabaseObject:
|
||||
if override or getattr(self, simple_attribute) == default_value:
|
||||
setattr(self, simple_attribute, getattr(other, simple_attribute))
|
||||
|
||||
def strip_details(self):
|
||||
for collection in type(self).DOWNWARDS_COLLECTION_ATTRIBUTES:
|
||||
getattr(self, collection).clear()
|
||||
|
||||
@property
|
||||
def metadata(self) -> Metadata:
|
||||
return Metadata()
|
||||
|
Loading…
Reference in New Issue
Block a user