From 0dbb6833df4993c2094a4db7e972f80c9ba9c02d Mon Sep 17 00:00:00 2001 From: reckyy Date: Tue, 9 Jul 2024 11:44:40 +0900 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=82=B9=E3=82=BF=E3=83=B3=E3=82=B9=E5=A4=89=E6=95=B0=E3=82=92?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../calendar/nico_nico_calendar_component.html.slim | 8 ++++---- app/controllers/home_controller.rb | 4 +--- app/controllers/users_controller.rb | 4 +--- app/views/home/index.html.slim | 2 +- app/views/users/show.html.slim | 2 +- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/app/components/calendar/nico_nico_calendar_component.html.slim b/app/components/calendar/nico_nico_calendar_component.html.slim index 7ab12727e19..15b3ec1db7a 100644 --- a/app/components/calendar/nico_nico_calendar_component.html.slim +++ b/app/components/calendar/nico_nico_calendar_component.html.slim @@ -6,15 +6,15 @@ .card-body .card__description .niconico-calendar-nav - - if prev_month?(@current_date) + - if prev_month?(current_date) = link_to prev_month_path do .niconico-calendar-nav__previous i.fa-solid.fa-angle-left - else .niconico-calendar-nav__next.is-blank .niconico-calendar-nav__year--month - = "#{@current_date.year}年#{@current_date.month}月" - - if next_month?(@current_date) + = "#{current_date.year}年#{current_date.month}月" + - if next_month?(current_date) = link_to next_month_path do .niconico-calendar-nav__next i.fa-solid.fa-angle-right @@ -31,7 +31,7 @@ th.niconico-calendar__header-day 金 th.niconico-calendar__header-day.is-saturday 土 tbody.niconico-calendar__body - - user.niconico_calendar(@current_calendar).each do |week| + - user.niconico_calendar(current_calendar).each do |week| tr.niconico-calendar__week - week.each do |set| - day_css_class = frame_and_background(set[:date], set[:emotion]) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index e1353051188..f997684df15 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -47,9 +47,7 @@ def display_dashboard @collegue_trainees_recent_reports = collegue_trainees_reports.order(reported_on: :desc).limit(10) @recent_reports = Report.with_avatar.where(wip: false).order(reported_on: :desc, created_at: :desc).limit(10) @collegues = current_user.collegues_other_than_self - calendar = NicoNicoCalendar.new(current_user, params[:niconico_calendar]) - @current_date = calendar.current_date - @current_calendar = calendar.with_reports + @calendar = NicoNicoCalendar.new(current_user, params[:niconico_calendar]) end def display_events_on_dashboard diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6db8c44fc59..041ae23d96c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -38,9 +38,7 @@ def show .where(status: 3) .order(updated_at: :desc) - calendar = NicoNicoCalendar.new(@user, params[:niconico_calendar]) - @current_date = calendar.current_date - @current_calendar = calendar.with_reports + @calendar = NicoNicoCalendar.new(@user, params[:niconico_calendar]) if logged_in? render :show diff --git a/app/views/home/index.html.slim b/app/views/home/index.html.slim index 3c306a4fc04..3e58130dd1a 100644 --- a/app/views/home/index.html.slim +++ b/app/views/home/index.html.slim @@ -42,5 +42,5 @@ - if current_user.github_account.present? = render 'users/github_grass', user: current_user - if current_user.student_or_trainee? - = render(Calendar::NicoNicoCalendarComponent.new(user: current_user, path: :niconico_calendar_date_path, current_date: @current_date, current_calendar: @current_calendar)) + = render(Calendar::NicoNicoCalendarComponent.new(user: current_user, path: :niconico_calendar_date_path, current_date: @calendar.current_date, current_calendar: @calendar.with_reports)) = render partial: 'recent_reports' diff --git a/app/views/users/show.html.slim b/app/views/users/show.html.slim index 5d16fcecd2b..fbf8e1d09bd 100644 --- a/app/views/users/show.html.slim +++ b/app/views/users/show.html.slim @@ -72,7 +72,7 @@ - unless @user.total_learning_time.zero? || @user.mentor? = react_component 'Grass', { userId: @user.id }, { class: 'a-card' } - if @user.student_or_trainee? - = render(Calendar::NicoNicoCalendarComponent.new(user: @user, path: :niconico_calendar_date_in_profile_path, current_date: @current_date, current_calendar: @current_calendar)) + = render(Calendar::NicoNicoCalendarComponent.new(user: @user, path: :niconico_calendar_date_in_profile_path, current_date: @calendar.current_date, current_calendar: @calendar.with_reports)) - if @user.completed_practices.present? - cache [@user, @completed_learnings] do = render '/users/practices/completed_practices', user: @user, completed_learnings: @completed_learnings