Skip to content

Commit 871e4c0

Browse files
committed
Fix CI lint offenses and SSR ActionCable loading
1 parent 182bb69 commit 871e4c0

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

client/app/bundles/comments/components/CommentBox/CommentBox.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import Immutable from 'immutable';
44
import _ from 'lodash';
5-
import * as ActionCable from '@rails/actioncable';
65
import { injectIntl } from 'react-intl';
76
import BaseComponent from 'libs/components/BaseComponent';
87
import actionCableUrl from 'libs/actionCableUrl';
@@ -36,6 +35,11 @@ class CommentBox extends BaseComponent {
3635

3736
subscribeChannel() {
3837
const { messageReceived } = this.props.actions;
38+
39+
// Avoid loading ActionCable during server-side rendering.
40+
// eslint-disable-next-line global-require
41+
const actionCableModule = require('@rails/actioncable');
42+
const ActionCable = actionCableModule.default || actionCableModule;
3943
this.cable = ActionCable.createConsumer(actionCableUrl());
4044

4145
/* eslint no-console: ["error", { allow: ["log"] }] */
@@ -62,7 +66,7 @@ class CommentBox extends BaseComponent {
6266
}
6367

6468
componentWillUnmount() {
65-
this.cable.subscriptions.remove({ channel: 'CommentsChannel' });
69+
this.cable?.subscriptions.remove({ channel: 'CommentsChannel' });
6670
}
6771

6872
refreshComments() {

config/ci.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ module TutorialCI
99
"Build: Test assets",
1010
"RAILS_ENV=test bin/conductor-exec bin/rails react_on_rails:generate_packs && " \
1111
"bin/conductor-exec yarn res:build && " \
12-
"bin/conductor-exec yarn build:test",
12+
"bin/conductor-exec yarn build:test"
1313
],
1414
["Tests: RSpec", "bin/conductor-exec bin/rspec"],
15-
["Tests: Jest", "bin/conductor-exec yarn test:client"],
15+
["Tests: Jest", "bin/conductor-exec yarn test:client"]
1616
].freeze
1717
end

config/environments/production.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
9494

9595
# Action Cable endpoint configuration
96-
production_host = ENV["PRODUCTION_HOST"]
96+
production_host = ENV.fetch("PRODUCTION_HOST", nil)
9797
if production_host.present?
9898
config.action_cable.url = "wss://#{production_host}/cable"
9999
config.action_cable.allowed_request_origins = ["https://#{production_host}"]

0 commit comments

Comments
 (0)