Skip to content

Commit

Permalink
Merge pull request #195 from kufu/hotfix/friend
Browse files Browse the repository at this point in the history
Don't use string date!!!!!!!!!!
  • Loading branch information
kinoppyd authored May 14, 2024
2 parents 35542db + 8a81f12 commit 1b25ae1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/javascript/controllers/friend_code_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Controller } from "@hotwired/stimulus"
// Connects to data-controller="friend-code"
export default class extends Controller {
static targets = ['counter']
static values = { expiresAt: String }
static values = { expiresAt: Number }

connect() {
this.calc();
Expand All @@ -17,7 +17,7 @@ export default class extends Controller {
}

calc () {
const expiresAt = Date.parse(this.expiresAtValue);
const expiresAt = new Date(this.expiresAtValue);
const now = Date.now();

if (now < expiresAt) {
Expand Down
4 changes: 2 additions & 2 deletions app/views/friends/_qrcode.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="w-full">
<%= @qrcode.html_safe %>
<div class="flex flex-col w-full mt-4" data-controller="friend-code" data-friend-code-expires-at-value="<%= @trigger.expires_at %>">
<div class="flex flex-col w-full mt-4" data-controller="friend-code" data-friend-code-expires-at-value="<%= @trigger.expires_at.to_i * 1000 %>">
<p>expires in <span data-friend-code-target="counter"></span> seconds</p>
<a href="<%= new_profile_friend_path %>" class="normal-button mr-2"><%= I18n.t('button.reload') %></a>
</div>
</div>
</div>

0 comments on commit 1b25ae1

Please sign in to comment.