A platform for community discussion. Free, open, simple.
FIX: avoid intermediate state when rebaking posts with oneboxes (#36567)
Régis Hanol64cf6772f195
diff --git a/app/models/post.rb b/app/models/post.rbindex 77604efdbb7..78624a14123 100644--- a/app/models/post.rb+++ b/app/models/post.rb@@ -847,7 +847,10 @@ class Post < ActiveRecord::Base# make sure we trigger the post processtrigger_post_process(bypass_bump: true, priority: priority)- publish_change_to_clients!(:rebaked)+ # Skip publishing if invalidating oneboxes - the ProcessPost job will+ # publish :revised after fetching fresh oneboxes, avoiding an intermediate+ # state where raw links are shown before oneboxes are loaded.+ publish_change_to_clients!(:rebaked) unless invalidate_oneboxesnew_cooked != old_cookedenddiff --git a/plugins/discourse-github/assets/stylesheets/common/github-pr-status.scss b/plugins/discourse-github/assets/stylesheets/common/github-pr-status.scssindex a56844b0ccd..3bce0f9a123 100644--- a/plugins/discourse-github/assets/stylesheets/common/github-pr-status.scss+++ b/plugins/discourse-github/assets/stylesheets/common/github-pr-status.scss@@ -1,5 +1,9 @@@use "lib/viewport";+$icon-aspect-ratio: calc(12 / 16);+$icon-width: 2.5em;+$icon-width-mobile: 1.8em;+.onebox.githubpullrequest .github-row {--gh-icon-draft: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 14a2.25 2.25 0 1 1 0-4.5 2.25 2.25 0 0 1 0 4.5ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM14 4.25a.75.75 0 0 1-.75.75h-2a.75.75 0 0 1 0-1.5h2a.75.75 0 0 1 .75.75Zm-.75 3.75a.75.75 0 0 0 0-1.5h-2a.75.75 0 0 0 0 1.5Z'/%3E%3C/svg%3E");--gh-icon-open: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z'/%3E%3C/svg%3E");@@ -20,6 +24,13 @@align-self: center;justify-self: center;+ // Fixed height prevents layout shift when status icon changes+ min-height: calc($icon-width / $icon-aspect-ratio);++ @include viewport.until(sm) {+ min-height: calc($icon-width-mobile / $icon-aspect-ratio);+ }+.github-icon {display: none;}@@ -27,14 +38,14 @@&::before {content: "";display: block;- width: 2.5em;- aspect-ratio: 12 / 16;+ width: $icon-width;+ aspect-ratio: $icon-aspect-ratio;mask-size: 100% 100%;mask-repeat: no-repeat;mask-position: center;@include viewport.until(sm) {- width: 1.8em;+ width: $icon-width-mobile;}}}diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rbindex 13097b21647..371e94fa6ac 100644--- a/spec/models/post_spec.rb+++ b/spec/models/post_spec.rb@@ -1365,6 +1365,12 @@ RSpec.describe Post dopost.rebake!end+ it "does not publish to clients when invalidating oneboxes" do+ post = create_post+ post.expects(:publish_change_to_clients!).never+ post.rebake!(invalidate_oneboxes: true)+ end+it "uses inline onebox cache by default" doJobs.run_immediately!stub_request(:get, "http://testonebox.com/vvf").to_return(status: 200, body: <<~HTML)