be-components 6.9.4 → 6.9.5

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.
Files changed (144) hide show
  1. package/lib/commonjs/FlashMarket/FlashHolder.js +21 -2
  2. package/lib/commonjs/FlashMarket/FlashHolder.js.map +1 -1
  3. package/lib/commonjs/FlashMarket/api/index.js +5 -2
  4. package/lib/commonjs/FlashMarket/api/index.js.map +1 -1
  5. package/lib/commonjs/SocialComponents/ActivityDetail/components/PostCommentCard.js +142 -0
  6. package/lib/commonjs/SocialComponents/ActivityDetail/components/PostCommentCard.js.map +1 -0
  7. package/lib/commonjs/SocialComponents/ActivityDetail/index.js +308 -0
  8. package/lib/commonjs/SocialComponents/ActivityDetail/index.js.map +1 -0
  9. package/lib/commonjs/SocialComponents/FormattedTextInput/index.js +11 -3
  10. package/lib/commonjs/SocialComponents/FormattedTextInput/index.js.map +1 -1
  11. package/lib/commonjs/SocialComponents/PostCard/components/PostReactionBar.js +1 -0
  12. package/lib/commonjs/SocialComponents/PostCard/components/PostReactionBar.js.map +1 -1
  13. package/lib/commonjs/SocialComponents/PostCard/index.js +36 -13
  14. package/lib/commonjs/SocialComponents/PostCard/index.js.map +1 -1
  15. package/lib/commonjs/SocialComponents/Poster/index.js +1 -1
  16. package/lib/commonjs/SocialComponents/Poster/index.js.map +1 -1
  17. package/lib/commonjs/SocialComponents/api/index.js +55 -2
  18. package/lib/commonjs/SocialComponents/api/index.js.map +1 -1
  19. package/lib/commonjs/SocialComponents/index.js +7 -0
  20. package/lib/commonjs/SocialComponents/index.js.map +1 -1
  21. package/lib/commonjs/Squares/api/index.js +11 -0
  22. package/lib/commonjs/Squares/api/index.js.map +1 -1
  23. package/lib/commonjs/Squares/index.js +9 -5
  24. package/lib/commonjs/Squares/index.js.map +1 -1
  25. package/lib/commonjs/Wallet/components/DepositCard.js +3 -1
  26. package/lib/commonjs/Wallet/components/DepositCard.js.map +1 -1
  27. package/lib/commonjs/Wallet/index.js +8 -2
  28. package/lib/commonjs/Wallet/index.js.map +1 -1
  29. package/lib/module/FlashMarket/FlashHolder.js +22 -3
  30. package/lib/module/FlashMarket/FlashHolder.js.map +1 -1
  31. package/lib/module/FlashMarket/api/index.js +5 -2
  32. package/lib/module/FlashMarket/api/index.js.map +1 -1
  33. package/lib/module/FlashMarket/index.js.map +1 -1
  34. package/lib/module/SocialComponents/ActivityDetail/components/PostCommentCard.js +134 -0
  35. package/lib/module/SocialComponents/ActivityDetail/components/PostCommentCard.js.map +1 -0
  36. package/lib/module/SocialComponents/ActivityDetail/index.js +300 -0
  37. package/lib/module/SocialComponents/ActivityDetail/index.js.map +1 -0
  38. package/lib/module/SocialComponents/FormattedTextInput/index.js +11 -3
  39. package/lib/module/SocialComponents/FormattedTextInput/index.js.map +1 -1
  40. package/lib/module/SocialComponents/PostCard/components/PostReactionBar.js +1 -0
  41. package/lib/module/SocialComponents/PostCard/components/PostReactionBar.js.map +1 -1
  42. package/lib/module/SocialComponents/PostCard/index.js +36 -13
  43. package/lib/module/SocialComponents/PostCard/index.js.map +1 -1
  44. package/lib/module/SocialComponents/Poster/index.js +1 -1
  45. package/lib/module/SocialComponents/Poster/index.js.map +1 -1
  46. package/lib/module/SocialComponents/api/index.js +55 -2
  47. package/lib/module/SocialComponents/api/index.js.map +1 -1
  48. package/lib/module/SocialComponents/index.js +2 -1
  49. package/lib/module/SocialComponents/index.js.map +1 -1
  50. package/lib/module/Squares/api/index.js +11 -0
  51. package/lib/module/Squares/api/index.js.map +1 -1
  52. package/lib/module/Squares/index.js +9 -5
  53. package/lib/module/Squares/index.js.map +1 -1
  54. package/lib/module/Wallet/components/DepositCard.js +3 -1
  55. package/lib/module/Wallet/components/DepositCard.js.map +1 -1
  56. package/lib/module/Wallet/index.js +8 -2
  57. package/lib/module/Wallet/index.js.map +1 -1
  58. package/lib/typescript/lib/commonjs/FlashMarket/FlashHolder.d.ts +2 -1
  59. package/lib/typescript/lib/commonjs/FlashMarket/FlashHolder.d.ts.map +1 -1
  60. package/lib/typescript/lib/commonjs/FlashMarket/api/index.d.ts.map +1 -1
  61. package/lib/typescript/lib/commonjs/SocialComponents/ActivityDetail/components/PostCommentCard.d.ts +12 -0
  62. package/lib/typescript/lib/commonjs/SocialComponents/ActivityDetail/components/PostCommentCard.d.ts.map +1 -0
  63. package/lib/typescript/lib/commonjs/SocialComponents/ActivityDetail/index.d.ts +14 -0
  64. package/lib/typescript/lib/commonjs/SocialComponents/ActivityDetail/index.d.ts.map +1 -0
  65. package/lib/typescript/lib/commonjs/SocialComponents/FormattedTextInput/index.d.ts.map +1 -1
  66. package/lib/typescript/lib/commonjs/SocialComponents/PostCard/components/PostReactionBar.d.ts.map +1 -1
  67. package/lib/typescript/lib/commonjs/SocialComponents/PostCard/index.d.ts +2 -1
  68. package/lib/typescript/lib/commonjs/SocialComponents/PostCard/index.d.ts.map +1 -1
  69. package/lib/typescript/lib/commonjs/SocialComponents/api/index.d.ts +31 -1
  70. package/lib/typescript/lib/commonjs/SocialComponents/api/index.d.ts.map +1 -1
  71. package/lib/typescript/lib/commonjs/SocialComponents/index.d.ts +1 -0
  72. package/lib/typescript/lib/commonjs/Squares/api/index.d.ts +1 -0
  73. package/lib/typescript/lib/commonjs/Squares/api/index.d.ts.map +1 -1
  74. package/lib/typescript/lib/commonjs/Squares/index.d.ts +2 -1
  75. package/lib/typescript/lib/commonjs/Squares/index.d.ts.map +1 -1
  76. package/lib/typescript/lib/commonjs/Wallet/components/DepositCard.d.ts.map +1 -1
  77. package/lib/typescript/lib/commonjs/Wallet/index.d.ts +3 -1
  78. package/lib/typescript/lib/commonjs/Wallet/index.d.ts.map +1 -1
  79. package/lib/typescript/lib/module/FlashMarket/FlashHolder.d.ts +2 -1
  80. package/lib/typescript/lib/module/FlashMarket/FlashHolder.d.ts.map +1 -1
  81. package/lib/typescript/lib/module/FlashMarket/api/index.d.ts.map +1 -1
  82. package/lib/typescript/lib/module/SocialComponents/ActivityDetail/components/PostCommentCard.d.ts +12 -0
  83. package/lib/typescript/lib/module/SocialComponents/ActivityDetail/components/PostCommentCard.d.ts.map +1 -0
  84. package/lib/typescript/lib/module/SocialComponents/ActivityDetail/index.d.ts +14 -0
  85. package/lib/typescript/lib/module/SocialComponents/ActivityDetail/index.d.ts.map +1 -0
  86. package/lib/typescript/lib/module/SocialComponents/FormattedTextInput/index.d.ts.map +1 -1
  87. package/lib/typescript/lib/module/SocialComponents/PostCard/components/PostReactionBar.d.ts.map +1 -1
  88. package/lib/typescript/lib/module/SocialComponents/PostCard/index.d.ts +2 -1
  89. package/lib/typescript/lib/module/SocialComponents/PostCard/index.d.ts.map +1 -1
  90. package/lib/typescript/lib/module/SocialComponents/api/index.d.ts +31 -1
  91. package/lib/typescript/lib/module/SocialComponents/api/index.d.ts.map +1 -1
  92. package/lib/typescript/lib/module/SocialComponents/index.d.ts +2 -1
  93. package/lib/typescript/lib/module/SocialComponents/index.d.ts.map +1 -1
  94. package/lib/typescript/lib/module/Squares/api/index.d.ts +1 -0
  95. package/lib/typescript/lib/module/Squares/api/index.d.ts.map +1 -1
  96. package/lib/typescript/lib/module/Squares/index.d.ts +2 -1
  97. package/lib/typescript/lib/module/Squares/index.d.ts.map +1 -1
  98. package/lib/typescript/lib/module/Wallet/components/DepositCard.d.ts.map +1 -1
  99. package/lib/typescript/lib/module/Wallet/index.d.ts +3 -1
  100. package/lib/typescript/lib/module/Wallet/index.d.ts.map +1 -1
  101. package/lib/typescript/src/Components/AutoPageFlatList.d.ts +2 -1
  102. package/lib/typescript/src/Components/AutoPageFlatList.d.ts.map +1 -1
  103. package/lib/typescript/src/FlashMarket/FlashHolder.d.ts +2 -1
  104. package/lib/typescript/src/FlashMarket/FlashHolder.d.ts.map +1 -1
  105. package/lib/typescript/src/FlashMarket/api/index.d.ts +4 -1
  106. package/lib/typescript/src/FlashMarket/api/index.d.ts.map +1 -1
  107. package/lib/typescript/src/FlashMarket/index.d.ts +3 -2
  108. package/lib/typescript/src/FlashMarket/index.d.ts.map +1 -1
  109. package/lib/typescript/src/SocialComponents/ActivityDetail/components/PostCommentCard.d.ts +20 -0
  110. package/lib/typescript/src/SocialComponents/ActivityDetail/components/PostCommentCard.d.ts.map +1 -0
  111. package/lib/typescript/src/SocialComponents/ActivityDetail/index.d.ts +16 -0
  112. package/lib/typescript/src/SocialComponents/ActivityDetail/index.d.ts.map +1 -0
  113. package/lib/typescript/src/SocialComponents/FormattedTextInput/index.d.ts.map +1 -1
  114. package/lib/typescript/src/SocialComponents/PostCard/index.d.ts +2 -1
  115. package/lib/typescript/src/SocialComponents/PostCard/index.d.ts.map +1 -1
  116. package/lib/typescript/src/SocialComponents/api/index.d.ts +5 -2
  117. package/lib/typescript/src/SocialComponents/api/index.d.ts.map +1 -1
  118. package/lib/typescript/src/SocialComponents/index.d.ts +2 -1
  119. package/lib/typescript/src/SocialComponents/index.d.ts.map +1 -1
  120. package/lib/typescript/src/Squares/api/index.d.ts +1 -0
  121. package/lib/typescript/src/Squares/api/index.d.ts.map +1 -1
  122. package/lib/typescript/src/Squares/index.d.ts +2 -1
  123. package/lib/typescript/src/Squares/index.d.ts.map +1 -1
  124. package/lib/typescript/src/Wallet/components/DepositCard.d.ts.map +1 -1
  125. package/lib/typescript/src/Wallet/index.d.ts +4 -1
  126. package/lib/typescript/src/Wallet/index.d.ts.map +1 -1
  127. package/package.json +1 -1
  128. package/src/Components/AutoPageFlatList.tsx +1 -1
  129. package/src/FlashMarket/FlashHolder.tsx +19 -5
  130. package/src/FlashMarket/api/index.ts +3 -3
  131. package/src/FlashMarket/index.tsx +3 -3
  132. package/src/SocialComponents/ActivityDetail/components/PostCommentCard.tsx +101 -0
  133. package/src/SocialComponents/ActivityDetail/index.tsx +283 -0
  134. package/src/SocialComponents/FormattedTextInput/index.tsx +4 -3
  135. package/src/SocialComponents/PostCard/components/PostReactionBar.tsx +1 -1
  136. package/src/SocialComponents/PostCard/index.tsx +19 -8
  137. package/src/SocialComponents/Poster/index.tsx +1 -1
  138. package/src/SocialComponents/api/index.ts +54 -3
  139. package/src/SocialComponents/index.tsx +2 -1
  140. package/src/Squares/api/index.ts +11 -0
  141. package/src/Squares/index.tsx +14 -9
  142. package/src/Wallet/components/DepositCard.tsx +4 -2
  143. package/src/Wallet/index.tsx +6 -4
  144. package/src/types.d.ts +4 -2
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Wallet/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAInD,OAAO,KAAK,EAAgB,YAAY,EAAoB,kBAAkB,EAAE,cAAc,EAAgD,kBAAkB,EAAiJ,MAAM,UAAU,CAAC;AAuBlU,KAAK,aAAa,GAAG;IACjB,UAAU,CAAC,EAAC,MAAM,CAAC;IACnB,WAAW,CAAC,EAAC,kBAAkB,CAAC;IAChC,MAAM,CAAC,EAAC,MAAM,CAAC;IACf,SAAS,CAAC,EAAC,SAAS,GAAC,QAAQ,CAAC;IAC9B,MAAM,CAAC,EAAC;QAAE,GAAG,EAAC,MAAM,CAAC;QAAC,MAAM,EAAC,MAAM,CAAC;QAAC,IAAI,EAAC,MAAM,CAAC;QAAC,KAAK,EAAC,MAAM,CAAA;KAAE,CAAC;IACjE,eAAe,CAAC,EAAC,CAAC,GAAG,EAAC,kBAAkB,KAAK,IAAI,CAAC;IAClD,OAAO,EAAC,MAAM,IAAI,CAAC;IACnB,OAAO,EAAC,CAAC,KAAK,EAAC,YAAY,KAAK,IAAI,CAAA;IACpC,UAAU,EAAE,CAAC,UAAU,EAAC,cAAc,EAAE,UAAU,CAAC,EAAC,MAAM,KAAK,IAAI,CAAA;CACtE,CAAA;AAED,QAAA,MAAM,QAAQ,GAAI,uGAAsG,aAAa,sBA2iBpI,CAAA;AAED,eAAe,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Wallet/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAG3E,OAAO,KAAK,EAAgB,YAAY,EAAoB,kBAAkB,EAAE,cAAc,EAAgD,kBAAkB,EAAiJ,MAAM,UAAU,CAAC;AAuBlU,KAAK,aAAa,GAAG;IACjB,UAAU,CAAC,EAAC,MAAM,CAAC;IACnB,YAAY,CAAC,EAAC,SAAS,CAAC;IACxB,YAAY,CAAC,EAAC,SAAS,CAAC;IACxB,WAAW,CAAC,EAAC,kBAAkB,CAAC;IAChC,MAAM,CAAC,EAAC,MAAM,CAAC;IACf,SAAS,CAAC,EAAC,SAAS,GAAC,QAAQ,CAAC;IAC9B,MAAM,CAAC,EAAC;QAAE,GAAG,EAAC,MAAM,CAAC;QAAC,MAAM,EAAC,MAAM,CAAC;QAAC,IAAI,EAAC,MAAM,CAAC;QAAC,KAAK,EAAC,MAAM,CAAA;KAAE,CAAC;IACjE,eAAe,CAAC,EAAC,CAAC,GAAG,EAAC,kBAAkB,KAAK,IAAI,CAAC;IAClD,OAAO,EAAC,MAAM,IAAI,CAAC;IACnB,OAAO,EAAC,CAAC,KAAK,EAAC,YAAY,KAAK,IAAI,CAAA;IACpC,UAAU,EAAE,CAAC,UAAU,EAAC,cAAc,EAAE,UAAU,CAAC,EAAC,MAAM,KAAK,IAAI,CAAA;CACtE,CAAA;AAED,QAAA,MAAM,QAAQ,GAAI,mIAAkI,aAAa,sBA2iBhK,CAAA;AAED,eAAe,QAAQ,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "be-components",
3
- "version": "6.9.4",
3
+ "version": "6.9.5",
4
4
  "description": "Components for BettorEdge Apps",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -9,7 +9,7 @@ import Pagination from './Pagination';
