diff --git a/Gemfile b/Gemfile index a927d2e08..6eed6e153 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,6 @@ gem "importmap-rails" gem "propshaft" gem "stimulus-rails" gem "turbo-rails" -gem "local_time" # Deployment and drivers gem "bootsnap", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 1526749a3..2a1789a26 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -145,7 +145,6 @@ GEM reline (>= 0.4.2) json (2.7.2) language_server-protocol (3.17.0.3) - local_time (3.0.2) logger (1.6.1) loofah (2.22.0) crass (~> 1.0.2) @@ -327,7 +326,6 @@ DEPENDENCIES capybara debug importmap-rails - local_time propshaft puma (>= 5.0) rails! diff --git a/app/javascript/application.js b/app/javascript/application.js index e917b49c5..0d7b49404 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -1,4 +1,3 @@ // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails import "@hotwired/turbo-rails" -import "initializers" import "controllers" diff --git a/app/javascript/controllers/animation_controller.js b/app/javascript/controllers/animation_controller.js index 9fd0998d8..a6fe306a2 100644 --- a/app/javascript/controllers/animation_controller.js +++ b/app/javascript/controllers/animation_controller.js @@ -1,5 +1,5 @@ import { Controller } from "@hotwired/stimulus" -import { nextFrame } from "helpers" +import { nextFrame } from "helpers/timing_helpers" export default class extends Controller { static classes = [ "play" ] diff --git a/app/javascript/controllers/filter_controller.js b/app/javascript/controllers/filter_controller.js index 953ae3a29..815b05952 100644 --- a/app/javascript/controllers/filter_controller.js +++ b/app/javascript/controllers/filter_controller.js @@ -1,5 +1,5 @@ import { Controller } from "@hotwired/stimulus" -import { debounce } from "helpers" +import { debounce } from "helpers/timing_helpers" export default class extends Controller { static targets = [ "list" ] diff --git a/app/javascript/controllers/thread_controller.js b/app/javascript/controllers/thread_controller.js deleted file mode 100644 index 0671c8361..000000000 --- a/app/javascript/controllers/thread_controller.js +++ /dev/null @@ -1,13 +0,0 @@ -import { Controller } from "@hotwired/stimulus" - -export default class extends Controller { - static classes = [ "myComment" ] - - connect() { - this.#myComments.forEach(comment => comment.classList.add(this.myCommentClass)) - } - - get #myComments() { - return this.element.querySelectorAll(`.comment[data-creator-id='${Current.user.id}']`) - } -} diff --git a/app/javascript/helpers/index.js b/app/javascript/helpers/index.js deleted file mode 100644 index c33ab8c40..000000000 --- a/app/javascript/helpers/index.js +++ /dev/null @@ -1 +0,0 @@ -export * from "helpers/timing_helpers" diff --git a/app/javascript/initializers/current.js b/app/javascript/initializers/current.js deleted file mode 100644 index 96ace04b5..000000000 --- a/app/javascript/initializers/current.js +++ /dev/null @@ -1,15 +0,0 @@ -class Current { - get user() { - const currentUserId = this.#extractContentFromMetaTag("current-user-id") - - if (currentUserId) { - return { id: parseInt(currentUserId) } - } - } - - #extractContentFromMetaTag(name) { - return document.head.querySelector(`meta[name="${name}"]`)?.getAttribute("content") - } -} - -window.Current = new Current() diff --git a/app/javascript/initializers/index.js b/app/javascript/initializers/index.js deleted file mode 100644 index c86bbda03..000000000 --- a/app/javascript/initializers/index.js +++ /dev/null @@ -1,2 +0,0 @@ -import "initializers/current" -import "initializers/local_time" diff --git a/app/javascript/initializers/local_time.js b/app/javascript/initializers/local_time.js deleted file mode 100644 index 8b294a5d5..000000000 --- a/app/javascript/initializers/local_time.js +++ /dev/null @@ -1,2 +0,0 @@ -import LocalTime from "local-time" -LocalTime.start() diff --git a/app/models/bubble/thread.rb b/app/models/bubble/thread.rb index a87a4d4d3..8b0e28be5 100644 --- a/app/models/bubble/thread.rb +++ b/app/models/bubble/thread.rb @@ -13,10 +13,6 @@ class Bubble::Thread "bubbles/threads/thread" end - def cache_key - ActiveSupport::Cache.expand_cache_key bubble, :thread - end - private delegate :events, :comments, to: :bubble, private: true diff --git a/app/models/bubble/thread/rollup.rb b/app/models/bubble/thread/rollup.rb index 89d3d76b5..e98f8a00e 100644 --- a/app/models/bubble/thread/rollup.rb +++ b/app/models/bubble/thread/rollup.rb @@ -13,14 +13,10 @@ class Bubble::Thread::Rollup "bubbles/threads/rollup" end - def cache_key - ActiveSupport::Cache.expand_cache_key [ thread, entries.first, entries.last ], "rollup" - end - private attr_reader :thread, :entries, :first_position - delegate :local_time_ago, to: "ApplicationController.helpers", private: true + delegate :time_ago_in_words, to: "ApplicationController.helpers", private: true def first_position? first_position @@ -47,10 +43,10 @@ class Bubble::Thread::Rollup def summarize(entry, chunk_size) case entry.action when "created" - "added by #{entry.creator.name} #{local_time_ago(entry.created_at)}" + "added by #{entry.creator.name} #{time_ago_in_words(entry.created_at)} ago" when "assigned" summary = "assigned to #{entry.assignee_names.to_sentence}" - summary += " #{local_time_ago(entry.created_at)}" unless first_position? + summary += " #{time_ago_in_words(entry.created_at)} ago" unless first_position? summary when "boosted" "#{entry.creator.name} +#{chunk_size}" diff --git a/app/views/bubbles/threads/_entry.html.erb b/app/views/bubbles/threads/_entry.html.erb deleted file mode 100644 index f299a3e08..000000000 --- a/app/views/bubbles/threads/_entry.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -<%# Template Dependency: comments/comment %> -<%# Template Dependency: bubbles/threads/rollup %> -<%= render entry %> diff --git a/app/views/bubbles/threads/_rollup.html.erb b/app/views/bubbles/threads/_rollup.html.erb index aec078644..adbfd5138 100644 --- a/app/views/bubbles/threads/_rollup.html.erb +++ b/app/views/bubbles/threads/_rollup.html.erb @@ -1,3 +1,3 @@
- <%= rollup.body.html_safe %> + <%= rollup.body %>
diff --git a/app/views/bubbles/threads/_thread.html.erb b/app/views/bubbles/threads/_thread.html.erb index 7573722e5..9d8103bb1 100644 --- a/app/views/bubbles/threads/_thread.html.erb +++ b/app/views/bubbles/threads/_thread.html.erb @@ -1,13 +1,6 @@ <% bubble = thread.bubble %> -
- <% cache thread do %> - <%= render partial: "bubbles/threads/entry", collection: thread.entries, cache: true %> - <% end %> - +
+ <%= render thread.entries %> <%= render "comments/new", bubble: bubble %>
diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index 1492a6a23..0cd298ab3 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -1,4 +1,4 @@ -
+<%= tag.div id: dom_id(comment), class: [ "comment flex align-start full-width", { "comment--mine": Current.user == comment.creator } ] do %>
<%= avatar_tag comment.creator, loading: :lazy %>
@@ -16,4 +16,4 @@ <%= simple_format comment.body %>
- +<% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 84908c22d..f75b3e64c 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -9,10 +9,6 @@ <%= csrf_meta_tags %> <%= csp_meta_tag %> - <% if Current.user %> - - <% end %> - <%= yield :head %> <%= stylesheet_link_tag :all, "data-turbo-track": "reload" %> diff --git a/config/importmap.rb b/config/importmap.rb index f7807adc1..768403738 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -4,8 +4,6 @@ pin "application" pin "@hotwired/turbo-rails", to: "turbo.min.js" pin "@hotwired/stimulus", to: "stimulus.min.js" pin "@hotwired/stimulus-loading", to: "stimulus-loading.js" -pin "local-time" # @3.0.2 -pin_all_from "app/javascript/initializers", under: "initializers" pin_all_from "app/javascript/controllers", under: "controllers" pin_all_from "app/javascript/helpers", under: "helpers" diff --git a/vendor/javascript/local-time.js b/vendor/javascript/local-time.js deleted file mode 100644 index 64d6e7995..000000000 --- a/vendor/javascript/local-time.js +++ /dev/null @@ -1,4 +0,0 @@ -// local-time@3.0.2 downloaded from https://ga.jspm.io/npm:local-time@3.0.2/app/assets/javascripts/local-time.es2017-esm.js - -var t;t={config:{},run:function(){return this.getController().processElements()},process:function(...t){var e,r,a;for(r=0,a=t.length;r11?"pm":"am")).toUpperCase();case"P":return M("time."+(n>11?"pm":"am"));case"S":return p(o,l);case"w":return a;case"y":return p(u%100,l);case"Y":return u;case"Z":return S(t)}}))},p=function(t,e){return"-"===e?t:`0${t}`.slice(-2)},S=function(t){var e,r,a;return(r=h(t))?g[r]:(a=y(t,{allowGMT:!1}))||(a=v(t))?a:(e=y(t,{allowGMT:!0}))?e:""},h=function(t){return Object.keys(g).find((function(e){return b?new Date(t).toLocaleString("en-US",{timeZoneName:"long"}).includes(e):t.toString().includes(e)}))},y=function(t,{allowGMT:e}){var r;if(b&&(r=new Date(t).toLocaleString("en-US",{timeZoneName:"short"}).split(" ").pop(),e||!r.includes("GMT")))return r},v=function(t){var e,r,a,n,s;return(e=null!=(r=(s=t.toString()).match(/\(([\w\s]+)\)$/))?r[1]:void 0)?/\s/.test(e)?e.match(/\b(\w)/g).join(""):e:(e=null!=(a=s.match(/(\w{3,4})\s\d{4}$/))?a[1]:void 0)||(e=null!=(n=s.match(/(UTC[\+\-]\d+)/))?n[1]:void 0)?e:void 0},L.CalendarDate=class{static fromDate(t){return new this(t.getFullYear(),t.getMonth()+1,t.getDate())}static today(){return this.fromDate(new Date)}constructor(t,e,r){this.date=new Date(Date.UTC(t,e-1)),this.date.setUTCDate(r),this.year=this.date.getUTCFullYear(),this.month=this.date.getUTCMonth()+1,this.day=this.date.getUTCDate(),this.value=this.date.getTime()}equals(t){return(null!=t?t.value:void 0)===this.value}is(t){return this.equals(t)}isToday(){return this.is(this.constructor.today())}occursOnSameYearAs(t){return this.year===(null!=t?t.year:void 0)}occursThisYear(){return this.occursOnSameYearAs(this.constructor.today())}daysSince(t){if(t)return(this.date-t.date)/864e5}daysPassed(){return this.constructor.today().daysSince(this)}},({strftime:E,translate:I,getI18nValue:w,config:D}=L),L.RelativeTime=class{constructor(t){this.date=t,this.calendarDate=L.CalendarDate.fromDate(this.date)}toString(){var t,e;return(e=this.toTimeElapsedString())?I("time.elapsed",{time:e}):(t=this.toWeekdayString())?(e=this.toTimeString(),I("datetime.at",{date:t,time:e})):I("date.on",{date:this.toDateString()})}toTimeOrDateString(){return this.calendarDate.isToday()?this.toTimeString():this.toDateString()}toTimeElapsedString(){var t,e,r,a,n;return r=(new Date).getTime()-this.date.getTime(),a=Math.round(r/1e3),e=Math.round(a/60),t=Math.round(e/60),r<0?null:a<10?(n=I("time.second"),I("time.singular",{time:n})):a<45?`${a} ${I("time.seconds")}`:a<90?(n=I("time.minute"),I("time.singular",{time:n})):e<45?`${e} ${I("time.minutes")}`:e<90?(n=I("time.hour"),I("time.singularAn",{time:n})):t<24?`${t} ${I("time.hours")}`:""}toWeekdayString(){switch(this.calendarDate.daysPassed()){case 0:return I("date.today");case 1:return I("date.yesterday");case-1:return I("date.tomorrow");case 2:case 3:case 4:case 5:case 6:return E(this.date,"%A");default:return""}}toDateString(){var t;return t=this.calendarDate.occursThisYear()?w("date.formats.thisYear"):w("date.formats.default"),E(this.date,t)}toTimeString(){var t;return t=D.useFormat24?"default_24h":"default",E(this.date,w(`time.formats.${t}`))}},({elementMatchesSelector:C}=L),L.PageObserver=class{constructor(t,e){this.processMutations=this.processMutations.bind(this),this.processInsertion=this.processInsertion.bind(this),this.selector=t,this.callback=e}start(){if(!this.started)return this.observeWithMutationObserver()||this.observeWithMutationEvent(),this.started=!0}observeWithMutationObserver(){if("undefined"!=typeof MutationObserver&&null!==MutationObserver)return new MutationObserver(this.processMutations).observe(document.documentElement,{childList:!0,subtree:!0}),!0}observeWithMutationEvent(){return addEventListener("DOMNodeInserted",this.processInsertion,!1),!0}findSignificantElements(t){var e;return e=[],(null!=t?t.nodeType:void 0)===Node.ELEMENT_NODE&&(C(t,this.selector)&&e.push(t),e.push(...t.querySelectorAll(this.selector))),e}processMutations(t){var e,r,a,n,s,i,o,u;for(e=[],r=0,n=t.length;r