Handle the case where a previous serach model isn't set when updating the model

This commit is contained in:
sabaimran
2024-04-05 13:18:51 +05:30
parent f57f9f672d
commit d23f7da8e3

View File

@@ -265,7 +265,11 @@ async def update_search_model(
prev_config = await adapters.aget_user_search_model(user)
new_config = await adapters.aset_user_search_model(user, int(id))
if int(id) != prev_config.id:
if prev_config and int(id) != prev_config.id and new_config:
await EntryAdapters.adelete_all_entries(user)
if not prev_config:
# If the use was just using the default config, delete all the entries and set the new config.
await EntryAdapters.adelete_all_entries(user)
if new_config is None: