FEATURE: Show the slow mode indicator in composer (PR #12720)


@jjaffeux a code smell again since there’re so many arguments here. But it’s harder to imagine fix here and I feel like it’s better not to move so fast with the refactoring of composer since it’s so important component.

you don’t need the seq here, it’s only needed if you are going to use it in function body

Yes no need to rush.

A possible solution would be to create a state object:

@discourseComputed("isEditing", "isInSlowMode")
composerState(isEditing, isInSlowMode) {
  return  { isEditing, isInSlowMode };

And then you could use it as property in iconForComposerAction:

@discourseComputed("composerState.{isEditing,isInSlowMode}", "action", "whisper", "noBump")
iconForComposerAction(composerState, action, whisper, noBump) {
  return ...

But yes no need to rush this in this PR, you can keep it that way, it might need more thought.

I wonder, what happens if you are editing a post that is in a slow mode topic?

No sorry i wasn’t clear:

  • you need it in @discourseComputed so it tracks updates on seq
  • but you don’t need it on content(seq) if you don’t use seq

Yeah, we don’t use it directly but unfortunately, we still need it here. The method uses through this a lot of stuff that should be passed as an argument of computed property. The only reason we have seq in this component is to make sure that UI updates correctly.

It was introduced here. It isn’t an ideal solution but it works :slightly_smiling_face: . I would fix it in the future but it needs a careful approach :slightly_smiling_face: .

Oh, all right :+1: .

Then it’ll be pretty obvious without comment why we need it, so I will remove it.

:+1: at first glance looks like a cool solution, but, yeah, better later.

It’s a good catch! We should show the slow mode indicator when editing a post.

In other cases, we shouldn’t show it since they either aren’t affected by slow mode restrictions (like when a user answering with the new topic) either intended to be used by staff (like when answering with a whisper).