Skip to content

Conversation

@igorkasyanchuk
Copy link
Contributor

I think we are missing an easy way to render stream actions in background.

I want to have code like this:

    def update_unread_conversations_count(user)
      conversations_count = user.available_conversations.unread_for_user(user).count
      # conversations_count = rand(3)
      actions = [
        turbo_stream_action_tag(:update, template: conversations_count, target: "unread-conversations-count-sidebar"),
        if conversations_count > 0
          turbo_stream_action_tag(:remove_css_class, target: "unread-conversations-count-sidebar", classes: "hidden")
        else
          turbo_stream_action_tag(:add_css_class, target: "unread-conversations-count-sidebar", classes: "hidden")
        end
      ]
      broadcast_stream_later_to([user, :updates], content: actions.join("\n"))
    end

@igorkasyanchuk
Copy link
Contributor Author

I don't understand how to fix failed CI builds. Not related to my code changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant