# עדכון ווידג'ט כאשר מתקבלת הודעה חדשה?

**URL:** <https://meta.discourse.org/t/update-widget-when-new-message-received/250637>\
**Category:** Development\
**Created:** [4 בינואר,‏ 2023,‏ 12:37am UTC](https://meta.discourse.org/t/update-widget-when-new-message-received/250637 "2023-01-04T00:37:52Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![piffy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/piffy/32/254198_2.png) [@piffy](https://meta.discourse.org/u/piffy)\
**Post date:** [4 בינואר,‏ 2023,‏ 3:01am UTC](https://meta.discourse.org/t/update-widget-when-new-message-received/250637/2 "2023-01-04T03:01:21Z")

</div>

So I found a working solution. There is apparently a private message version of the TopicTrackingState. Took me a while to figure out that it requires a “key” as a parameter, which is unclear to me what the key is for but it took an arbitrary string without issue

```
  pmTopicTrackingState.onStateChange("pm-tracking-key", () => {
    this.scheduleRerender();
   });

```

This triggers the rerender but I noticed that `new_personal_messages_notifications_count` is not updated in time for the rerender so it fails to actually update immediately.

I think this is a “good enough” solution for me though. The notification eventually makes it’s way onto the widget. I’m happy to hear any comments on this though

---

_[View the full topic](https://meta.discourse.org/t/update-widget-when-new-message-received/250637)._