9
9
  interface AutoPageFlatListProps<T> {
10
10
  data: T[];
11
11
  reset_key:string,
12
- renderItem: ({ item }: { item: T }) => JSX.Element;
12
+ renderItem: ({ item, index }: { item: T, index:number }) => JSX.Element;
13
13
  horizontal?: boolean;
14
14
  time_on_page?: number; // seconds
15
15
  itemHeight?: number; // required for vertical paging
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import React, { useEffect, useRef, useState } from 'react';
2
2
  import { Button, Text, View } from "../Components/Themed"
3
3
  import { FlashMarketApi } from './api';
4
4
  import type { FlashMarketFeeProps, LocationProps, MyPlayerProps, PollCampaignProps, PollOptionProps, PollProps, PollSummaryProps } from '../types';
@@ -29,6 +29,7 @@ type FlashHolderProps = {
29
29
  no_highlight?:boolean,
30
30
  location?:LocationProps,
31
31
  side_id?:string,
32
+ default_poll_id?:string,
32
33
  poll_id?:string,
33
34
  onSelectCompactPoll?:(poll_id:string) => void,
34
35
  onRequestLocation:() => void,
@@ -36,7 +37,7 @@ type FlashHolderProps = {
36
37
  onRequestAuthenticate: () => void
37
38
  }
38
39
  const sections = [ 'selector','explainer','flash_market','options','footer' ]
39
- const FlashHolder = ({ float, company_id, compact, style, hide_timer, distinct_id, hide_footer, no_highlight, hide_tabs, parent_style, league_id, init_expanded, player_id, player, location, contest_type, contest_id, side_type, side_id, poll_id, onSelectCompactPoll, onRequestAuthenticate, onFocusPosition, onRequestLocation } : FlashHolderProps) => {
40
+ const FlashHolder = ({ float, company_id, compact, style, default_poll_id, hide_timer, distinct_id, hide_footer, no_highlight, hide_tabs, parent_style, league_id, init_expanded, player_id, player, location, contest_type, contest_id, side_type, side_id, poll_id, onSelectCompactPoll, onRequestAuthenticate, onFocusPosition, onRequestLocation } : FlashHolderProps) => {
40
41
  const Colors = useColors();
41
42
  const [ needs_reload, setNeedsReload ] = useState(false);
42
43
  const [ socket_campaigns, setSocketCampaigns ] = useState<PollCampaignProps[]>([]);
@@ -62,7 +63,7 @@ const FlashHolder = ({ float, company_id, compact, style, hide_timer, distinct_i
62
63
  flash_market_fees:[]
63
64
  });
64
65
  const { loading, poll_options, poll_summaries, poll_campaign, flash_market_fees } = market_data;
65
-
66
+ const flashRef = useRef<any>(null);
66
67
  const [ flash_data, setFlashData ] = useState<{
67
68
  holder_loading:boolean,
68
69
  loaded:boolean,
@@ -75,6 +76,7 @@ const FlashHolder = ({ float, company_id, compact, style, hide_timer, distinct_i
75
76
  const { holder_loading, flash_markets, loaded } = flash_data;
76
77
  const [ active_flash_market, setActiveFlashMarket ] = useState<string | undefined>(undefined);
77
78
  const flash_market = flash_markets.find(fm => fm.poll_id == active_flash_market);
79
+ const sorted_flashes = flash_markets.sort((a,b) => moment(a.end_datetime).unix() - moment(b.end_datetime).unix() || parseInt(a.poll_id) - parseInt(b.poll_id))
78
80
 
79
81
  useEffect(() => {
80
82
  loadData();
@@ -85,6 +87,8 @@ const FlashHolder = ({ float, company_id, compact, style, hide_timer, distinct_i
85
87
  if(compact){ return } //We dont do any polls if compacted
86
88
  let expiring_poll = flash_markets.sort((a,b) => moment(a.end_datetime).unix() - moment(b.end_datetime).unix() || parseInt(a.poll_id) - parseInt(b.poll_id))[0]
87
89
  if(poll_id){ return }
90
+ let default_poll = flash_markets.find(fm => fm.poll_id == default_poll_id);
91
+ if(default_poll){ handleSelectPoll(default_poll.poll_id); return }//Return out if we have this!
88
92
  if(expiring_poll){ handleSelectPoll(expiring_poll.poll_id) }
89
93
  },[loaded])
90
94
 
@@ -143,6 +147,14 @@ const FlashHolder = ({ float, company_id, compact, style, hide_timer, distinct_i
143
147
  if(selected && !options?.reload){ return setActiveFlashMarket(undefined) }
144
148
  loadMarket(poll_id);
145
149
  setActiveFlashMarket(poll_id);
150
+
151
+ let active_flash_index = sorted_flashes.findIndex(d => d.poll_id === poll_id);
152
+ if(flashRef && active_flash_index > 0){
153
+ setTimeout(() => {
154
+ flashRef.current?.scrollToIndex({ animated: true, index: active_flash_index - 1 });
155
+ }, 250);
156
+ }
157
+
146
158
  }
147
159
 
148
160
 
@@ -157,7 +169,8 @@ const FlashHolder = ({ float, company_id, compact, style, hide_timer, distinct_i
157
169
 
158
170
  let found_polls:PollProps[] = []
159
171
  if(company_id){
160
- found_polls = await FlashMarketApi.getActiveMarkets(company_id);
172
+ let resp = await FlashMarketApi.getActiveMarkets(company_id);
173
+ found_polls = resp.polls
161
174
  } else if(league_id || contest_type || contest_id || side_type || side_id){
162
175
  found_polls = await FlashMarketApi.getActiveLinkedFlashMarkets(league_id, contest_type, contest_id, side_type, side_id);
163
176
  } else {
@@ -233,8 +246,9 @@ const FlashHolder = ({ float, company_id, compact, style, hide_timer, distinct_i
233
246
  <View transparent style={{ flex:1 }}>
234
247
  <FlatList
235
248
  key={'poll_selector'}
249
+ ref={flashRef}
236
250
  keyExtractor={(item) => item.poll_id.toString()}
237
- data={flash_markets.sort((a,b) => moment(a.end_datetime).unix() - moment(b.end_datetime).unix() || parseInt(a.poll_id) - parseInt(b.poll_id))}
251
+ data={sorted_flashes}
238
252
  horizontal
239
253
  renderItem={renderFlashes}
240
254
  />
@@ -38,12 +38,12 @@ const FlashMarketApi = {
38
38
  return []
39
39
  }
40
40
  },
41
- getActiveMarkets: async(company_id?:string):Promise<PollProps[]> => {
41
+ getActiveMarkets: async(company_id?:string):Promise<{polls:PollProps[], poll_campaigns:PollCampaignProps[]}> => {
42
42
  try {
43
43
  const resp = await axios.get(`${AUTH_SVC_API}/v2/pm/active?company_id=${company_id}`);
44
- return resp.data.polls
44
+ return resp.data
45
45
  } catch (e) {
46
- return []
46
+ return { polls: [], poll_campaigns: [] }
47
47
  }
48
48
  },
49
49
  getActiveLinkedFlashMarkets: async(league_id?:string, contest_type?:string, contest_id?:string, side_type?:string, side_id?:string):Promise<PollProps[]> => {
@@ -4,7 +4,7 @@ import type { FlashMarketFeeProps, LocationProps, MyPlayerProps, PollCampaignPro
4
4
  import { FlashAdminApi, FlashMarketApi, FlashMarketHelpers } from './api';
5
5
  import { Checkbox, Icons } from '../Components';
6
6
  import { useColors } from '../constants/useColors';
7
- import { ActivityIndicator, Alert, FlatList, Image } from 'react-native';
7
+ import { ActivityIndicator, Alert, FlatList, Image, type ViewStyle } from 'react-native';
8
8
  import FlashMarketHelp from './components/FlashMarketHelp';
9
9
  import moment from 'moment-mini';
10
10
  import MarketTimer from './components/MarketTimer';
@@ -22,9 +22,9 @@ type FlashMarketProps = {
22
22
  init_expanded?:boolean,
23
23
  hide_timer?:boolean,
24
24
  onReload:() => void,
25
- header_style?:any,
25
+ header_style?:ViewStyle,
26
26
  hide_footer?:boolean,
27
- footer_style?:any,
27
+ footer_style?:ViewStyle,
28
28
  player_id?:string
29
29
  player?:MyPlayerProps,
30
30
  onRequestLocation:() => void,
@@ -0,0 +1,101 @@
1
+ import React, { useState } from 'react';
2
+ import { Text, View } from "../../../Components/Themed";
3
+ import { useColors } from "../../../constants/useColors";
4
+ import type { MyPlayerProps, OrderProps, PostCommentProps, PublicPlayerProps, TextTagProps } from "../../../types";
5
+ import { FormattedText } from '../../FormattedTextInput/FormattedText';
6
+ import moment from 'moment-mini';
7
+ import { Image } from 'react-native';
8
+ import ImageRenderer from '../../ImageRenderer';
9
+ import UrlPreviewCard from '../../UrlPreviewCard';
10
+ import SocialOrdersList from '../../SocialOrdersList';
11
+
12
+ type PostCommentCardProps = {
13
+ post_comment:PostCommentProps,
14
+ me?:MyPlayerProps,
15
+ orders:OrderProps[],
16
+ player?:PublicPlayerProps,
17
+ mine?:boolean,
18
+ onCopyOrder?:(order:OrderProps) => void,
19
+ onFadeOrder?:(order:OrderProps) => void,
20
+ onSelectImage:(image:{ url:string, height?:number, width?:number }) => void,
21
+ onSelectTag:(tag:TextTagProps) => void
22
+ }
23
+ const MAX_IMAGE_WIDTH = 400
24
+ const PostCommentCard = ({post_comment, orders, player, onSelectImage, onSelectTag, onCopyOrder, onFadeOrder}:PostCommentCardProps) => {
25
+ const [ comment_size, setCommentSize ] = useState({ width:0 })
26
+ const Colors = useColors();
27
+ const image = post_comment.comment_images ? post_comment.comment_images[0] : undefined
28
+ const url = post_comment.comment_urls ? post_comment.comment_urls[0] : undefined
29
+ const image_width = comment_size.width > 400 ? MAX_IMAGE_WIDTH : comment_size.width
30
+ return (
31
+ <View transparent style={{ flexDirection:'row', alignItems:'flex-start', padding:10, borderBottomWidth:1, borderColor:Colors.borders.light }}>
32
+ <View float style={{ borderRadius:100, padding:2 }}>
33
+ <Image
34
+ source={{ uri:player?.profile_pic }}
35
+ style={{ height:36, width:36, borderRadius:100 }}
36
+ resizeMode='cover'
37
+ />
38
+ </View>
39
+ <View style={{ flex:1, marginLeft:10 }} onLayout={(ev) => {
40
+ const { width } = ev.nativeEvent.layout
41
+ setCommentSize({ width })
42
+ }}>
43
+ <View type='row'>
44
+ <Text theme='h2' style={{ flex:1, marginRight:10 }}>@{player?.username ?? 'Anonymous'}</Text>
45
+ <Text theme='light' style={{ marginTop:3 }}>Delivered {moment(post_comment.create_datetime).format('hh:mm a')}</Text>
46
+ </View>
47
+ <View type='body' style={{ marginTop:5 }}>
48
+ <View transparent nativeID='comment'>
49
+ {post_comment.formatted_text ?
50
+ <FormattedText
51
+ text={post_comment.formatted_text}
52
+ tags={post_comment.tags ?? []}
53
+ text_color={Colors.text.h1}
54
+ onSelectTag={(tag) => onSelectTag(tag)}
55
+ />
56
+ : post_comment.message ?
57
+ <Text size={12} theme='h2'>{post_comment.message}</Text>
58
+ :<></>}
59
+ </View>
60
+ {image ?
61
+ <View transparent style={{ justifyContent:'center', alignItems:'center', marginTop:10 }}>
62
+ <ImageRenderer
63
+ image={image}
64
+ width={image_width}
65
+ max_height={300}
66
+ onSelectImage={onSelectImage}
67
+ />
68
+ </View>
69
+ :<></>}
70
+ {url ?
71
+ <View transparent style={{ justifyContent:'center', alignItems:'center', marginTop:10 }}>
72
+ <UrlPreviewCard
73
+ url={url}
74
+ max_height={120}
75
+ width={comment_size.width}
76
+ color={Colors.text.white}
77
+ />
78
+ </View>
79
+ :<></>}
80
+ {player && orders && orders.length > 0 ?
81
+ <View float style={{ padding:4, marginTop:10 }}>
82
+ <SocialOrdersList
83
+ orders={orders}
84
+ onCopyOrder={onCopyOrder}
85
+ onFadeOrder={onFadeOrder}
86
+ maxWidth={comment_size.width}
87
+ players={[player]}
88
+ direction='horizontal'
89
+
90
+
91
+ />
92
+ </View>
93
+ :<></>}
94
+ </View>
95
+ </View>
96
+
97
+ </View>
98
+ )
99
+ }
100
+
101
+ export default PostCommentCard
@@ -0,0 +1,283 @@
1
+ import React, { useEffect, useState } from 'react'
2
+ import { Text, View } from "../../Components/Themed"
3
+ import type { ArticleProps, FocusPositionProps, MyPlayerProps, OrderProps, PostCommentProps, PostProps, PublicPlayerProps, TextTagProps } from "../../types"
4
+ import { SocialComponentApi, SocialComponentHelpers } from '../api'
5
+ import { ActivityIndicator, FlatList } from 'react-native'
6
+ import PostCard from '../PostCard'
7
+ import FormattedTextInput from '../FormattedTextInput'
8
+ import InputBar from '../InputBar'
9
+ import moment from 'moment-mini'
10
+ import PostCommentCard from './components/PostCommentCard'
11
+ import SocialOrdersList from '../SocialOrdersList'
12
+ import SocketManager from '../../Socket'
13
+ import { useColors } from '../../constants/useColors'
14
+
15
+ type ActivityDetailProps = {
16
+ post_id:string,
17
+ me?:MyPlayerProps,
18
+ onSelectTag:(t:TextTagProps) => void,
19
+ onCopyOrder?:(o:OrderProps) => void,
20
+ onFadeOrder?:(o:OrderProps) => void,
21
+ onSelectPlayer:(p:PublicPlayerProps) => void,
22
+ onSelectArticle:(a:ArticleProps) => void,
23
+ onSelectImage:(i:any) => void,
24
+
25
+ onFocusPosition?:(pos:FocusPositionProps) => void
26
+ }
27
+ const sections = ['post','comments']
28
+ const ActivityDetail = ({ post_id, me, onFocusPosition, onSelectArticle, onSelectImage, onSelectTag, onCopyOrder, onFadeOrder, onSelectPlayer }:ActivityDetailProps) => {
29
+ const Colors = useColors();
30
+ const [size, setSize] = useState({ width:0, height:0 });
31
+ const [ show_input_bar, setShowInputBar ] = useState(false);
32
+ const [ needs_reload, setNeedsReload ] = useState(false);
33
+ const [ socket_comment, setSocketComment ] = useState<PostCommentProps|undefined>(undefined);
34
+ const [ post_refresh_key, setPostRefreshKey ] = useState(moment().toString())
35
+ const [ comment_loading, setCommentLoading ] = useState(false);
36
+ const [ draft_orders, setDraftOrders ] = useState<OrderProps[]>([]);
37
+ const [ state, setState ] = useState<{
38
+ loading: boolean,
39
+ post?:PostProps,
40
+ orders:OrderProps[],
41
+ articles:ArticleProps[],
42
+ players:PublicPlayerProps[],
43
+ post_comments:PostCommentProps[],
44
+ }>({
45
+ loading:false,
46
+ post_comments:[],
47
+ articles:[],
48
+ orders:[],
49
+ players:[]
50
+ });
51
+ const { loading, post, post_comments, players, orders, articles } = state;
52
+ const sorted_comments = post_comments.sort((a,b) =>{
53
+ return moment(b.create_datetime).unix() - moment(a.create_datetime).unix()
54
+ })
55
+ useEffect(() => {
56
+ SocialComponentApi.setEnvironment();
57
+ getData(post_id)
58
+ },[post_id, me?.player_id]);
59
+
60
+ useEffect(() => {
61
+ if(!socket_comment){ return }
62
+ setState({
63
+ ...state,
64
+ post_comments: post_comments.filter(pc => pc.post_comment_id != socket_comment.post_comment_id).concat(socket_comment)
65
+ })
66
+ },[socket_comment?.post_comment_id])
67
+
68
+ const getData = async(id:string) => {
69
+ setState({ ...state, loading:true });
70
+ const server_post = await SocialComponentApi.getPostById(id, 'memo');
71
+ if(!server_post){ return alert('Unable to get activity at this time. Please try again') }
72
+ const comments = await SocialComponentApi.getPostComments(id, 0);
73
+ let order_ids = server_post.memo_orders ?? []
74
+ let comment_orders:string[] = []
75
+ comments.filter(c => c.comment_orders).map(c => c.comment_orders?.map(o => comment_orders.push(o)))
76
+ let ser_orders = await SocialComponentApi.getBulkOrders(order_ids.concat(comment_orders));
77
+ let article_ids = server_post.memo_articles ?? []
78
+ let ser_articles = await SocialComponentApi.getBulkArticles(article_ids);
79
+ let player_ids = [ ...new Set(comments.map(c => c.player_id).concat(server_post.player_id)) ]
80
+ let ser_players = await SocialComponentApi.getPlayersByIds(player_ids);
81
+ setState({
82
+ ...state,
83
+ post: server_post,
84
+ post_comments: comments,
85
+ players: ser_players,
86
+ orders:ser_orders,
87
+ articles: ser_articles,
88
+ loading:false
89
+ });
90
+ }
91
+
92
+
93
+ const handleSendImage = async(image:any) => {
94
+ if(!post || comment_loading){ return }
95
+ setCommentLoading(true);
96
+ const new_comment = SocialComponentHelpers.getEmptyComment();
97
+ const pc = await SocialComponentApi.createComment({
98
+ ...new_comment,
99
+ formatted_text: '',
100
+ activity_post_id: post_id,
101
+ tags: [],
102
+ comment_images: [image],
103
+ message: ''
104
+ });
105
+ if(!pc){
106
+ setCommentLoading(false);
107
+ return
108
+ }
109
+ setState({
110
+ ...state,
111
+ post_comments: post_comments.filter(m => m.post_comment_id != pc.post_comment_id).concat(pc)
112
+ })
113
+ setCommentLoading(false);
114
+ }
115
+
116
+ const handleSendComment = async(data: { formatted_text: string, text:string }, tags:TextTagProps[]) => {
117
+ if(!post || comment_loading){ return }
118
+ setCommentLoading(true);
119
+
120
+ //Find urls!
121
+ const url = SocialComponentHelpers.getUrlsFromString(data.text);
122
+ let message_urls:string[] = []
123
+ if(url){ message_urls.push(url) }
124
+ const new_comment = SocialComponentHelpers.getEmptyComment();
125
+ const pc = await SocialComponentApi.createComment({
126
+ ...new_comment,
127
+ activity_post_id: post_id,
128
+ formatted_text: data.formatted_text,
129
+ tags: tags.map(t => { return { ...t, data:undefined } }), //Drop the data!
130
+ comment_urls: message_urls,
131
+ comment_orders:draft_orders.map(o => o.order_id),
132
+ message: data.text
133
+ });
134
+ if(!pc){
135
+ setCommentLoading(false);
136
+ return
137
+ }
138
+ setDraftOrders([]);
139
+ setState({
140
+ ...state,
141
+ post_comments: post_comments.filter(m => m.post_comment_id != pc.post_comment_id).concat(pc)
142
+ })
143
+ setCommentLoading(false);
144
+ }
145
+
146
+ const renderComments = (data:{ item:PostCommentProps, index:number }) => {
147
+ const player = players.find(p => p.player_id == data.item.player_id);
148
+ const comment_orders = data.item.comment_orders ? orders.filter(o => data.item.comment_orders?.includes(o.order_id)): []
149
+ return (
150
+ <PostCommentCard
151
+ post_comment={data.item}
152
+ player={player}
153
+ orders={comment_orders}
154
+ onSelectImage={onSelectImage}
155
+ onSelectTag={onSelectTag}
156
+ onCopyOrder={onCopyOrder}
157
+ onFadeOrder={onFadeOrder}
158
+ />
159
+ )
160
+ }
161
+
162
+ const renderSections = (data:{ item:string, index:number }) => {
163
+ switch(data.item){
164
+ case 'post':
165
+ if(!post){ return <></> }
166
+ const player = players.find(p => p.player_id == post.player_id)
167
+ return (
168
+ <PostCard
169
+ post={post}
170
+ refresh_key={post_refresh_key}
171
+ width={size.width}
172
+ //onViewComments={() => console.log('')}
173
+ player={player}
174
+ player_id={me?.player_id}
175
+ articles={articles}
176
+ orders={orders}
177
+ onRequestAuthenticate={() => console.log('hey')}
178
+ onSelectArticle={onSelectArticle}
179
+ onSelectImage={onSelectImage}
180
+ onSelectPlayer={onSelectPlayer}
181
+ onSelectTag={onSelectTag}
182
+ />
183
+ )
184
+ case 'comments':
185
+ return (
186
+ <FlatList
187
+ data={sorted_comments}
188
+ renderItem={renderComments}
189
+ key={'activity_comments_list'}
190
+ keyExtractor={item => item.post_comment_id.toString()}
191
+ />
192
+ )
193
+ default: return <></>
194
+ }
195
+ }
196
+
197
+ return (
198
+ <View style={{ flex:1 }} onLayout={(ev) => {
199
+ const { width, height } = ev.nativeEvent.layout
200
+ setSize({ width, height })
201
+ }}>
202
+ <View style={{ flex:1 }}>
203
+ {loading ?
204
+ <ActivityIndicator
205
+ style={{ padding:10, alignSelf:'center' }}
206
+ size={'large'}
207
+ color={Colors.text.h1}
208
+ />
209
+ :<></>}
210
+ <FlatList
211
+ data={sections}
212
+ key={'activity_detail_list'}
213
+ keyExtractor={item => item}
214
+ renderItem={renderSections}
215
+ />
216
+ </View>
217
+ {show_input_bar?
218
+ <View type='header' style={{ padding:5 }}>
219
+ <InputBar
220
+ actions={['image','action']}
221
+ width={size.width}
222
+ //insets={insets}
223
+ onTagOrder={(order) => {
224
+ setDraftOrders(draft_orders.filter(o => o.order_id != order.order_id).concat(order))
225
+ }}
226
+ onImageUpload={(image) => handleSendImage(image)}
227
+ />
228
+ </View>
229
+ :<></>}
230
+ {draft_orders.length > 0 ?
231
+ <View>
232
+ <Text theme='h2'>Tagged Orders</Text>
233
+ <SocialOrdersList
234
+ players={players}
235
+ orders={draft_orders}
236
+ onUntagOrder={(order) => setDraftOrders(draft_orders.filter(o => o.order_id != order.order_id))}
237
+ direction='horizontal'
238
+ />
239
+ </View>
240
+ :<></>}
241
+ <View type='footer' style={{ padding:5 }}>
242
+ <FormattedTextInput
243
+ submit_placement='inline'
244
+ icon_submit
245
+ width={size.width}
246
+ onSelectInput={() => setShowInputBar(!show_input_bar)}
247
+ onSubmit={(data, tags) => handleSendComment(data, tags)}
248
+ onFocusPosition={onFocusPosition}
249
+ />
250
+ </View>
251
+ <SocketManager
252
+ onConnect={() => {
253
+ if(needs_reload){
254
+ setPostRefreshKey(moment().toString());
255
+ getData(post_id);
256
+ }
257
+ }}
258
+ onDisconnect={() => setNeedsReload(true)}
259
+ subscribed_events={['V1_UPDATE_POST_COMMENT_STAT', 'V1_UPDATE_POST_REACTION_STATS','UPDATE_POST_COMMENT']}
260
+ onSocketEvent={(ev) => {
261
+ switch(ev.type){
262
+ case 'V1_UPDATE_POST_COMMENT_STAT':
263
+ console.log('updated')
264
+ setPostRefreshKey(moment().toString())
265
+ break
266
+ case 'V1_UPDATE_POST_REACTION_STATS':
267
+ setPostRefreshKey(moment().toString())
268
+ break
269
+ case 'UPDATE_POST_COMMENT':
270
+ const new_comment = ev.data as PostCommentProps
271
+ if(new_comment.activity_post_id != post_id){ return }
272
+ setSocketComment(new_comment)
273
+ break
274
+ default: return
275
+ }
276
+ }}
277
+
278
+ />
279
+ </View>
280
+ )
281
+ }
282
+
283
+ export default ActivityDetail
@@ -135,6 +135,7 @@ const FormattedTextInput = ({ width, disable_scroll, submit_title, hide_border,
135
135
 
136
136
  const handleChange = (ev:any) => {
137
137
  let text:string = JSON.stringify(ev.text)
138
+ if(text.length < 3 && input_state.height > 50){ setInputState({ ...input_state, height: 50 }) }
138
139
  setData({
139
140
  ...data,
140
141
  text: ev.text,
@@ -160,11 +161,11 @@ const FormattedTextInput = ({ width, disable_scroll, submit_title, hide_border,
160
161
  :<></>}
161
162
  <View transparent style={{ flexDirection:'row', alignItems:'flex-end' }}>
162
163
  {onSelectInput ?
163
- <Button float style={{ padding:10, width:45, marginRight:5, borderRadius:8, justifyContent:'center', alignItems:'center' }} onPress={() => onSelectInput()}>
164
- <Icons.MoreIcon size={24} color={Colors.text.h1} />
164
+ <Button float style={{ padding:15, width:45, marginRight:5, borderRadius:8, justifyContent:'center', alignItems:'center' }} onPress={() => onSelectInput()}>
165
+ <Icons.MoreIcon size={18} color={Colors.text.h1} />
165
166
  </Button>
166
167
  :<></>}
167
- <View type={hide_border?undefined:'input'} style={{ flex:1, flexDirection:'row' }}>
168
+ <View type={hide_border?undefined:'input'} style={{ flex:1, flexDirection:'row', marginLeft:4, marginRight:4 }}>
168
169
  <TextInput
169
170
  value={text}
170
171
  editable={!action_loading}
@@ -51,7 +51,7 @@ const PostReactionBar = ({ post_id, loading, post_reaction_stats, my_post_reacti
51
51
  const my_reaction = my_post_reactions?.find(pr => pr.reaction === data.item.reaction)
52
52
  const selected = my_reaction?.status === 'visible' ? true : false
53
53
  return (
54
- <Button style={
54
+ <Button transparent style={
55
55
  reacted ?
56
56
  { ...view_styles.float, marginBottom:5, marginLeft:data.index===0?0:-5, paddingRight:10, paddingLeft:5, flexDirection:'row', alignItems:'center', padding:2, borderRadius:100, backgroundColor:selected?Colors.text.success:Colors.text.white }
57
57
  :
@@ -24,6 +24,7 @@ type PostCardProps = {
24
24
  orders:OrderProps[],
25
25
  player_id?:string,
26
26
  width:number,
27
+ refresh_key?:string,
27
28
  onSelectImage:(image:{ url:string, width?:number, height?:number}) => void,
28
29
  onSelectTag:(tag:TextTagProps) => void,
29
30
  onSelectArticle:(article:ArticleProps) => void,
@@ -36,7 +37,7 @@ type PostCardProps = {
36
37
 
37
38
  const sections = ['header', 'title', 'body', 'orders','images','articles', 'urls', 'footer']
38
39
 
39
- const PostCard = ({ player_id, width, articles, post, player, orders, onRequestAuthenticate, onSelectArticle, onCopyOrder, onFadeOrder, onViewComments, onSelectImage, onSelectPlayer, onSelectTag }:PostCardProps) => {
40
+ const PostCard = ({ player_id, width, articles, post, player, orders, refresh_key, onRequestAuthenticate, onSelectArticle, onCopyOrder, onFadeOrder, onViewComments, onSelectImage, onSelectPlayer, onSelectTag }:PostCardProps) => {
40
41
  const Colors = useColors();
41
42
  const [ post_data, setPostData ] = useState<{
42
43
  loading:boolean,
@@ -64,14 +65,23 @@ const PostCard = ({ player_id, width, articles, post, player, orders, onRequestA
64
65
  const is_in_viewport = useIsInViewport(post_ref);
65
66
 
66
67
  useEffect(() => {
67
- if(!is_in_viewport || reactions_loaded){ return }
68
+ if(!is_in_viewport){ return }
69
+ if(reactions_loaded){ return }
68
70
  SocialProfileApi.setEnvironment();
69
71
  getPostReactionData();
70
72
  if(player_id){ getMyData(player_id) }
71
73
  },[is_in_viewport]);
72
74
 
73
- const getMyData = async(player_id:string) => {
74
- setMyData({ ...my_data, my_data_loading: true });
75
+ useEffect(() => {
76
+ if(!refresh_key){ return }
77
+ if(!reactions_loaded){ return }
78
+ if(!is_in_viewport){ return }
79
+ getPostReactionData(true);
80
+ if(player_id){ getMyData(player_id, true) }
81
+ },[refresh_key]);
82
+
83
+ const getMyData = async(player_id:string, quiet?:boolean) => {
84
+ if(!quiet){ setMyData({ ...my_data, my_data_loading: true }) }
75
85
  const mr = await SocialProfileApi.getReactionsByPostAndPlayer(player_id, post.memo_post_id, 'memo');
76
86
  setMyData({
77
87
  ...my_data,
@@ -80,8 +90,8 @@ const PostCard = ({ player_id, width, articles, post, player, orders, onRequestA
80
90
  })
81
91
  }
82
92
 
83
- const getPostReactionData = async() => {
84
- setPostData({ ...post_data, loading: true });
93
+ const getPostReactionData = async(quiet?:boolean) => {
94
+ if(!quiet){ setPostData({ ...post_data, loading: true }) }
85
95
  const pr_stats = await SocialProfileApi.getReactionStatsByPostId(post.memo_post_id, 'memo');
86
96
  const pc_stat = await SocialProfileApi.getCommentStatsByPostId(post.memo_post_id, 'memo');
87
97
  setPostData({
@@ -215,7 +225,7 @@ const PostCard = ({ player_id, width, articles, post, player, orders, onRequestA
215
225
  case 'footer':
216
226
  return (
217
227
  <View type='footer' style={{ flexDirection:'row', alignItems:'center', padding:5, borderBottomRightRadius:8, borderBottomLeftRadius:8 }}>
218
- <View float transparent style={{ padding:5 }}>
228
+ <View transparent style={{ flex:1, padding:5 }}>
219
229
  <PostReactionBar
220
230
  loading={my_data_loading}
221
231
  post_id={post.memo_post_id}
@@ -226,7 +236,8 @@ const PostCard = ({ player_id, width, articles, post, player, orders, onRequestA
226
236
  </View>
227
237
  {onViewComments ?
228
238
  <Button
229
- style={{ flex:1, flexDirection:'row', alignItems:'center', justifyContent:'flex-end' }}
239
+ transparent
240
+ style={{ flexDirection:'row', alignItems:'center', justifyContent:'flex-end' }}
230
241
  onPress={() => onViewComments(post.memo_post_id)}
231
242
  >
232
243
  <Text style={{ marginRight:4 }} theme='h2'>{post_comment_stat.comment_count}</Text>
@@ -48,7 +48,7 @@ const Poster = ({ width, post_id, insets, onCreatePost, onSelectImage, onClose }
48
48
  let ords:OrderProps[] = []
49
49
  let playrs:PublicPlayerProps[] = []
50
50
  if(post_id){
51
- existing_post = await SocialComponentApi.getPostById(post_id);
51
+ existing_post = await SocialComponentApi.getPostById(post_id, 'memo');
52
52
  if(existing_post){
53
53
  const set_up_data = await SocialComponentHelpers.getPostsData([existing_post]);
54
54
  ords = set_up_data.orders