From 69a37495b53029cf318f579f7b03a3fd1cc3197d Mon Sep 17 00:00:00 2001 From: Nuwan Date: Wed, 6 Nov 2024 17:58:40 +0530 Subject: [PATCH 1/7] new user confirm email update user confirm email contents and change to the new layout --- ruby/lib/jam_ruby/app/mailers/user_mailer.rb | 4 +- .../user_mailer/confirm_email.html.erb | 33 ++++++++-- .../user_mailer/confirm_email.html.erb.backup | 9 +++ .../user_mailer/confirm_email.text.erb | 10 +-- .../user_mailer/confirm_email.text.erb.backup | 8 +++ .../user_mailer/new_musicians_match.text.erb | 16 ++--- .../views/layouts/user_mailer_beta.html.erb | 66 ++++++++++--------- .../jam_ruby/lib/email_new_musician_match.rb | 2 +- web/config/locales/en.yml | 14 ++++ web/config/locales/es.yml | 24 ++++++- 10 files changed, 133 insertions(+), 53 deletions(-) create mode 100644 ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.html.erb.backup create mode 100644 ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.text.erb.backup diff --git a/ruby/lib/jam_ruby/app/mailers/user_mailer.rb b/ruby/lib/jam_ruby/app/mailers/user_mailer.rb index 8bb38cde7..2c4108565 100644 --- a/ruby/lib/jam_ruby/app/mailers/user_mailer.rb +++ b/ruby/lib/jam_ruby/app/mailers/user_mailer.rb @@ -31,9 +31,9 @@ module JamRuby sendgrid_recipients([user.email]) sendgrid_substitute('@USERID', [user.id]) - mail(:to => user.email, :subject => "Please confirm your JamKazam email") do |format| + mail(:to => user.email, :subject => "Please confirm your JamKazam email address") do |format| format.text - format.html + format.html { render layout: "user_mailer_beta" } end end diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.html.erb index 358f0f2b1..92fee1d6b 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.html.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.html.erb @@ -1,9 +1,34 @@ <% provide(:title, 'Welcome to JamKazam!') %> -

We’re delighted you have joined our community of <%= APP_CONFIG.musician_count %> musicians. We’d like to send you an orientation email with information and resource links that will help you get the most out of JamKazam. Please click here to confirm this email has reached you successfully and we will then send the orientation email.

+

+ <%= I18n.t 'user_mailer.confirm_email.paragraph1' -%> +

-

If you have received this email but aren’t familiar with JamKazam or JamTracks, then someone has registered at our website using your email address, and you can just ignore and delete this email.

+
+ <%= I18n.t 'user_mailer.confirm_email.confirm_email' -%> +
-

Best Regards,
- Team JamKazam +

+ <%= I18n.t 'user_mailer.confirm_email.paragraph2' -%> +

+ +

<%= I18n.t 'user_mailer.confirm_email.best_wishes' -%>
+ <%= I18n.t 'user_mailer.confirm_email.signature' -%>

\ No newline at end of file diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.html.erb.backup b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.html.erb.backup new file mode 100644 index 000000000..358f0f2b1 --- /dev/null +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.html.erb.backup @@ -0,0 +1,9 @@ +<% provide(:title, 'Welcome to JamKazam!') %> + +

We’re delighted you have joined our community of <%= APP_CONFIG.musician_count %> musicians. We’d like to send you an orientation email with information and resource links that will help you get the most out of JamKazam. Please click here to confirm this email has reached you successfully and we will then send the orientation email.

+ +

If you have received this email but aren’t familiar with JamKazam or JamTracks, then someone has registered at our website using your email address, and you can just ignore and delete this email.

+ +

Best Regards,
+ Team JamKazam +

