Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Announcements don't stay dismissed #1876

Open
ArmandBernard opened this issue Jun 18, 2022 · 0 comments
Open

Announcements don't stay dismissed #1876

ArmandBernard opened this issue Jun 18, 2022 · 0 comments

Comments

@ArmandBernard
Copy link

ArmandBernard commented Jun 18, 2022

This is my first submitted issue! Yay!

The issue

When I dismiss announcements on the main page of the site, they don't stay dismissed, returning on page refresh.

Investigation so far

Looking at the code in site-announcements.js, clicking the cross dismiss button sends a post request to the back-end, presumably saving to a database the announcements a user has seen to filter them out.

Front-end

Fetch to get announcements

The call is made to https://kitsu.io/api/edge/feeds/site_announcements/57044?include=subject. I believe 57044 here is my user id.
The data returns 4 announcements. Each announcement seems to be split between two objects. The first has an id and a link to the second object. The second object contains the content to be shown in the announcement. This is probably linked to the "data enrichment" mentioned by the site-announcements.js.
image

Fetch to dismiss

Once I click on the dismiss button, the correct announcemment id seems to be sent to the back-end.
image
The url has a matching id. https://kitsu.io/api/edge/feeds/site_announcements/57044/_read
The response is a 200 success code.

Back-end

Bear with me here, as I have never even seen ruby code before.

The controller routes seem to be defined in routes.rb. The relevant resource seems to be jsonapi_resources :site_announcements on line 142, with the appropriate route being

post '/feeds/:group/:id/_read', to: 'feeds#mark_read'

There seems to be a site_announcements controller, but that is basically empty.

Otherwise, the controller for feeds is feeds_controller.rb, which contains the mark_read action.

  def mark_read
    activities = feed.activities.mark(:read, params[:_json])
    render_jsonapi stringify_activities(activities)
  end

mark() here appears to be the function defined in activity_list.rb:

    def mark(type, values = true)
      values = [values] if values.is_a? String
      data["mark_#{type}"] = values
      self
    end

This seems to set the field "mark_read" to true depending on the passed in json, though I'm not sure.

this bit in activity_list.rb may also be relevant:

    %i[limit offset ranking mark_read mark_seen].each do |key|
      define_method(key) do |value|
        data[key] = value
        self
      end
    end

To be honest, though I can find related pieces of code on the back-end, I am struggling to find whats wrong given that I do not know the language. Hopefully the stuff I've done above will be helpful and someone can find whats wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant