Skip to content

Commit 79e3997

Browse files
authored
fix: handle updates where no previous obj... (#915)
is in the cache.
1 parent 9cd8378 commit 79e3997

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

interactions/api/gateway/client.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,11 +405,18 @@ def _dispatch_event(self, event: str, data: dict) -> None:
405405

406406
elif "_update" in name and hasattr(obj, "id"):
407407
old_obj = self._http.cache[model].get(id)
408-
copy = model(**old_obj._json)
409-
old_obj.update(**obj._json)
408+
409+
if old_obj:
410+
before = model(**old_obj._json)
411+
old_obj.update(**obj._json)
412+
else:
413+
before = None
414+
old_obj = obj
415+
410416
_cache.add(old_obj, id)
417+
411418
self._dispatch.dispatch(
412-
f"on_{name}", copy, old_obj
419+
f"on_{name}", before, old_obj
413420
) # give previously stored and new one
414421
return
415422

0 commit comments

Comments
 (0)