\ No newline at end of file diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.text.erb index 129da288d..c465f5ea9 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.text.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.text.erb @@ -1,8 +1,8 @@ -Welcome to JamKazam! +<%= I18n.t 'user_mailer.confirm_email.paragraph1' -%> -We’re delighted you have joined our community of <%= APP_CONFIG.musician_count %> musicians. We’d like to send you an orientation email with information and resource links that will help you get the most out of JamKazam. Please click <%= @signup_confirm_url %> to confirm this email has reached you successfully and we will then send the orientation email. +<%= @signup_confirm_url %> -If you have received this email but aren’t familiar with JamKazam or JamTracks, then someone has registered at our website using your email address, and you can just ignore and delete this email. +<%= I18n.t 'user_mailer.confirm_email.paragraph2' -%> -Best Regards, -Team JamKazam \ No newline at end of file +<%= I18n.t 'user_mailer.confirm_email.best_wishes' -%> +<%= I18n.t 'user_mailer.confirm_email.signature' -%> \ No newline at end of file diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.text.erb.backup b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.text.erb.backup new file mode 100644 index 000000000..129da288d --- /dev/null +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/confirm_email.text.erb.backup @@ -0,0 +1,8 @@ +Welcome to JamKazam! + +We’re delighted you have joined our community of <%= APP_CONFIG.musician_count %> musicians. We’d like to send you an orientation email with information and resource links that will help you get the most out of JamKazam. Please click <%= @signup_confirm_url %> to confirm this email has reached you successfully and we will then send the orientation email. + +If you have received this email but aren’t familiar with JamKazam or JamTracks, then someone has registered at our website using your email address, and you can just ignore and delete this email. + +Best Regards, +Team JamKazam \ No newline at end of file diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/new_musicians_match.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/new_musicians_match.text.erb index 30d6cb449..e372b88ef 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/new_musicians_match.text.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/new_musicians_match.text.erb @@ -2,7 +2,7 @@ Hi <%= @user.first_name %>, <% end %> -The following musicians have joined JamKazam within the last week and have low internet latency to you that will support enjoyable sessions. If you'd like to make more musical connections, we encourage you to use the links below to send these new users a welcome message and perhaps arrange a session to play together. +<%= I18n.t 'user_mailer.new_musicians_match.paragraph1' -%> <% @musicians_data.each do | data | -%> @@ -13,20 +13,20 @@ The following musicians have joined JamKazam within the last week and have low i latency = latencies.find{|l| l[:user_id] == musician.id } -%> <%= musician.first_name %> <%= musician.last_name %> - Latency To You: <%= latency_info(latency) %> + <%= I18n.t 'user_mailer.new_musicians_match.latency_to_you' -%>: <%= latency_info(latency) %> <% if musician.last_active_timestamp -%> - Last Active On: <%= time_ago_in_words(Time.at(musician.last_active_timestamp)) %> ago + <%= I18n.t 'user_mailer.new_musicians_match.last_active' -%>: <%= time_ago_in_words(Time.at(musician.last_active_timestamp)) %> ago <% end -%> <% musician.musician_instruments.each do |mi| -%> <%= mi.description %> (<%= @instrument_proficiencies[mi.proficiency_level.to_s.to_sym] %>) <% end -%> - View Profile: <%= APP_CONFIG.spa_origin -%>/friends?id=<%= musician.id %>&open=details - Send Message: <%= APP_CONFIG.spa_origin -%>/friends?id=<%= musician.id %>&open=message - Send Friend Request: <%= APP_CONFIG.spa_origin -%>/friends?id=<%= musician.id %>&open=connect + <%= I18n.t 'user_mailer.new_musicians_match.view_profile' -%>: <%= APP_CONFIG.spa_origin -%>/friends?id=<%= musician.id %>&open=details + <%= I18n.t 'user_mailer.new_musicians_match.send_message' -%>: <%= APP_CONFIG.spa_origin -%>/friends?id=<%= musician.id %>&open=message + <%= I18n.t 'user_mailer.new_musicians_match.send_friend_request' -%>: <%= APP_CONFIG.spa_origin -%>/friends?id=<%= musician.id %>&open=connect <% end -%> <% end -%> - To find great musical matches across the entire JamKazam commiunity and make new connections, use the link below to access our musician search feature. This let you filter JamKazammers by latency, instruments, skill level, genre interests, last active day and more. + <%= I18n.t 'user_mailer.new_musicians_match.paragraph2' -%> - Search JamKazam Musicians: <%= APP_CONFIG.spa_origin -%>/friends \ No newline at end of file + <%= I18n.t 'user_mailer.new_musicians_match.search_musicians' -%>: <%= APP_CONFIG.spa_origin -%>/friends \ No newline at end of file diff --git a/ruby/lib/jam_ruby/app/views/layouts/user_mailer_beta.html.erb b/ruby/lib/jam_ruby/app/views/layouts/user_mailer_beta.html.erb index d5417be56..ae24e13b6 100644 --- a/ruby/lib/jam_ruby/app/views/layouts/user_mailer_beta.html.erb +++ b/ruby/lib/jam_ruby/app/views/layouts/user_mailer_beta.html.erb @@ -25,38 +25,40 @@ + <% if @user && @user.unsubscribe_token -%> +

