@quintype/native-components 2.19.15 → 2.19.18

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
@@ -2,6 +2,23 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [2.19.18](https://github.com/quintype/native-components/compare/v2.19.17...v2.19.18) (2022-07-04)
6
+
7
+ ### [2.19.17](https://github.com/quintype/native-components/compare/v2.19.14...v2.19.17) (2022-06-29)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * **story-page:** Fixes crash if image-metadata is null 🔨 ([#184](https://github.com/quintype/native-components/issues/184)) ([8f703d1](https://github.com/quintype/native-components/commit/8f703d19c90c4a5c7844e2251c6691263f9b3d4b))
13
+ * **story-template:** Fixed story-template-icon color :hammer: ([#182](https://github.com/quintype/native-components/issues/182)) ([95f750d](https://github.com/quintype/native-components/commit/95f750d7df5f7cc400095317be26900c0cffd3e1))
14
+
15
+ ### [2.19.16](https://github.com/quintype/native-components/compare/v2.19.15...v2.19.16) (2022-05-09)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **story-template:** Fixed story-template-icon color :hammer: ([#182](https://github.com/quintype/native-components/issues/182)) ([95f750d](https://github.com/quintype/native-components/commit/95f750d7df5f7cc400095317be26900c0cffd3e1))
21
+
5
22
  ### [2.19.15](https://github.com/quintype/native-components/compare/v2.19.14...v2.19.15) (2022-04-12)
6
23
 
7
24
  ### [2.19.14](https://github.com/quintype/native-components/compare/v2.19.7...v2.19.14) (2022-04-04)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/native-components",
3
- "version": "2.19.15",
3
+ "version": "2.19.18",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,28 +1,30 @@
1
- import { get, throttle } from "lodash";
2
- import PropTypes from "prop-types";
3
- import React, { useContext, memo } from "react";
4
- import { StyleSheet, TouchableOpacity, View } from "react-native";
5
- import Icon from "react-native-vector-icons/FontAwesome";
1
+ import { get, throttle } from 'lodash';
2
+ import PropTypes from 'prop-types';
3
+ import React, { useContext, memo } from 'react';
4
+ import { StyleSheet, TouchableOpacity, View } from 'react-native';
5
+ import Icon from 'react-native-vector-icons/FontAwesome';
6
6
  import {
7
7
  AppTheme,
8
8
  getImageMetadata,
9
9
  getImageSlug,
10
10
  getTimeForStoryCards,
11
- } from "../../utils";
12
- import { getStoryHeadline } from "../../utils/story";
13
- import { ResponsiveImage, Text } from "../index";
14
- import { storyStyles } from "./styles";
11
+ } from '../../utils';
12
+ import { getStoryHeadline } from '../../utils/story';
13
+ import { ResponsiveImage, Text } from '../index';
14
+ import { storyStyles } from './styles';
15
15
  import {
16
16
  COMP_GENERAL_CONSTANTS,
17
17
  COMP_CONTENT_CONSTANTS,
18
- } from "../../constants/component-constants";
18
+ } from '../../constants/component-constants';
19
19
 
20
20
  const PrimaryStoryCardNewBase = (props) => {
21
21
  const { story = {} } = props;
22
22
  const { theme } = useContext(AppTheme);
23
- const { COLORS, FONT_SIZE, locale, DARK_MODE } = theme || {};
23
+ const {
24
+ COLORS, FONT_SIZE, locale, DARK_MODE,
25
+ } = theme || {};
24
26
 
25
- const translate = get(theme, ["translate"], (word) => word);
27
+ const translate = get(theme, ['translate'], (word) => word);
26
28
 
27
29
  const styles = storyStyles(COLORS, FONT_SIZE, DARK_MODE);
28
30
  const containerStyle = StyleSheet.flatten([
@@ -38,16 +40,16 @@ const PrimaryStoryCardNewBase = (props) => {
38
40
  props.timestampStyle,
39
41
  ]);
40
42
 
41
- const DATE_FORMAT = "d MMM, yyyy";
42
- const readTime = story["read-time"]
43
- ? `${story["read-time"]} ${translate("min read")} · `
44
- : "";
43
+ const DATE_FORMAT = 'd MMM, yyyy';
44
+ const readTime = story['read-time']
45
+ ? `${story['read-time']} ${translate('min read')} · `
46
+ : '';
45
47
 
46
48
  const throttledOnpress = throttle(props.onPress, 1000);
47
49
 
48
50
  const showIcon = (name) => (
49
51
  <View style={styles.storyType}>
50
- <Icon name={name} size={22} color={COLORS.BRAND_BLACK} />
52
+ <Icon name={name} size={22} color={COLORS.MONO7} />
51
53
  </View>
52
54
  );
53
55
 
@@ -58,14 +60,14 @@ const PrimaryStoryCardNewBase = (props) => {
58
60
  </View>
59
61
  );
60
62
  const showStoryType = () => {
61
- switch (story["story-template"]) {
62
- case "text":
63
+ switch (story['story-template']) {
64
+ case 'text':
63
65
  return null;
64
- case "photo":
65
- return showIcon("photo");
66
- case "video":
67
- return showIcon("play");
68
- case "live-blog":
66
+ case 'photo':
67
+ return showIcon('photo');
68
+ case 'video':
69
+ return showIcon('play');
70
+ case 'live-blog':
69
71
  return showLiveBlogIcon();
70
72
  default:
71
73
  null;
@@ -103,12 +105,12 @@ const PrimaryStoryCardNewBase = (props) => {
103
105
  numberOfLines={2}
104
106
  testID={COMP_CONTENT_CONSTANTS.publishedDate}
105
107
  >
106
- {readTime +
107
- getTimeForStoryCards(
108
- story["published-at"],
108
+ {readTime
109
+ + getTimeForStoryCards(
110
+ story['published-at'],
109
111
  DATE_FORMAT,
110
112
  locale,
111
- translate
113
+ translate,
112
114
  )}
113
115
  </Text>
114
116
  </View>
@@ -130,7 +132,7 @@ PrimaryStoryCardNewBase.propTypes = {
130
132
  };
131
133
 
132
134
  PrimaryStoryCardNewBase.defaultProps = {
133
- cdn: "",
135
+ cdn: '',
134
136
  horizontalPadding: 12,
135
137
  };
136
138
 
@@ -47,7 +47,7 @@ const getLiveBlogTimeStamp = (card, DATE_FORMAT, share, styles, locale) => {
47
47
 
48
48
  /* Mutate the data during access check to limit the content shown */
49
49
  const mutateDataBeforeAccess = (item, storyHasAccess) => {
50
- if (isStoryFree(item)) {
50
+ if (isStoryFree(item) === 0 || storyHasAccess === 'granted') {
51
51
  return item;
52
52
  }
53
53
  if (storyHasAccess !== 'loading' && storyHasAccess === 'granted') {
@@ -55,7 +55,7 @@ const mutateDataBeforeAccess = (item, storyHasAccess) => {
55
55
  }
56
56
  /* The following steps are necessary to keep argument mutation at bay */
57
57
  const firstCardObject = get(item, ['cards', 0], {});
58
- const firstCardElement = get(firstCardObject, ['story-elements', 0], {});
58
+ const firstCardElement = get(firstCardObject, !STORY_TYPES.VIDEO_STORY && ['story-elements', 0], {});
59
59
 
60
60
  return {
61
61
  ...item,
@@ -119,8 +119,9 @@ const getStoryCards = (
119
119
  )}
120
120
  {/* Skip first card if it's a listicle */}
121
121
 
122
- {source.length > 1 && isMiddleIndexOfArray(index, source) && getAd(true)}
123
- {/* ^ Requesting Ad if there are multiple cards. Sending param true for mid-content ad */}
122
+ {source.length > 1 && (!STORY_TYPES.VIDEO_STORY || source.length > 2) && isMiddleIndexOfArray(index, source) && getAd(true)}
123
+ {/* ^ Requesting Ad if there are multiple cards. Sending param true for mid-content ad
124
+ If the story is from video template and have single card then not showing mid-ad */}
124
125
 
125
126
  {(card['story-elements'] || []).map((storyElement, index, source) => {
126
127
  /* Skip the first video element for video story */
@@ -194,9 +195,8 @@ export const Story = ({
194
195
 
195
196
  const shouldShowComments = () => {
196
197
  if (!enableFbComments) return null;
197
-
198
198
  if (
199
- isStoryFree(story)
199
+ isStoryFree(story) === 0
200
200
  || (storyHasAccess !== 'loading' && storyHasAccess === 'granted')
201
201
  ) {
202
202
  return (
@@ -1,8 +1,8 @@
1
1
  import { StyleSheet } from 'react-native';
2
2
  import { getImageHeight } from '../../utils';
3
3
 
4
- export const storyImageStyles = ({ COLORS, FONT_SIZE }, metadata) => {
5
- const { width, height } = metadata;
4
+ export const storyImageStyles = ({ COLORS, FONT_SIZE }, metadata = {}) => {
5
+ const { width, height } = metadata || {};
6
6
  const imageHeight = getImageHeight(width, height);
7
7
 
8
8
  return StyleSheet.create({
@@ -36,6 +36,7 @@ const webviewStyles = (windowWidth) => {
36
36
  },
37
37
  container: {
38
38
  flex: 1,
39
+ marginVertical: 10,
39
40
  },
40
41
  };
41
42
  };
@@ -7,10 +7,14 @@ import get from 'lodash/get';
7
7
  */
8
8
 
9
9
  export const isStoryFree = (story = {}) => {
10
- if (!('access' in story)) {
11
- return true;
10
+ switch (story.access) {
11
+ case 'login':
12
+ return 1;
13
+ case 'subscription':
14
+ return 2;
15
+ default:
16
+ return 0;
12
17
  }
13
- return story.access === 'public' || Object.is(story.access, null);
14
18
  };
15
19
 
16
20
  /**