docbrown/app/controllers/reading_list_items_controller.rb
Ben Halpern c7d7d55460
[WIP] Move both v1 and v2 editor to v2 preact-driven editor (#2797)
* Initial work on v2

* Initial changes merger

* Work to finalize v1/v2 editor adjustments

* Clean up styling

* Fiddle with form margins

* Fix some tests

* Change video

* skip a couple tests

* Modify tests to work with new code
2019-05-13 12:27:36 -04:00

31 lines
796 B
Ruby

class ReadingListItemsController < ApplicationController
def index
@reading_list_items_index = true
set_view
generate_algolia_search_key
end
def update
@reaction = Reaction.find(params[:id])
raise if @reaction.user_id != current_user.id # Lazy but I'm tired. HACK
@reaction.status = params[:current_status] == "archived" ? "valid" : "archived"
@reaction.save
head :ok
end
def generate_algolia_search_key
params = { filters: "viewable_by:#{current_user.id}" }
@secured_algolia_key = Algolia.generate_secured_api_key(
ApplicationConfig["ALGOLIASEARCH_SEARCH_ONLY_KEY"], params
)
end
def set_view
@view = if params[:view] == "archive"
"archived"
else
"valid"
end
end
end