+ <%= I18n.t "mailer_layout.footer.paragraph1" -%> JamKazam. <%= I18n.t "mailer_layout.footer.unsubscribe" -%> +

+ <% end -%> +
+ + " alt="Facebook" style="width: 24px; height: 24px; margin: 0 5px;"> + + + + " alt="Instagram" style="width: 24px; height: 24px; margin: 0 5px;"> + + + " alt="TikTok" style="width: 24px; height: 24px; margin: 0 5px;"> + + + " alt="YouTube" style="width: 24px; height: 24px; margin: 0 5px;"> + + + " alt="X.com" style="width: 24px; height: 24px; margin: 0 5px;"> + +
+

+ <%= I18n.t "mailer_layout.footer.copyright" -%> +

+ diff --git a/ruby/lib/jam_ruby/lib/email_new_musician_match.rb b/ruby/lib/jam_ruby/lib/email_new_musician_match.rb index b55200ac0..d5369f65e 100644 --- a/ruby/lib/jam_ruby/lib/email_new_musician_match.rb +++ b/ruby/lib/jam_ruby/lib/email_new_musician_match.rb @@ -9,7 +9,7 @@ module JamRuby PRIORITY_RECIPIENTS = %w(seth@jamkazam.com david@jamkazam.com peter@jamkazam.com nuwan@jamkazam.com).freeze def self.subject - "New musicians with good Internet connections to you have joined JamKazam!" + I18n.t 'user_mailer.new_musicians_match.subject' end def self.send_new_musicians diff --git a/web/config/locales/en.yml b/web/config/locales/en.yml index 97c8dafd1..cb4cdf309 100644 --- a/web/config/locales/en.yml +++ b/web/config/locales/en.yml @@ -6,8 +6,22 @@ en: attributes: user: password_digest: "Password" + mailer_layout: + footer: + paragraph1: "This email was sent to you because you have an account at" + unsubscribe: "Unsubscribe" + copyright: "Copyright © 2024 JamKazam, Inc. All rights reserved." user_mailer: + confirm_email: + subject: "Please confirm your JamKazam email address" + paragraph1: "Thanks for signing up with JamKazam! Please click the button below to confirm your email for use with JamKazam. We do not sell or share our users’ emails. We only use your email to send you information and updates about the JamKazam service." + confirm_email: "Confirm Email Address" + paragraph2: " If you have received this email but aren’t familiar with JamKazam, someone has registered at our website using your email address, and you can use the unsubscribe link below to stop receiving emails from us." + best_wishes: "Best Regards," + signature: "Team JamKazam" + new_musicians_match: + subject: "New musicians with good Internet connections to you have joined JamKazam!" greeting: "Hi" paragraph1: "The following musicians have joined JamKazam within the last week and have low internet latency to you that will support enjoyable sessions. If you'd like to make more musical connections, we encourage you to use the links below to send these new users a welcome message and perhaps arrange a session to play together." latency_to_you: "Latency to You" diff --git a/web/config/locales/es.yml b/web/config/locales/es.yml index 91d6d1468..7bc3962d0 100644 --- a/web/config/locales/es.yml +++ b/web/config/locales/es.yml @@ -6,7 +6,29 @@ en: attributes: user: password_digest: "Password" + mailer_layout: + footer: + paragraph1: "This email was sent to you because you have an account at" + unsubscribe: "Unsubscribe" + copyright: "Copyright © 2024 JamKazam, Inc. All rights reserved." user_mailer: + confirm_email: + subject: "Please confirm your JamKazam email address" + paragraph1: "Thanks for signing up with JamKazam! Please click the button below to confirm your email for use with JamKazam. We do not sell or share our users’ emails. We only use your email to send you information and updates about the JamKazam service." + confirm_email: "Confirm Email Address" + paragraph2: " If you have received this email but aren’t familiar with JamKazam, someone has registered at our website using your email address, and you can use the unsubscribe link below to stop receiving emails from us." + best_wishes: "Best Regards," + signature: "Team JamKazam" + new_musicians_match: + subject: "New musicians with good Internet connections to you have joined JamKazam!" greeting: "Hola" - view_profile: "Ver Perfil" + paragraph1: "The following musicians have joined JamKazam within the last week and have low internet latency to you that will support enjoyable sessions. If you'd like to make more musical connections, we encourage you to use the links below to send these new users a welcome message and perhaps arrange a session to play together." + latency_to_you: "Latency to You" + last_active: "Last Active" + ago: "ago" + view_profile: "View Profile" + send_message: "Send Message" + send_friend_request: "Send Friend Request" + paragraph2: "To find great musical matches across the entire JamKazam commiunity and make new connections, use the button below to access our musician search feature. This let you filter JamKazammers by latency, instruments, skill level, genre interests, last active day and more." + search_musicians: "Search JamKazam Musicians" From 051477d19f0bc704bdc40db8bcf066f74386cd10 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Thu, 7 Nov 2024 20:45:51 +0530 Subject: [PATCH 2/7] new user match email - jamkazam team only add a config to restrict new_musicians_match email to be sent only to jamkazam team users --- ruby/lib/jam_ruby/lib/email_new_musician_match.rb | 8 ++++++-- ruby/spec/jam_ruby/lib/email_new_musician_match_spec.rb | 9 +++++++++ web/config/application.rb | 1 + web/config/environments/development.rb | 2 ++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ruby/lib/jam_ruby/lib/email_new_musician_match.rb b/ruby/lib/jam_ruby/lib/email_new_musician_match.rb index d5369f65e..e8be9c41e 100644 --- a/ruby/lib/jam_ruby/lib/email_new_musician_match.rb +++ b/ruby/lib/jam_ruby/lib/email_new_musician_match.rb @@ -33,7 +33,6 @@ module JamRuby end begin - recipients = User.where("users.subscribe_email = ? AND users.subscribe_email_for_user_match = ? AND NOT COALESCE(users.user_match_email_sent_at, ?) > ?", @@ -41,12 +40,17 @@ module JamRuby CASE WHEN users.email IN ('#{PRIORITY_RECIPIENTS.map {|str| "\"#{str}\""}.join(',')}') THEN 0 ELSE 1 END, last_active_at DESC").select("users.*, GREATEST(updated_at, last_jam_updated_at) AS last_active_at").limit(LIMIT) + + # If the flag is set to send user match email only to jamkazam team + if Rails.application.config.send_user_match_mail_only_to_jamkazam_team + recipients = recipients.where(email: PRIORITY_RECIPIENTS) + end AdminMailer.ugly({to: APP_CONFIG.user_match_monitoring_email, subject:"Weekly user match email sending job started.", body: "#{email_sending.sent_user_ids.any?? "This job is resuming. It was originally started at #{email_sending.created_at} and has been sent to #{email_sending.sent_user_ids.size} user(s) so far." : "This job was started at #{email_sending.created_at}" }. It will send to total of #{ recipients.size } users."}).deliver_now - recipients.find_each do |user| + recipients.find_each do |user| ip_address = user.last_jam_addr.blank?? '127.0.0.1' : IPAddr.new(user.last_jam_addr, Socket::AF_INET).to_s matched_musician_data = [] diff --git a/ruby/spec/jam_ruby/lib/email_new_musician_match_spec.rb b/ruby/spec/jam_ruby/lib/email_new_musician_match_spec.rb index 56eca0494..5ce5de145 100644 --- a/ruby/spec/jam_ruby/lib/email_new_musician_match_spec.rb +++ b/ruby/spec/jam_ruby/lib/email_new_musician_match_spec.rb @@ -23,6 +23,7 @@ describe EmailNewMusicianMatch do ActionMailer::Base.deliveries = [] User.delete_all allow(JamRuby::MusicianFilter).to receive(:filter).and_return(search_result) + Rails.application.config.send_user_match_mail_only_to_jamkazam_team = false end after(:each) do @@ -46,6 +47,14 @@ describe EmailNewMusicianMatch do JamRuby::EmailNewMusicianMatch.send_new_musicians end + it "delivers only to priority recipients" do + Rails.application.config.send_user_match_mail_only_to_jamkazam_team = true + allow(UserMailer).to receive(:new_musicians_match).and_return(mail) + expect(mail).to receive(:deliver_now).exactly(1).times #only to the priority user seth@jamkazam + JamRuby::EmailNewMusicianMatch.send_new_musicians + end + + xit "delivers to priority recipients first" do JamRuby::EmailNewMusicianMatch.send_new_musicians raise ActionMailer::Base.deliveries.map{|d| d['to'].to_s }.inspect #.include?("seth@example.com").should be_truthy diff --git a/web/config/application.rb b/web/config/application.rb index 0aa9e312c..d43bbd722 100644 --- a/web/config/application.rb +++ b/web/config/application.rb @@ -518,5 +518,6 @@ if defined?(Bundler) config.manual_override_installer_ends_with = "JamKazam-1.0.3776.dmg" config.spa_origin = "http://beta.jamkazam.local:4000" config.user_match_monitoring_email = "user_match_monitoring_email@jamkazam.com" + config.send_user_match_mail_only_to_jamkazam_team = true end end diff --git a/web/config/environments/development.rb b/web/config/environments/development.rb index 0c8e8bd91..0b38cafbb 100644 --- a/web/config/environments/development.rb +++ b/web/config/environments/development.rb @@ -125,4 +125,6 @@ SampleApp::Application.configure do config.action_controller.asset_host = 'http://localhost:3000' config.action_mailer.asset_host = config.action_controller.asset_host + + config.send_user_match_mail_only_to_jamkazam_team = false end From d7a4e4635563784b197f6c58b9708efff693aeb9 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Thu, 7 Nov 2024 20:50:40 +0530 Subject: [PATCH 3/7] add murali, bob & jorge to the jamkazam users that get the new_musicians_match email --- ruby/lib/jam_ruby/lib/email_new_musician_match.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruby/lib/jam_ruby/lib/email_new_musician_match.rb b/ruby/lib/jam_ruby/lib/email_new_musician_match.rb index e8be9c41e..bc3ab6534 100644 --- a/ruby/lib/jam_ruby/lib/email_new_musician_match.rb +++ b/ruby/lib/jam_ruby/lib/email_new_musician_match.rb @@ -6,7 +6,7 @@ module JamRuby JOINED_WITHIN_DAYS = 7 ACTIVE_WITHIN_DAYS = 30 - PRIORITY_RECIPIENTS = %w(seth@jamkazam.com david@jamkazam.com peter@jamkazam.com nuwan@jamkazam.com).freeze + PRIORITY_RECIPIENTS = %w(seth@jamkazam.com david@jamkazam.com peter@jamkazam.com nuwan@jamkazam.com murali@jamkazam.com bob@jamkazam.com jorge@jamkazam.com).freeze def self.subject I18n.t 'user_mailer.new_musicians_match.subject' From ac469c2741871709e8cf3a6464729187c0102529 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Fri, 8 Nov 2024 13:03:47 +0530 Subject: [PATCH 4/7] remove mailcatcher gem from Gemfile.alt --- web/Gemfile.alt | 2 +- web/config/environments/development.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/Gemfile.alt b/web/Gemfile.alt index df438d16e..4b79bebf2 100644 --- a/web/Gemfile.alt +++ b/web/Gemfile.alt @@ -159,7 +159,7 @@ gem 'logging', '1.7.2' gem 'rack-cors', '~> 1.0', '>= 1.0.6' -gem 'mailcatcher' +#gem 'mailcatcher' if ENV['FASTER_PATH'] == '1' diff --git a/web/config/environments/development.rb b/web/config/environments/development.rb index 0b38cafbb..b2f52c386 100644 --- a/web/config/environments/development.rb +++ b/web/config/environments/development.rb @@ -26,8 +26,8 @@ SampleApp::Application.configure do # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false - config.action_mailer.delivery_method = :smtp - config.action_mailer.smtp_settings = { address: '127.0.0.1', port: 1025, domain: '127.0.0.1' } + #config.action_mailer.delivery_method = :smtp + #config.action_mailer.smtp_settings = { address: '127.0.0.1', port: 1025, domain: '127.0.0.1' } # Print deprecation notices to the Rails logger config.active_support.deprecation = :log From 94ac48c8b55b19791532dae0308e209527d41bc6 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Fri, 8 Nov 2024 16:40:20 +0530 Subject: [PATCH 5/7] fix images on beta email template --- .../views/layouts/user_mailer_beta.html.erb | 22 +++++++++---------- web/config/environments/development.rb | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ruby/lib/jam_ruby/app/views/layouts/user_mailer_beta.html.erb b/ruby/lib/jam_ruby/app/views/layouts/user_mailer_beta.html.erb index ae24e13b6..58824245a 100644 --- a/ruby/lib/jam_ruby/app/views/layouts/user_mailer_beta.html.erb +++ b/ruby/lib/jam_ruby/app/views/layouts/user_mailer_beta.html.erb @@ -18,7 +18,7 @@ " >
- " alt="JamKazam" /> + " alt="JamKazam" />
<%= yield %> @@ -38,21 +38,21 @@

<% end -%>

diff --git a/web/config/environments/development.rb b/web/config/environments/development.rb index b2f52c386..5de879b92 100644 --- a/web/config/environments/development.rb +++ b/web/config/environments/development.rb @@ -123,7 +123,7 @@ SampleApp::Application.configure do config.session_cookie_domain = ".jamkazam.local" - config.action_controller.asset_host = 'http://localhost:3000' + config.action_controller.asset_host = 'http://www.jamkazam.local:3000/assets' config.action_mailer.asset_host = config.action_controller.asset_host config.send_user_match_mail_only_to_jamkazam_team = false From c42dfdbb30283552c3139cd9721abca6ea7d090c Mon Sep 17 00:00:00 2001 From: Nuwan Date: Sun, 10 Nov 2024 21:10:08 +0530 Subject: [PATCH 6/7] session history pagination --- .../components/page/JKMusicSessionsHistory.js | 14 +++-- .../sessions/JKSessionsHistoryItem.js | 52 +++++++++++++------ .../sessions/JKSessionsHistoryList.js | 20 ++++++- .../sessions/JKSessionsHistorySwiper.js | 5 +- .../components/sessions/JKUseSessionHelper.js | 18 ++++--- 5 files changed, 79 insertions(+), 30 deletions(-) diff --git a/jam-ui/src/components/page/JKMusicSessionsHistory.js b/jam-ui/src/components/page/JKMusicSessionsHistory.js index 6bb972889..33df2ae27 100644 --- a/jam-ui/src/components/page/JKMusicSessionsHistory.js +++ b/jam-ui/src/components/page/JKMusicSessionsHistory.js @@ -17,7 +17,7 @@ const JKMusicSessionsHistory = () => { const sessions = useSelector(state => state.sessionsHistory.sessions); const loadingStatus = useSelector(state => state.sessionsHistory.status); const [offset, setOffset] = useState(0); - const LIMIT = 10; + const LIMIT = 50; useEffect(() => { const options = { @@ -27,6 +27,10 @@ const JKMusicSessionsHistory = () => { dispatch(fetchSessionsHistory(options)); }, [offset]); + const handleNextPage = () => { + setOffset(offset + LIMIT); + }; + return ( @@ -38,12 +42,16 @@ const JKMusicSessionsHistory = () => { {greaterThan.sm ? (

- +
) : ( - + )} diff --git a/jam-ui/src/components/sessions/JKSessionsHistoryItem.js b/jam-ui/src/components/sessions/JKSessionsHistoryItem.js index aa885dd5f..4e26eaf57 100644 --- a/jam-ui/src/components/sessions/JKSessionsHistoryItem.js +++ b/jam-ui/src/components/sessions/JKSessionsHistoryItem.js @@ -6,33 +6,53 @@ import JKInstrumentIcon from '../profile/JKInstrumentIcon'; import JKSessionUser from './JKSessionUser'; import JKUserLatencyBadge from '../profile/JKUserLatencyBadge'; import { useTranslation } from 'react-i18next'; +import { useAuth } from '../../context/UserAuth'; +import { fetchUserLatencies } from '../../store/features/latencySlice'; const JKSessionsHistoryItem = ({ session_id, sessionGroup }) => { const { greaterThan } = useResponsive(); const { sessionDescription, sessionDateTime } = useSessionHelper(sessionGroup[0]); const [participants, setParticipants] = useState([]); const { t } = useTranslation(); + const { currentUser } = useAuth(); useEffect(() => { + console.log('sessionGroup', sessionGroup); setParticipants( - sessionGroup.map(history => ({ - id: history.user_id, - user: { + sessionGroup.map(history => { + const participant = { id: history.user_id, - photo_url: history.photo_url, - first_name: history.first_name, - last_name: history.last_name, - name: `${history.first_name} ${history.last_name}` - }, - tracks: history.instruments.split('|').map((instrument, index) => ({ - id: index, - instrument_id: instrument, - instrument: instrument - })) - })) + user: { + id: history.user_id, + photo_url: history.photo_url, + first_name: history.first_name, + last_name: history.last_name, + name: `${history.first_name} ${history.last_name}` + } + }; + if (history.instrments) { + participant.tracks = history.instrments.split('|').map((instrument, index) => ({ + id: index, + instrument_id: instrument, + instrument: instrument + })); + } + + return participant; + }) ); }, [sessionGroup]); + + useEffect(() => { + console.log('participants', participants); + if (participants.length > 0 && currentUser) { + const currentUserId = currentUser.id; + const otherUserIds = participants.filter(p => p.id !== currentUserId).map(p => p.id); + fetchUserLatencies({ otherUserIds, currentUserId }); + } + }, [participants]); + // const formattedDate = date => { // const d = new Date(date); // return d.toLocaleDateString('en-us', { @@ -73,7 +93,7 @@ const JKSessionsHistoryItem = ({ session_id, sessionGroup }) => { ))} - {participants.map(participant => ( + {participants.filter(p => p.user.id !== currentUser.id).map(participant => ( @@ -85,7 +105,7 @@ const JKSessionsHistoryItem = ({ session_id, sessionGroup }) => { {participants.map(participant => ( - {participant.tracks.map(track => ( + {participant.tracks && participant.tracks.map(track => ( { +const JKSessionsHistoryList = ({ sessions, onNextPage, isLoading }) => { const sessionsById = groupByKey(sessions, 'session_id'); const { t } = useTranslation(); @@ -31,8 +32,23 @@ const JKSessionsHistoryList = ({ sessions }) => { ))} + ); }; +JKSessionsHistoryList.propTypes = { + sessions: PropTypes.array.isRequired, + onNextPage: PropTypes.func.isRequired, + isLoading: PropTypes.bool +}; + export default JKSessionsHistoryList; diff --git a/jam-ui/src/components/sessions/JKSessionsHistorySwiper.js b/jam-ui/src/components/sessions/JKSessionsHistorySwiper.js index 2f843ee24..1aabab7e3 100644 --- a/jam-ui/src/components/sessions/JKSessionsHistorySwiper.js +++ b/jam-ui/src/components/sessions/JKSessionsHistorySwiper.js @@ -20,7 +20,7 @@ import { Card, CardBody, CardHeader } from 'reactstrap'; SwiperCore.use([Navigation, Pagination, Scrollbar, A11y]); -const JKSessionsHistorySwiper = ({ sessions }) => { +const JKSessionsHistorySwiper = ({ sessions, onNextPage }) => { const sessionsById = groupByKey(sessions, 'session_id'); const { t } = useTranslation(); @@ -32,7 +32,7 @@ const JKSessionsHistorySwiper = ({ sessions }) => { //onSlideChange={() => console.log('slide change')} onSlideNextTransitionEnd={swiper => { if(swiper.isEnd){ - //goNextPage() + onNextPage() } }} pagination={{ @@ -68,6 +68,7 @@ const JKSessionsHistorySwiper = ({ sessions }) => { JKSessionsHistorySwiper.propTypes = { sessions: PropTypes.arrayOf(PropTypes.instanceOf(Object)).isRequired, + onNextPage: PropTypes.func.isRequired }; export default JKSessionsHistorySwiper; diff --git a/jam-ui/src/components/sessions/JKUseSessionHelper.js b/jam-ui/src/components/sessions/JKUseSessionHelper.js index d78beaa07..6b8521d42 100644 --- a/jam-ui/src/components/sessions/JKUseSessionHelper.js +++ b/jam-ui/src/components/sessions/JKUseSessionHelper.js @@ -18,13 +18,17 @@ const useSessionHelper = (session) => { const sessionDateTime = session => { const date = new Date(session.created_at); const d = new Date(date); - return d.toLocaleDateString('en-us', { - weekday: 'long', - year: 'numeric', - month: 'short', - day: 'numeric', - timeZoneName: 'short' - }); + // return d.toLocaleDateString('en-us', { + // weekday: 'long', + // year: 'numeric', + // month: 'short', + // day: 'numeric', + // timeZoneName: 'short' + // }); + return new Intl.DateTimeFormat('en-US', { + dateStyle: 'full', + timeStyle: 'long', + }).format(date); }; return { From b9eff8dac0befbd3659dfe3aaed6fadfca099684 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Mon, 11 Nov 2024 00:42:34 +0530 Subject: [PATCH 7/7] debug session history participat letancy --- jam-ui/src/components/profile/JKUserLatencyBadge.js | 6 +++++- jam-ui/src/components/sessions/JKSessionsHistoryItem.js | 5 +++-- jam-ui/src/store/features/latencySlice.js | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/jam-ui/src/components/profile/JKUserLatencyBadge.js b/jam-ui/src/components/profile/JKUserLatencyBadge.js index 4b64d883c..c7ff9bdfc 100644 --- a/jam-ui/src/components/profile/JKUserLatencyBadge.js +++ b/jam-ui/src/components/profile/JKUserLatencyBadge.js @@ -17,6 +17,10 @@ const JKUserLatency = ({user, showAll, showBadgeOnly}) => { ); }; -JKUserLatency.propTypes = { user: PropTypes.object.isRequired }; +JKUserLatency.propTypes = { + user: PropTypes.object.isRequired, + showAll: PropTypes.bool, + showBadgeOnly: PropTypes.bool +}; export default JKUserLatency; diff --git a/jam-ui/src/components/sessions/JKSessionsHistoryItem.js b/jam-ui/src/components/sessions/JKSessionsHistoryItem.js index 4e26eaf57..dff006d0c 100644 --- a/jam-ui/src/components/sessions/JKSessionsHistoryItem.js +++ b/jam-ui/src/components/sessions/JKSessionsHistoryItem.js @@ -45,11 +45,12 @@ const JKSessionsHistoryItem = ({ session_id, sessionGroup }) => { useEffect(() => { - console.log('participants', participants); + if (participants.length > 0 && currentUser) { const currentUserId = currentUser.id; const otherUserIds = participants.filter(p => p.id !== currentUserId).map(p => p.id); - fetchUserLatencies({ otherUserIds, currentUserId }); + console.log('X_DEBUG_ JKSessionsHistoryItem', currentUserId, otherUserIds); + fetchUserLatencies({ currentUserId, otherUserIds}); } }, [participants]); diff --git a/jam-ui/src/store/features/latencySlice.js b/jam-ui/src/store/features/latencySlice.js index 111e32dce..49f5e0ce1 100644 --- a/jam-ui/src/store/features/latencySlice.js +++ b/jam-ui/src/store/features/latencySlice.js @@ -11,6 +11,7 @@ export const fetchUserLatencies = createAsyncThunk( 'latency/fetchUserLatencies', async (options, thunkAPI) => { const { currentUserId, otherUserIds } = options + console.log('X_DEBUG_ fetchUserLatencies', currentUserId, otherUserIds) const response = await getLatencyToUsers(currentUserId, otherUserIds) return response.json() }