Skip to content

Commit 7bc8db2

Browse files
committed
Fix topics view behaviour for unsigned in users
1 parent baeb0c3 commit 7bc8db2

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

app/controllers/pages_controller.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ def topic
6464

6565
label = Label.find_by(name: topic_name)
6666

67-
@topic_repos = Repo.with_some_issues
67+
@repos = Repo.with_some_issues
6868
.includes(:repo_labels)
69-
.where(repo_labels: {label_id: label.id})
69+
.where(repo_labels: { label_id: label.id })
7070
.select(:id, :updated_at, :issues_count, :language, :full_name, :name, :description)
7171

72-
@repos = @topic_repos.without_user_subscriptions(current_user.id) if user_signed_in?
73-
@repos = @repos.order_by_issue_count.page(valid_params[:page]).per_page(valid_params[:per_page] || 50)
72+
topic_repo_ids = @repos.map { |repo| repo.id }
7473

75-
topic_repo_ids = @topic_repos.map { |repo| repo.id }
74+
@repos = @repos.without_user_subscriptions(current_user.id) if user_signed_in?
75+
@repos = @repos.order_by_issue_count.page(valid_params[:page]).per_page(valid_params[:per_page] || 50)
7676

7777
if user_signed_in?
7878
@repos_subs = current_user.repo_subscriptions.page(valid_params[:page]).per_page(valid_params[:per_page] || 50).includes(:repo)

app/views/application/_nav.html.slim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@ nav.application-navigation
1717
= content_tag 'a', 'Topics'
1818
div.dropdown-content
1919
=link_to 'Hacktoberfest', '/topics/hacktoberfest'
20-
2120
li.application-navigation-list-item= link_to "Submit Repo", new_repo_path
2221
li.application-navigation-list-item= link_to "Sign Out", destroy_user_session_path, method: :delete
2322
- else
2423
li.application-navigation-list-item= link_to 'About', what_path
2524
li.application-navigation-list-item= link_to 'University', university_index_path
25+
li.application-navigation-list-item
26+
div.dropdown
27+
= content_tag 'a', 'Topics'
28+
div.dropdown-content
29+
=link_to 'Hacktoberfest', '/topics/hacktoberfest'
2630
li.application-navigation-list-item= link_to 'Log in', user_github_omniauth_authorize_path, method: :post
2731
li.application-navigation-list-item= link_to 'Sign Up', user_github_omniauth_authorize_path, method: :post
2832

0 commit comments

Comments
 (0)