# How to check if last step was from collab in view plugin?

**URL:** <https://discuss.prosemirror.net/t/how-to-check-if-last-step-was-from-collab-in-view-plugin/2917>\
**Category:** Uncategorized\
**Created:** [June 17, 2020, 10:03pm UTC](https://discuss.prosemirror.net/t/how-to-check-if-last-step-was-from-collab-in-view-plugin/2917 "2020-06-17T22:03:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ungoldman](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/ungoldman/32/931_2.png) [@ungoldman](https://discuss.prosemirror.net/u/ungoldman)\
**Post date:** [June 17, 2020, 10:03pm UTC](https://discuss.prosemirror.net/t/how-to-check-if-last-step-was-from-collab-in-view-plugin/2917/1 "2020-06-17T22:03:09Z")

</div>

Hey folks, another question for people who’ve worked with the [prosemirror-collab](https://github.com/ProseMirror/prosemirror-collab/) module before:

Has anyone found a good method, _within the context of a view plugin_, for determining if a state change was caused by a remote transaction?

The scenario is that I have a menu plugin that needs to close if the user changes their selection or updates the document, but it needs to stay open if the document is updated by a _different_ user.

The idea I have for now is to use the `Plugin.state` fields to look for transactions with `collab$` metadata and change plugin state based on that. Something like:

```auto
new Plugin({
  key: new PluginKey('LAST_TR'),
  state: {
    init () {
      return false
    },
    apply (tr, prev, oldState, newState) {
      if (tr.getMeta('collab$')) return true
      return false
    }
  }
})

```

To clarify further, I need to be able to tell within the scope of the `update` function returned by `Plugin.view` if the last update was caused by the collab module.

I’m thinking I’d be able to use the value set above in the `update` function by checking state of `editorView.state[LAST_TR]`, LAST\_TR being the plugin key.

Anyone have a better idea?

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [June 18, 2020, 11:32am UTC](https://discuss.prosemirror.net/t/how-to-check-if-last-step-was-from-collab-in-view-plugin/2917/2 "2020-06-18T11:32:50Z")

</div>

You can attach additional metadata to the transaction produced by `receiveTransaction` if you want, which might help here.

---

<div class="post-metadata">

**Author:** ![ungoldman](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/ungoldman/32/931_2.png) [@ungoldman](https://discuss.prosemirror.net/u/ungoldman)\
**Post date:** [June 18, 2020, 5:55pm UTC](https://discuss.prosemirror.net/t/how-to-check-if-last-step-was-from-collab-in-view-plugin/2917/3 "2020-06-18T17:55:31Z")

</div>

How would that help?
