@atlaskit/media-card 77.4.1 → 77.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/media-card
2
2
 
3
+ ## 77.4.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#43248](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43248) [`38b1f08a5da`](https://bitbucket.org/atlassian/atlassian-frontend/commits/38b1f08a5da) - [ux] CXP-2748 Bug fix in CardV2 so that the card correctly updates the file preview when a new identifier is passed to the component
8
+
9
+ ## 77.4.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [#43093](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43093) [`ccba4cddc23`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ccba4cddc23) - [ux] CXP-2736 Bug fix to ensure that a poster attribute is provided to videos for CardV2.
14
+
3
15
  ## 77.4.1
4
16
 
5
17
  ### Patch Changes
@@ -49,7 +49,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
49
49
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
50
50
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
51
51
  var packageName = "@atlaskit/media-card";
52
- var packageVersion = "77.4.1";
52
+ var packageVersion = "77.4.3";
53
53
  var CardBase = exports.CardBase = /*#__PURE__*/function (_Component) {
54
54
  (0, _inherits2.default)(CardBase, _Component);
55
55
  var _super = _createSuper(CardBase);
@@ -90,7 +90,7 @@ var WrappedMediaCardAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Compo
90
90
  }(_react.default.Component);
91
91
  (0, _defineProperty2.default)(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
92
92
  var packageName = "@atlaskit/media-card";
93
- var packageVersion = "77.4.1";
93
+ var packageVersion = "77.4.3";
94
94
  var MediaCardAnalyticsErrorBoundary = (0, _mediaCommon.withMediaAnalyticsContext)({
95
95
  packageVersion: packageVersion,
96
96
  packageName: packageName,
@@ -16,14 +16,16 @@ var _externalImageCard = require("./externalImageCard");
16
16
  var _fileCard = require("./fileCard");
17
17
  var _excluded = ["identifier"];
18
18
  var packageName = "@atlaskit/media-card";
19
- var packageVersion = "77.4.1";
19
+ var packageVersion = "77.4.3";
20
20
  var CardV2Base = exports.CardV2Base = function CardV2Base(_ref) {
21
21
  var identifier = _ref.identifier,
22
22
  otherProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
23
23
  var innerContent = (0, _mediaClient.isFileIdentifier)(identifier) ? /*#__PURE__*/_react.default.createElement(_fileCard.FileCard, (0, _extends2.default)({}, otherProps, {
24
- identifier: identifier
24
+ identifier: identifier,
25
+ key: identifier.id
25
26
  })) : /*#__PURE__*/_react.default.createElement(_externalImageCard.ExternalImageCard, (0, _extends2.default)({}, otherProps, {
26
- identifier: identifier
27
+ identifier: identifier,
28
+ key: identifier.dataURI
27
29
  }));
28
30
  return otherProps.intl ? innerContent : /*#__PURE__*/_react.default.createElement(_reactIntlNext.IntlProvider, {
29
31
  locale: "en"
@@ -85,10 +85,6 @@ var ExternalImageCard = exports.ExternalImageCard = function ExternalImageCard(_
85
85
  _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
86
86
  status = _useState4[0],
87
87
  setStatus = _useState4[1];
88
- (0, _react.useEffect)(function () {
89
- fireCommencedEventRef.current();
90
- setStatus('loading-preview');
91
- }, [fireCommencedEventRef, identifier]);
92
88
  var cardPreview = (0, _react.useMemo)(function () {
93
89
  return {
94
90
  dataURI: identifier.dataURI,
@@ -160,6 +156,9 @@ var ExternalImageCard = exports.ExternalImageCard = function ExternalImageCard(_
160
156
  //------------------------ useEffects ----------------------------//
161
157
  //----------------------------------------------------------------//
162
158
 
159
+ (0, _react.useEffect)(function () {
160
+ fireCommencedEventRef.current();
161
+ }, [fireCommencedEventRef]);
163
162
  (0, _react.useEffect)(function () {
164
163
  var _getDocument;
165
164
  var fireCopiedCardEvent = function fireCopiedCardEvent() {
@@ -81,19 +81,6 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
81
81
  //---------------- State Initializer Functions -------------------//
82
82
  //----------------------------------------------------------------//
83
83
 
84
- var _useFileState = (0, _mediaClientReact.useFileState)(identifier.id, {
85
- collectionName: identifier.collectionName,
86
- occurrenceKey: identifier.occurrenceKey
87
- }),
88
- fileState = _useFileState.fileState;
89
- var prevFileState = (0, _usePrevious.usePrevious)(fileState);
90
- var fileStateValue = (0, _react.useMemo)(function () {
91
- if (fileState && (fileState === null || fileState === void 0 ? void 0 : fileState.status) !== 'error') {
92
- return fileState;
93
- }
94
- return prevFileState;
95
- // eslint-disable-next-line react-hooks/exhaustive-deps
96
- }, [fileState]);
97
84
  var ssrDataRef = (0, _react.useRef)();
98
85
  var ssrReliabilityRef = (0, _react.useRef)({
99
86
  server: {
@@ -118,10 +105,10 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
118
105
  allowAnimated: true
119
106
  });
120
107
  }, [cardElement, dimensions, identifier.collectionName, resizeMode]);
121
- var mediaBlobUrlAttrs = (0, _react.useMemo)(function () {
108
+ var getMediaBlobUrlAttrs = (0, _react.useCallback)(function (fileState) {
122
109
  var id = identifier.id,
123
110
  collection = identifier.collectionName;
124
- var _getFileDetails = (0, _metadata.getFileDetails)(identifier, fileStateValue),
111
+ var _getFileDetails = (0, _metadata.getFileDetails)(identifier, fileState),
125
112
  mimeType = _getFileDetails.mimeType,
126
113
  name = _getFileDetails.name,
127
114
  size = _getFileDetails.size;
@@ -138,7 +125,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
138
125
  })), {}, {
139
126
  alt: alt
140
127
  }) : undefined;
141
- }, [alt, cardElement, contextId, dimensions, fileStateValue, identifier, originalDimensions]);
128
+ }, [alt, cardElement, contextId, dimensions, identifier, originalDimensions]);
142
129
  var getSSRPreview = function getSSRPreview(ssr, identifier, mediaClient) {
143
130
  var _ssrDataRef$current, _ssrDataRef$current2;
144
131
  ssrDataRef.current = (0, _globalScope.getSSRData)(identifier);
@@ -149,7 +136,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
149
136
  }
150
137
  if (!((_ssrDataRef$current2 = ssrDataRef.current) !== null && _ssrDataRef$current2 !== void 0 && _ssrDataRef$current2.dataURI)) {
151
138
  try {
152
- return (0, _getCardPreview.getSSRCardPreview)(ssr, mediaClient, identifier.id, imageURLParams, mediaBlobUrlAttrs);
139
+ return (0, _getCardPreview.getSSRCardPreview)(ssr, mediaClient, identifier.id, imageURLParams, getMediaBlobUrlAttrs(fileStateValue));
153
140
  } catch (e) {
154
141
  ssrReliabilityRef.current[ssr] = _objectSpread({
155
142
  status: 'fail'
@@ -172,6 +159,35 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
172
159
  }
173
160
  return cardPreview;
174
161
  };
162
+ var _useState3 = (0, _react.useState)(cardPreviewInitializer),
163
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
164
+ cardPreview = _useState4[0],
165
+ setCardPreview = _useState4[1];
166
+
167
+ // If cardPreview is available from local cache or external, `isCardVisible`
168
+ // should be true to avoid flickers during re-mount of the component
169
+ // should not be visible for SSR preview, otherwise we'll fire the metadata fetch from
170
+ // outside the viewport
171
+ var _useState5 = (0, _react.useState)(function () {
172
+ return !isLazy || cardPreview && !(0, _getCardPreview.isSSRPreview)(cardPreview);
173
+ }),
174
+ _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
175
+ isCardVisible = _useState6[0],
176
+ setIsCardVisible = _useState6[1];
177
+ var _useFileState = (0, _mediaClientReact.useFileState)(identifier.id, {
178
+ skipRemote: !isCardVisible,
179
+ collectionName: identifier.collectionName,
180
+ occurrenceKey: identifier.occurrenceKey
181
+ }),
182
+ fileState = _useFileState.fileState;
183
+ var prevFileState = (0, _usePrevious.usePrevious)(fileState);
184
+ var fileStateValue = (0, _react.useMemo)(function () {
185
+ if (fileState && (fileState === null || fileState === void 0 ? void 0 : fileState.status) !== 'error') {
186
+ return fileState;
187
+ }
188
+ return prevFileState;
189
+ // eslint-disable-next-line react-hooks/exhaustive-deps
190
+ }, [fileState]);
175
191
 
176
192
  //----------------------------------------------------------------//
177
193
  //------------ State, Refs & Initial Values ----------------------//
@@ -194,28 +210,10 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
194
210
  traceId: (0, _mediaCommon.getRandomHex)(8)
195
211
  };
196
212
  }, []);
197
- var _useState3 = (0, _react.useState)('loading'),
198
- _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
199
- status = _useState4[0],
200
- setStatus = _useState4[1];
201
- (0, _react.useEffect)(function () {
202
- setStatus('loading');
203
- }, [identifier]);
204
- var _useState5 = (0, _react.useState)(cardPreviewInitializer),
205
- _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
206
- cardPreview = _useState6[0],
207
- setCardPreview = _useState6[1];
208
-
209
- // If cardPreview is available from local cache or external, `isCardVisible`
210
- // should be true to avoid flickers during re-mount of the component
211
- // should not be visible for SSR preview, otherwise we'll fire the metadata fetch from
212
- // outside the viewport
213
- var _useState7 = (0, _react.useState)(function () {
214
- return !isLazy || !!cardPreview && !(0, _getCardPreview.isSSRPreview)(cardPreview);
215
- }),
213
+ var _useState7 = (0, _react.useState)('loading'),
216
214
  _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
217
- isCardVisible = _useState8[0],
218
- setIsCardVisible = _useState8[1];
215
+ status = _useState8[0],
216
+ setStatus = _useState8[1];
219
217
  var _useState9 = (0, _react.useState)(false),
220
218
  _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
221
219
  isPlayingFile = _useState10[0],
@@ -440,11 +438,11 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
440
438
  //----------------------------------------------------------------//
441
439
 
442
440
  var fetchRemotePreviewRef = (0, _useCurrentValueRef.useCurrentValueRef)(function (identifier) {
443
- return (0, _getCardPreview.fetchAndCacheRemotePreview)(mediaClient, identifier.id, dimensions !== null && dimensions !== void 0 ? dimensions : {}, imageURLParams, mediaBlobUrlAttrs);
441
+ return (0, _getCardPreview.fetchAndCacheRemotePreview)(mediaClient, identifier.id, dimensions !== null && dimensions !== void 0 ? dimensions : {}, imageURLParams, getMediaBlobUrlAttrs(fileStateValue));
444
442
  });
445
443
  var resolvePreviewRef = (0, _useCurrentValueRef.useCurrentValueRef)( /*#__PURE__*/function () {
446
444
  var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(identifier, fileState) {
447
- var filePreview, isRemotePreviewReady, mode, cachedPreview, dimensionsAreBigger, localPreview, value, resolvedFilePreview, _value, type, mediaType, orientation, _dataURI, _dataURI2, preview, source, dataURI, remotePreview, wrappedError;
445
+ var filePreview, isRemotePreviewReady, mode, cachedPreview, dimensionsAreBigger, localPreview, value, resolvedFilePreview, _value, type, mediaType, orientation, _dataURI, _dataURI2, preview, source, mediaBlobUrlAttrs, dataURI, remotePreview, wrappedError;
448
446
  return _regenerator.default.wrap(function _callee$(_context) {
449
447
  while (1) switch (_context.prev = _context.next) {
450
448
  case 0:
@@ -462,7 +460,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
462
460
  case 8:
463
461
  _context.prev = 8;
464
462
  if (!filePreview) {
465
- _context.next = 74;
463
+ _context.next = 75;
466
464
  break;
467
465
  }
468
466
  _context.prev = 10;
@@ -568,6 +566,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
568
566
  source = preview.source;
569
567
  case 70:
570
568
  // We want to embed some meta context into dataURI for Copy/Paste to work.
569
+ mediaBlobUrlAttrs = getMediaBlobUrlAttrs(fileStateValue);
571
570
  dataURI = mediaBlobUrlAttrs ? (0, _mediaClient.addFileAttrsToUrl)(preview.dataURI, mediaBlobUrlAttrs) : preview.dataURI; // We store new cardPreview into cache
572
571
  _cache.default.set(identifier.id, mode, _objectSpread(_objectSpread({}, preview), {}, {
573
572
  source: source,
@@ -577,11 +576,11 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
577
576
  dataURI: dataURI
578
577
  }));
579
578
  return _context.abrupt("return");
580
- case 74:
581
- _context.next = 81;
579
+ case 75:
580
+ _context.next = 82;
582
581
  break;
583
- case 76:
584
- _context.prev = 76;
582
+ case 77:
583
+ _context.prev = 77;
585
584
  _context.t5 = _context["catch"](8);
586
585
  /**
587
586
  * We report the error if:
@@ -601,25 +600,25 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
601
600
  * if there is no remote preview available
602
601
  */
603
602
  if (isRemotePreviewReady) {
604
- _context.next = 81;
603
+ _context.next = 82;
605
604
  break;
606
605
  }
607
606
  throw _context.t5;
608
- case 81:
607
+ case 82:
609
608
  if (isRemotePreviewReady) {
610
- _context.next = 83;
609
+ _context.next = 84;
611
610
  break;
612
611
  }
613
612
  throw new _errors.MediaCardError('remote-preview-not-ready');
614
- case 83:
615
- _context.next = 85;
616
- return (0, _getCardPreview.fetchAndCacheRemotePreview)(mediaClient, identifier.id, dimensions !== null && dimensions !== void 0 ? dimensions : {}, imageURLParams, mediaBlobUrlAttrs, traceContext);
617
- case 85:
613
+ case 84:
614
+ _context.next = 86;
615
+ return (0, _getCardPreview.fetchAndCacheRemotePreview)(mediaClient, identifier.id, dimensions !== null && dimensions !== void 0 ? dimensions : {}, imageURLParams, getMediaBlobUrlAttrs(fileStateValue), traceContext);
616
+ case 86:
618
617
  remotePreview = _context.sent;
619
618
  setCardPreview(remotePreview);
620
619
  return _context.abrupt("return");
621
- case 90:
622
- _context.prev = 90;
620
+ case 91:
621
+ _context.prev = 91;
623
622
  _context.t6 = _context["catch"](2);
624
623
  wrappedError = (0, _errors.ensureMediaCardError)('preview-fetch', _context.t6); // If remote preview fails, we set status 'error'
625
624
  // If local preview fails (i.e, no remote preview available),
@@ -634,11 +633,11 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
634
633
  setError(wrappedError);
635
634
  }
636
635
  }
637
- case 94:
636
+ case 95:
638
637
  case "end":
639
638
  return _context.stop();
640
639
  }
641
- }, _callee, null, [[2, 90], [8, 76], [10, 17], [30, 38], [42, 49]]);
640
+ }, _callee, null, [[2, 91], [8, 77], [10, 17], [30, 38], [42, 49]]);
642
641
  }));
643
642
  return function (_x, _x2) {
644
643
  return _ref2.apply(this, arguments);
@@ -811,10 +810,16 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
811
810
  var _getFileDetails2 = (0, _metadata.getFileDetails)(identifier, fileStateValue),
812
811
  mimeType = _getFileDetails2.mimeType;
813
812
  var isVideoPlayable = (0, _videoIsPlayable.videoIsPlayable)(isBannedLocalPreview, fileStateValue, mimeType);
814
- if (isVideo && !isPlayingFile && disableOverlay && useInlinePlayer && isVideoPlayable) {
813
+ if (
814
+ /**
815
+ * We need to check that the card is visible before switching to inline player
816
+ * in order to avoid race conditions of the ViewportDector being unmounted before
817
+ * it is able to set isCardVisible to true.
818
+ */
819
+ isCardVisible && isVideo && !isPlayingFile && disableOverlay && useInlinePlayer && isVideoPlayable) {
815
820
  setIsPlayingFile(true);
816
821
  }
817
- }, [disableOverlay, fileAttributes.fileMediatype, fileStateValue, identifier, isBannedLocalPreview, isPlayingFile, useInlinePlayer]);
822
+ }, [isCardVisible, disableOverlay, fileAttributes.fileMediatype, fileStateValue, identifier, isBannedLocalPreview, isPlayingFile, useInlinePlayer]);
818
823
 
819
824
  //----------------------------------------------------------------//
820
825
  //----------------- fireScreenEvent ------------------------------//
@@ -119,7 +119,7 @@ var MediaInlineCardLoader = exports.default = /*#__PURE__*/function (_React$Pure
119
119
  ErrorBoundary = _this$state.ErrorBoundary;
120
120
  var analyticsContext = {
121
121
  packageVersion: "@atlaskit/media-card",
122
- packageName: "77.4.1",
122
+ packageName: "77.4.3",
123
123
  componentName: 'mediaInlineCard',
124
124
  component: 'mediaInlineCard'
125
125
  };
@@ -14,7 +14,7 @@ var _mediaClient = require("@atlaskit/media-client");
14
14
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
15
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
16
  var packageName = "@atlaskit/media-card";
17
- var packageVersion = "77.4.1";
17
+ var packageVersion = "77.4.3";
18
18
  var concurrentExperience;
19
19
  var getExperience = function getExperience(id) {
20
20
  if (!concurrentExperience) {
@@ -27,7 +27,7 @@ import { getMediaCardCursor } from '../utils/getMediaCardCursor';
27
27
  import { completeUfoExperience, startUfoExperience, abortUfoExperience } from '../utils/ufoExperiences';
28
28
  import { generateUniqueId } from '../utils/generateUniqueId';
29
29
  const packageName = "@atlaskit/media-card";
30
- const packageVersion = "77.4.1";
30
+ const packageVersion = "77.4.3";
31
31
  export class CardBase extends Component {
32
32
  constructor(props) {
33
33
  super(props);
@@ -66,7 +66,7 @@ class WrappedMediaCardAnalyticsErrorBoundary extends React.Component {
66
66
  }
67
67
  _defineProperty(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
68
68
  const packageName = "@atlaskit/media-card";
69
- const packageVersion = "77.4.1";
69
+ const packageVersion = "77.4.3";
70
70
  const MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
71
71
  packageVersion,
72
72
  packageName,
@@ -7,15 +7,17 @@ import { IntlProvider, injectIntl } from 'react-intl-next';
7
7
  import { ExternalImageCard } from './externalImageCard';
8
8
  import { FileCard } from './fileCard';
9
9
  const packageName = "@atlaskit/media-card";
10
- const packageVersion = "77.4.1";
10
+ const packageVersion = "77.4.3";
11
11
  export const CardV2Base = ({
12
12
  identifier,
13
13
  ...otherProps
14
14
  }) => {
15
15
  const innerContent = isFileIdentifier(identifier) ? /*#__PURE__*/React.createElement(FileCard, _extends({}, otherProps, {
16
- identifier: identifier
16
+ identifier: identifier,
17
+ key: identifier.id
17
18
  })) : /*#__PURE__*/React.createElement(ExternalImageCard, _extends({}, otherProps, {
18
- identifier: identifier
19
+ identifier: identifier,
20
+ key: identifier.dataURI
19
21
  }));
20
22
  return otherProps.intl ? innerContent : /*#__PURE__*/React.createElement(IntlProvider, {
21
23
  locale: "en"
@@ -57,10 +57,6 @@ export const ExternalImageCard = ({
57
57
  startUfoExperience(internalOccurrenceKey);
58
58
  });
59
59
  const [status, setStatus] = useState('loading-preview');
60
- useEffect(() => {
61
- fireCommencedEventRef.current();
62
- setStatus('loading-preview');
63
- }, [fireCommencedEventRef, identifier]);
64
60
  const cardPreview = useMemo(() => ({
65
61
  dataURI: identifier.dataURI,
66
62
  orientation: 1,
@@ -121,6 +117,9 @@ export const ExternalImageCard = ({
121
117
  //------------------------ useEffects ----------------------------//
122
118
  //----------------------------------------------------------------//
123
119
 
120
+ useEffect(() => {
121
+ fireCommencedEventRef.current();
122
+ }, [fireCommencedEventRef]);
124
123
  useEffect(() => {
125
124
  var _getDocument;
126
125
  const fireCopiedCardEvent = () => {
@@ -4,7 +4,7 @@ import { MediaFileStateError, useFileState } from '@atlaskit/media-client-react'
4
4
  import { getMediaTypeFromMimeType, getRandomHex, isMimeTypeSupportedByBrowser } from '@atlaskit/media-common';
5
5
  import { getOrientation } from '@atlaskit/media-ui';
6
6
  import { MediaViewer } from '@atlaskit/media-viewer';
7
- import React, { Suspense, useEffect, useMemo, useRef, useState } from 'react';
7
+ import React, { Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react';
8
8
  import ReactDOM from 'react-dom';
9
9
  import { ImageLoadError, LocalPreviewError, MediaCardError, ensureMediaCardError, isLocalPreviewError, isUnsupportedLocalPreviewError } from '../../errors';
10
10
  import { extractErrorInfo } from '../../utils/analytics';
@@ -61,20 +61,6 @@ export const FileCard = ({
61
61
  //---------------- State Initializer Functions -------------------//
62
62
  //----------------------------------------------------------------//
63
63
 
64
- const {
65
- fileState
66
- } = useFileState(identifier.id, {
67
- collectionName: identifier.collectionName,
68
- occurrenceKey: identifier.occurrenceKey
69
- });
70
- const prevFileState = usePrevious(fileState);
71
- const fileStateValue = useMemo(() => {
72
- if (fileState && (fileState === null || fileState === void 0 ? void 0 : fileState.status) !== 'error') {
73
- return fileState;
74
- }
75
- return prevFileState;
76
- // eslint-disable-next-line react-hooks/exhaustive-deps
77
- }, [fileState]);
78
64
  const ssrDataRef = useRef();
79
65
  const ssrReliabilityRef = useRef({
80
66
  server: {
@@ -94,7 +80,7 @@ export const FileCard = ({
94
80
  }),
95
81
  allowAnimated: true
96
82
  }), [cardElement, dimensions, identifier.collectionName, resizeMode]);
97
- const mediaBlobUrlAttrs = useMemo(() => {
83
+ const getMediaBlobUrlAttrs = useCallback(fileState => {
98
84
  const {
99
85
  id,
100
86
  collectionName: collection
@@ -103,7 +89,7 @@ export const FileCard = ({
103
89
  mimeType,
104
90
  name,
105
91
  size
106
- } = getFileDetails(identifier, fileStateValue);
92
+ } = getFileDetails(identifier, fileState);
107
93
  return contextId ? {
108
94
  id,
109
95
  collection,
@@ -117,7 +103,7 @@ export const FileCard = ({
117
103
  })),
118
104
  alt
119
105
  } : undefined;
120
- }, [alt, cardElement, contextId, dimensions, fileStateValue, identifier, originalDimensions]);
106
+ }, [alt, cardElement, contextId, dimensions, identifier, originalDimensions]);
121
107
  const getSSRPreview = (ssr, identifier, mediaClient) => {
122
108
  var _ssrDataRef$current, _ssrDataRef$current2;
123
109
  ssrDataRef.current = getSSRData(identifier);
@@ -129,7 +115,7 @@ export const FileCard = ({
129
115
  }
130
116
  if (!((_ssrDataRef$current2 = ssrDataRef.current) !== null && _ssrDataRef$current2 !== void 0 && _ssrDataRef$current2.dataURI)) {
131
117
  try {
132
- return getSSRCardPreview(ssr, mediaClient, identifier.id, imageURLParams, mediaBlobUrlAttrs);
118
+ return getSSRCardPreview(ssr, mediaClient, identifier.id, imageURLParams, getMediaBlobUrlAttrs(fileStateValue));
133
119
  } catch (e) {
134
120
  ssrReliabilityRef.current[ssr] = {
135
121
  status: 'fail',
@@ -155,6 +141,28 @@ export const FileCard = ({
155
141
  }
156
142
  return cardPreview;
157
143
  };
144
+ const [cardPreview, setCardPreview] = useState(cardPreviewInitializer);
145
+
146
+ // If cardPreview is available from local cache or external, `isCardVisible`
147
+ // should be true to avoid flickers during re-mount of the component
148
+ // should not be visible for SSR preview, otherwise we'll fire the metadata fetch from
149
+ // outside the viewport
150
+ const [isCardVisible, setIsCardVisible] = useState(() => !isLazy || cardPreview && !isSSRPreview(cardPreview));
151
+ const {
152
+ fileState
153
+ } = useFileState(identifier.id, {
154
+ skipRemote: !isCardVisible,
155
+ collectionName: identifier.collectionName,
156
+ occurrenceKey: identifier.occurrenceKey
157
+ });
158
+ const prevFileState = usePrevious(fileState);
159
+ const fileStateValue = useMemo(() => {
160
+ if (fileState && (fileState === null || fileState === void 0 ? void 0 : fileState.status) !== 'error') {
161
+ return fileState;
162
+ }
163
+ return prevFileState;
164
+ // eslint-disable-next-line react-hooks/exhaustive-deps
165
+ }, [fileState]);
158
166
 
159
167
  //----------------------------------------------------------------//
160
168
  //------------ State, Refs & Initial Values ----------------------//
@@ -172,16 +180,6 @@ export const FileCard = ({
172
180
  traceId: getRandomHex(8)
173
181
  }), []);
174
182
  const [status, setStatus] = useState('loading');
175
- useEffect(() => {
176
- setStatus('loading');
177
- }, [identifier]);
178
- const [cardPreview, setCardPreview] = useState(cardPreviewInitializer);
179
-
180
- // If cardPreview is available from local cache or external, `isCardVisible`
181
- // should be true to avoid flickers during re-mount of the component
182
- // should not be visible for SSR preview, otherwise we'll fire the metadata fetch from
183
- // outside the viewport
184
- const [isCardVisible, setIsCardVisible] = useState(() => !isLazy || !!cardPreview && !isSSRPreview(cardPreview));
185
183
  const [isPlayingFile, setIsPlayingFile] = useState(false);
186
184
  const [shouldAutoplay, setShouldAutoplay] = useState(false);
187
185
  const [isBannedLocalPreview, setIsBannedLocalPreview] = useState(false);
@@ -387,7 +385,7 @@ export const FileCard = ({
387
385
  //----------------------------------------------------------------//
388
386
 
389
387
  const fetchRemotePreviewRef = useCurrentValueRef(identifier => {
390
- return fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions !== null && dimensions !== void 0 ? dimensions : {}, imageURLParams, mediaBlobUrlAttrs);
388
+ return fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions !== null && dimensions !== void 0 ? dimensions : {}, imageURLParams, getMediaBlobUrlAttrs(fileStateValue));
391
389
  });
392
390
  const resolvePreviewRef = useCurrentValueRef(async (identifier, fileState) => {
393
391
  const filePreview = isBannedLocalPreview ? undefined : fileState.status !== 'error' && 'mimeType' in fileState && isMimeTypeSupportedByBrowser(fileState.mimeType) ? fileState.preview : undefined;
@@ -474,6 +472,7 @@ export const FileCard = ({
474
472
  source = preview.source;
475
473
  }
476
474
  // We want to embed some meta context into dataURI for Copy/Paste to work.
475
+ const mediaBlobUrlAttrs = getMediaBlobUrlAttrs(fileStateValue);
477
476
  const dataURI = mediaBlobUrlAttrs ? addFileAttrsToUrl(preview.dataURI, mediaBlobUrlAttrs) : preview.dataURI;
478
477
  // We store new cardPreview into cache
479
478
  cardPreviewCache.set(identifier.id, mode, {
@@ -518,7 +517,7 @@ export const FileCard = ({
518
517
  */
519
518
  throw new MediaCardError('remote-preview-not-ready');
520
519
  }
521
- const remotePreview = await fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions !== null && dimensions !== void 0 ? dimensions : {}, imageURLParams, mediaBlobUrlAttrs, traceContext);
520
+ const remotePreview = await fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions !== null && dimensions !== void 0 ? dimensions : {}, imageURLParams, getMediaBlobUrlAttrs(fileStateValue), traceContext);
522
521
  setCardPreview(remotePreview);
523
522
  return;
524
523
  } catch (e) {
@@ -691,10 +690,16 @@ export const FileCard = ({
691
690
  mimeType
692
691
  } = getFileDetails(identifier, fileStateValue);
693
692
  const isVideoPlayable = videoIsPlayable(isBannedLocalPreview, fileStateValue, mimeType);
694
- if (isVideo && !isPlayingFile && disableOverlay && useInlinePlayer && isVideoPlayable) {
693
+ if (
694
+ /**
695
+ * We need to check that the card is visible before switching to inline player
696
+ * in order to avoid race conditions of the ViewportDector being unmounted before
697
+ * it is able to set isCardVisible to true.
698
+ */
699
+ isCardVisible && isVideo && !isPlayingFile && disableOverlay && useInlinePlayer && isVideoPlayable) {
695
700
  setIsPlayingFile(true);
696
701
  }
697
- }, [disableOverlay, fileAttributes.fileMediatype, fileStateValue, identifier, isBannedLocalPreview, isPlayingFile, useInlinePlayer]);
702
+ }, [isCardVisible, disableOverlay, fileAttributes.fileMediatype, fileStateValue, identifier, isBannedLocalPreview, isPlayingFile, useInlinePlayer]);
698
703
 
699
704
  //----------------------------------------------------------------//
700
705
  //----------------- fireScreenEvent ------------------------------//
@@ -37,7 +37,7 @@ export default class MediaInlineCardLoader extends React.PureComponent {
37
37
  } = this.state;
38
38
  const analyticsContext = {
39
39
  packageVersion: "@atlaskit/media-card",
40
- packageName: "77.4.1",
40
+ packageName: "77.4.3",
41
41
  componentName: 'mediaInlineCard',
42
42
  component: 'mediaInlineCard'
43
43
  };
@@ -4,7 +4,7 @@ import { extractErrorInfo, getRenderErrorRequestMetadata } from './analytics';
4
4
  import { MediaCardError } from '../errors';
5
5
  import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
6
6
  const packageName = "@atlaskit/media-card";
7
- const packageVersion = "77.4.1";
7
+ const packageVersion = "77.4.3";
8
8
  let concurrentExperience;
9
9
  const getExperience = id => {
10
10
  if (!concurrentExperience) {
@@ -40,7 +40,7 @@ import { getMediaCardCursor } from '../utils/getMediaCardCursor';
40
40
  import { completeUfoExperience, startUfoExperience, abortUfoExperience } from '../utils/ufoExperiences';
41
41
  import { generateUniqueId } from '../utils/generateUniqueId';
42
42
  var packageName = "@atlaskit/media-card";
43
- var packageVersion = "77.4.1";
43
+ var packageVersion = "77.4.3";
44
44
  export var CardBase = /*#__PURE__*/function (_Component) {
45
45
  _inherits(CardBase, _Component);
46
46
  var _super = _createSuper(CardBase);
@@ -83,7 +83,7 @@ var WrappedMediaCardAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Compo
83
83
  }(React.Component);
84
84
  _defineProperty(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
85
85
  var packageName = "@atlaskit/media-card";
86
- var packageVersion = "77.4.1";
86
+ var packageVersion = "77.4.3";
87
87
  var MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
88
88
  packageVersion: packageVersion,
89
89
  packageName: packageName,
@@ -9,14 +9,16 @@ import { IntlProvider, injectIntl } from 'react-intl-next';
9
9
  import { ExternalImageCard } from './externalImageCard';
10
10
  import { FileCard } from './fileCard';
11
11
  var packageName = "@atlaskit/media-card";
12
- var packageVersion = "77.4.1";
12
+ var packageVersion = "77.4.3";
13
13
  export var CardV2Base = function CardV2Base(_ref) {
14
14
  var identifier = _ref.identifier,
15
15
  otherProps = _objectWithoutProperties(_ref, _excluded);
16
16
  var innerContent = isFileIdentifier(identifier) ? /*#__PURE__*/React.createElement(FileCard, _extends({}, otherProps, {
17
- identifier: identifier
17
+ identifier: identifier,
18
+ key: identifier.id
18
19
  })) : /*#__PURE__*/React.createElement(ExternalImageCard, _extends({}, otherProps, {
19
- identifier: identifier
20
+ identifier: identifier,
21
+ key: identifier.dataURI
20
22
  }));
21
23
  return otherProps.intl ? innerContent : /*#__PURE__*/React.createElement(IntlProvider, {
22
24
  locale: "en"
@@ -75,10 +75,6 @@ export var ExternalImageCard = function ExternalImageCard(_ref) {
75
75
  _useState4 = _slicedToArray(_useState3, 2),
76
76
  status = _useState4[0],
77
77
  setStatus = _useState4[1];
78
- useEffect(function () {
79
- fireCommencedEventRef.current();
80
- setStatus('loading-preview');
81
- }, [fireCommencedEventRef, identifier]);
82
78
  var cardPreview = useMemo(function () {
83
79
  return {
84
80
  dataURI: identifier.dataURI,
@@ -150,6 +146,9 @@ export var ExternalImageCard = function ExternalImageCard(_ref) {
150
146
  //------------------------ useEffects ----------------------------//
151
147
  //----------------------------------------------------------------//
152
148
 
149
+ useEffect(function () {
150
+ fireCommencedEventRef.current();
151
+ }, [fireCommencedEventRef]);
153
152
  useEffect(function () {
154
153
  var _getDocument;
155
154
  var fireCopiedCardEvent = function fireCopiedCardEvent() {
@@ -11,7 +11,7 @@ import { MediaFileStateError, useFileState } from '@atlaskit/media-client-react'
11
11
  import { getMediaTypeFromMimeType, getRandomHex, isMimeTypeSupportedByBrowser } from '@atlaskit/media-common';
12
12
  import { getOrientation } from '@atlaskit/media-ui';
13
13
  import { MediaViewer } from '@atlaskit/media-viewer';
14
- import React, { Suspense, useEffect, useMemo, useRef, useState } from 'react';
14
+ import React, { Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react';
15
15
  import ReactDOM from 'react-dom';
16
16
  import { ImageLoadError, LocalPreviewError, MediaCardError, ensureMediaCardError, isLocalPreviewError, isUnsupportedLocalPreviewError } from '../../errors';
17
17
  import { extractErrorInfo } from '../../utils/analytics';
@@ -71,19 +71,6 @@ export var FileCard = function FileCard(_ref) {
71
71
  //---------------- State Initializer Functions -------------------//
72
72
  //----------------------------------------------------------------//
73
73
 
74
- var _useFileState = useFileState(identifier.id, {
75
- collectionName: identifier.collectionName,
76
- occurrenceKey: identifier.occurrenceKey
77
- }),
78
- fileState = _useFileState.fileState;
79
- var prevFileState = usePrevious(fileState);
80
- var fileStateValue = useMemo(function () {
81
- if (fileState && (fileState === null || fileState === void 0 ? void 0 : fileState.status) !== 'error') {
82
- return fileState;
83
- }
84
- return prevFileState;
85
- // eslint-disable-next-line react-hooks/exhaustive-deps
86
- }, [fileState]);
87
74
  var ssrDataRef = useRef();
88
75
  var ssrReliabilityRef = useRef({
89
76
  server: {
@@ -108,10 +95,10 @@ export var FileCard = function FileCard(_ref) {
108
95
  allowAnimated: true
109
96
  });
110
97
  }, [cardElement, dimensions, identifier.collectionName, resizeMode]);
111
- var mediaBlobUrlAttrs = useMemo(function () {
98
+ var getMediaBlobUrlAttrs = useCallback(function (fileState) {
112
99
  var id = identifier.id,
113
100
  collection = identifier.collectionName;
114
- var _getFileDetails = getFileDetails(identifier, fileStateValue),
101
+ var _getFileDetails = getFileDetails(identifier, fileState),
115
102
  mimeType = _getFileDetails.mimeType,
116
103
  name = _getFileDetails.name,
117
104
  size = _getFileDetails.size;
@@ -128,7 +115,7 @@ export var FileCard = function FileCard(_ref) {
128
115
  })), {}, {
129
116
  alt: alt
130
117
  }) : undefined;
131
- }, [alt, cardElement, contextId, dimensions, fileStateValue, identifier, originalDimensions]);
118
+ }, [alt, cardElement, contextId, dimensions, identifier, originalDimensions]);
132
119
  var getSSRPreview = function getSSRPreview(ssr, identifier, mediaClient) {
133
120
  var _ssrDataRef$current, _ssrDataRef$current2;
134
121
  ssrDataRef.current = getSSRData(identifier);
@@ -139,7 +126,7 @@ export var FileCard = function FileCard(_ref) {
139
126
  }
140
127
  if (!((_ssrDataRef$current2 = ssrDataRef.current) !== null && _ssrDataRef$current2 !== void 0 && _ssrDataRef$current2.dataURI)) {
141
128
  try {
142
- return getSSRCardPreview(ssr, mediaClient, identifier.id, imageURLParams, mediaBlobUrlAttrs);
129
+ return getSSRCardPreview(ssr, mediaClient, identifier.id, imageURLParams, getMediaBlobUrlAttrs(fileStateValue));
143
130
  } catch (e) {
144
131
  ssrReliabilityRef.current[ssr] = _objectSpread({
145
132
  status: 'fail'
@@ -162,6 +149,35 @@ export var FileCard = function FileCard(_ref) {
162
149
  }
163
150
  return cardPreview;
164
151
  };
152
+ var _useState3 = useState(cardPreviewInitializer),
153
+ _useState4 = _slicedToArray(_useState3, 2),
154
+ cardPreview = _useState4[0],
155
+ setCardPreview = _useState4[1];
156
+
157
+ // If cardPreview is available from local cache or external, `isCardVisible`
158
+ // should be true to avoid flickers during re-mount of the component
159
+ // should not be visible for SSR preview, otherwise we'll fire the metadata fetch from
160
+ // outside the viewport
161
+ var _useState5 = useState(function () {
162
+ return !isLazy || cardPreview && !isSSRPreview(cardPreview);
163
+ }),
164
+ _useState6 = _slicedToArray(_useState5, 2),
165
+ isCardVisible = _useState6[0],
166
+ setIsCardVisible = _useState6[1];
167
+ var _useFileState = useFileState(identifier.id, {
168
+ skipRemote: !isCardVisible,
169
+ collectionName: identifier.collectionName,
170
+ occurrenceKey: identifier.occurrenceKey
171
+ }),
172
+ fileState = _useFileState.fileState;
173
+ var prevFileState = usePrevious(fileState);
174
+ var fileStateValue = useMemo(function () {
175
+ if (fileState && (fileState === null || fileState === void 0 ? void 0 : fileState.status) !== 'error') {
176
+ return fileState;
177
+ }
178
+ return prevFileState;
179
+ // eslint-disable-next-line react-hooks/exhaustive-deps
180
+ }, [fileState]);
165
181
 
166
182
  //----------------------------------------------------------------//
167
183
  //------------ State, Refs & Initial Values ----------------------//
@@ -184,28 +200,10 @@ export var FileCard = function FileCard(_ref) {
184
200
  traceId: getRandomHex(8)
185
201
  };
186
202
  }, []);
187
- var _useState3 = useState('loading'),
188
- _useState4 = _slicedToArray(_useState3, 2),
189
- status = _useState4[0],
190
- setStatus = _useState4[1];
191
- useEffect(function () {
192
- setStatus('loading');
193
- }, [identifier]);
194
- var _useState5 = useState(cardPreviewInitializer),
195
- _useState6 = _slicedToArray(_useState5, 2),
196
- cardPreview = _useState6[0],
197
- setCardPreview = _useState6[1];
198
-
199
- // If cardPreview is available from local cache or external, `isCardVisible`
200
- // should be true to avoid flickers during re-mount of the component
201
- // should not be visible for SSR preview, otherwise we'll fire the metadata fetch from
202
- // outside the viewport
203
- var _useState7 = useState(function () {
204
- return !isLazy || !!cardPreview && !isSSRPreview(cardPreview);
205
- }),
203
+ var _useState7 = useState('loading'),
206
204
  _useState8 = _slicedToArray(_useState7, 2),
207
- isCardVisible = _useState8[0],
208
- setIsCardVisible = _useState8[1];
205
+ status = _useState8[0],
206
+ setStatus = _useState8[1];
209
207
  var _useState9 = useState(false),
210
208
  _useState10 = _slicedToArray(_useState9, 2),
211
209
  isPlayingFile = _useState10[0],
@@ -430,11 +428,11 @@ export var FileCard = function FileCard(_ref) {
430
428
  //----------------------------------------------------------------//
431
429
 
432
430
  var fetchRemotePreviewRef = useCurrentValueRef(function (identifier) {
433
- return fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions !== null && dimensions !== void 0 ? dimensions : {}, imageURLParams, mediaBlobUrlAttrs);
431
+ return fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions !== null && dimensions !== void 0 ? dimensions : {}, imageURLParams, getMediaBlobUrlAttrs(fileStateValue));
434
432
  });
435
433
  var resolvePreviewRef = useCurrentValueRef( /*#__PURE__*/function () {
436
434
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(identifier, fileState) {
437
- var filePreview, isRemotePreviewReady, mode, cachedPreview, dimensionsAreBigger, localPreview, value, resolvedFilePreview, _value, type, mediaType, orientation, _dataURI, _dataURI2, preview, source, dataURI, remotePreview, wrappedError;
435
+ var filePreview, isRemotePreviewReady, mode, cachedPreview, dimensionsAreBigger, localPreview, value, resolvedFilePreview, _value, type, mediaType, orientation, _dataURI, _dataURI2, preview, source, mediaBlobUrlAttrs, dataURI, remotePreview, wrappedError;
438
436
  return _regeneratorRuntime.wrap(function _callee$(_context) {
439
437
  while (1) switch (_context.prev = _context.next) {
440
438
  case 0:
@@ -452,7 +450,7 @@ export var FileCard = function FileCard(_ref) {
452
450
  case 8:
453
451
  _context.prev = 8;
454
452
  if (!filePreview) {
455
- _context.next = 74;
453
+ _context.next = 75;
456
454
  break;
457
455
  }
458
456
  _context.prev = 10;
@@ -558,6 +556,7 @@ export var FileCard = function FileCard(_ref) {
558
556
  source = preview.source;
559
557
  case 70:
560
558
  // We want to embed some meta context into dataURI for Copy/Paste to work.
559
+ mediaBlobUrlAttrs = getMediaBlobUrlAttrs(fileStateValue);
561
560
  dataURI = mediaBlobUrlAttrs ? addFileAttrsToUrl(preview.dataURI, mediaBlobUrlAttrs) : preview.dataURI; // We store new cardPreview into cache
562
561
  cardPreviewCache.set(identifier.id, mode, _objectSpread(_objectSpread({}, preview), {}, {
563
562
  source: source,
@@ -567,11 +566,11 @@ export var FileCard = function FileCard(_ref) {
567
566
  dataURI: dataURI
568
567
  }));
569
568
  return _context.abrupt("return");
570
- case 74:
571
- _context.next = 81;
569
+ case 75:
570
+ _context.next = 82;
572
571
  break;
573
- case 76:
574
- _context.prev = 76;
572
+ case 77:
573
+ _context.prev = 77;
575
574
  _context.t5 = _context["catch"](8);
576
575
  /**
577
576
  * We report the error if:
@@ -591,25 +590,25 @@ export var FileCard = function FileCard(_ref) {
591
590
  * if there is no remote preview available
592
591
  */
593
592
  if (isRemotePreviewReady) {
594
- _context.next = 81;
593
+ _context.next = 82;
595
594
  break;
596
595
  }
597
596
  throw _context.t5;
598
- case 81:
597
+ case 82:
599
598
  if (isRemotePreviewReady) {
600
- _context.next = 83;
599
+ _context.next = 84;
601
600
  break;
602
601
  }
603
602
  throw new MediaCardError('remote-preview-not-ready');
604
- case 83:
605
- _context.next = 85;
606
- return fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions !== null && dimensions !== void 0 ? dimensions : {}, imageURLParams, mediaBlobUrlAttrs, traceContext);
607
- case 85:
603
+ case 84:
604
+ _context.next = 86;
605
+ return fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions !== null && dimensions !== void 0 ? dimensions : {}, imageURLParams, getMediaBlobUrlAttrs(fileStateValue), traceContext);
606
+ case 86:
608
607
  remotePreview = _context.sent;
609
608
  setCardPreview(remotePreview);
610
609
  return _context.abrupt("return");
611
- case 90:
612
- _context.prev = 90;
610
+ case 91:
611
+ _context.prev = 91;
613
612
  _context.t6 = _context["catch"](2);
614
613
  wrappedError = ensureMediaCardError('preview-fetch', _context.t6); // If remote preview fails, we set status 'error'
615
614
  // If local preview fails (i.e, no remote preview available),
@@ -624,11 +623,11 @@ export var FileCard = function FileCard(_ref) {
624
623
  setError(wrappedError);
625
624
  }
626
625
  }
627
- case 94:
626
+ case 95:
628
627
  case "end":
629
628
  return _context.stop();
630
629
  }
631
- }, _callee, null, [[2, 90], [8, 76], [10, 17], [30, 38], [42, 49]]);
630
+ }, _callee, null, [[2, 91], [8, 77], [10, 17], [30, 38], [42, 49]]);
632
631
  }));
633
632
  return function (_x, _x2) {
634
633
  return _ref2.apply(this, arguments);
@@ -801,10 +800,16 @@ export var FileCard = function FileCard(_ref) {
801
800
  var _getFileDetails2 = getFileDetails(identifier, fileStateValue),
802
801
  mimeType = _getFileDetails2.mimeType;
803
802
  var isVideoPlayable = videoIsPlayable(isBannedLocalPreview, fileStateValue, mimeType);
804
- if (isVideo && !isPlayingFile && disableOverlay && useInlinePlayer && isVideoPlayable) {
803
+ if (
804
+ /**
805
+ * We need to check that the card is visible before switching to inline player
806
+ * in order to avoid race conditions of the ViewportDector being unmounted before
807
+ * it is able to set isCardVisible to true.
808
+ */
809
+ isCardVisible && isVideo && !isPlayingFile && disableOverlay && useInlinePlayer && isVideoPlayable) {
805
810
  setIsPlayingFile(true);
806
811
  }
807
- }, [disableOverlay, fileAttributes.fileMediatype, fileStateValue, identifier, isBannedLocalPreview, isPlayingFile, useInlinePlayer]);
812
+ }, [isCardVisible, disableOverlay, fileAttributes.fileMediatype, fileStateValue, identifier, isBannedLocalPreview, isPlayingFile, useInlinePlayer]);
808
813
 
809
814
  //----------------------------------------------------------------//
810
815
  //----------------- fireScreenEvent ------------------------------//
@@ -103,7 +103,7 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
103
103
  ErrorBoundary = _this$state.ErrorBoundary;
104
104
  var analyticsContext = {
105
105
  packageVersion: "@atlaskit/media-card",
106
- packageName: "77.4.1",
106
+ packageName: "77.4.3",
107
107
  componentName: 'mediaInlineCard',
108
108
  component: 'mediaInlineCard'
109
109
  };
@@ -7,7 +7,7 @@ import { extractErrorInfo, getRenderErrorRequestMetadata } from './analytics';
7
7
  import { MediaCardError } from '../errors';
8
8
  import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
9
9
  var packageName = "@atlaskit/media-card";
10
- var packageVersion = "77.4.1";
10
+ var packageVersion = "77.4.3";
11
11
  var concurrentExperience;
12
12
  var getExperience = function getExperience(id) {
13
13
  if (!concurrentExperience) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "77.4.1",
3
+ "version": "77.4.3",
4
4
  "description": "Includes all media card related components, CardView, CardViewSmall, Card...",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"