# Refresh ui-node

**URL:** <https://discourse.nodered.org/t/refresh-ui-node/13921>\
**Category:** Dashboard\
**Created:** [2 August 2019 09:16 UTC](https://discourse.nodered.org/t/refresh-ui-node/13921 "2019-08-02T09:16:49Z")\
**Posts on this page:** 1\
**Showing post:** 40

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [17 October 2019 21:33 UTC](https://discourse.nodered.org/t/refresh-ui-node/13921/40 "2019-10-17T21:33:46Z")

</div>

> [@dceejay](#):
>
> Don't forget - although I say a second client - this is still not multi-user. There is only one flow running with one overall state.

@dceejay,  
Very clever that you have thought about that!!!!!!!!!!

Indeed the last message is stored (in the replayMessages array) and send to any dashboard that needs initial state (e.g. refresh existing dashboard or open new dashboard). So for our Contextmenu-node that is very unwanted behaviour.

Did a quick test: when second dashboard is refreshed, it will get the last contextmenu of the previous dashboard. Here is a demo with **two dashboards** for interested readers:

 ![contextmenu_replay](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/81812b39cbb1a59898b01c6a5e175884ecdb2d01.gif)

> [@hotNipi](#):
>
> Did you tested it also within that time or it is lucky guess it is working?. Cos I didn't test that all, just reading the code.

Your suggestion is indeed very simple to implement, and it seems to work (both for refreshing a dasbhoard and in combination with a second dashboard). Thanks a lot for helping us with this!!!

Here it is, in case anybody ever needs it:

```auto
$scope.init = function (config) {
   // Ignore all input messages that arrive within 1 second after creation of this widget.
   // This way we can avoid the last old message being resend from server to the client...
   $scope.acceptMessages = false;
   setTimeout(function() { 
      $scope.acceptMessages = true; 
   } , 1000);
}

$scope.$watch('msg', function(msg) {
   // Ignore undefined messages.
   if (!msg) {
      return;
   }
                    
   if (!$scope.acceptMessages) {
      return;
   }

   // Process the input message ...

```

Only the time _ **interval of 1 second** _ is a bit of a trial-and-error:

- If I use a _larger_ interval, then I don't get a context menu when I immediately click on a shape.
- If I use a _smaller_ interval, then the old messages might be replayed.

So in my case 1 second works fine. But I could image that this isn't the case in some other setups, e.g. due to a slow internet connection? And adding an extra input field to our config screen (to make the time adjustable by the user) might confuse users, since it is a rather technical issue ...

---

_[View the full topic](https://discourse.nodered.org/t/refresh-ui-node/13921)._
