[FIX] Omnichannel's icon svg fallback when the link returns an error (#4916)
* [FIX] Omnichannel's icon svg fallback when the link returns an error * add activity indicator * switch between activity indicator to custom icon * reuse the same component as const
This commit is contained in:
parent
da5e06fec4
commit
c5e1b9e7fd
|
@ -1,4 +1,4 @@
|
||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import { StyleProp, ViewStyle } from 'react-native';
|
import { StyleProp, ViewStyle } from 'react-native';
|
||||||
import { SvgUri } from 'react-native-svg';
|
import { SvgUri } from 'react-native-svg';
|
||||||
|
|
||||||
|
@ -29,22 +29,12 @@ interface IOmnichannelRoomIconProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const OmnichannelRoomIcon = ({ size, style, sourceType, status }: IOmnichannelRoomIconProps) => {
|
export const OmnichannelRoomIcon = ({ size, style, sourceType, status }: IOmnichannelRoomIconProps) => {
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [svgError, setSvgError] = useState(false);
|
||||||
const baseUrl = useAppSelector(state => state.server?.server);
|
const baseUrl = useAppSelector(state => state.server?.server);
|
||||||
const connected = useAppSelector(state => state.meteor?.connected);
|
const connected = useAppSelector(state => state.meteor?.connected);
|
||||||
|
|
||||||
if (sourceType?.type === OmnichannelSourceType.APP && sourceType.id && sourceType.sidebarIcon && connected) {
|
const customIcon = (
|
||||||
return (
|
|
||||||
<SvgUri
|
|
||||||
height={size}
|
|
||||||
width={size}
|
|
||||||
color={STATUS_COLORS[status || 'offline']}
|
|
||||||
uri={`${baseUrl}/api/apps/public/${sourceType.id}/get-sidebar-icon?icon=${sourceType.sidebarIcon}`}
|
|
||||||
style={style}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<CustomIcon
|
<CustomIcon
|
||||||
name={iconMap[sourceType?.type || 'other']}
|
name={iconMap[sourceType?.type || 'other']}
|
||||||
size={size}
|
size={size}
|
||||||
|
@ -52,4 +42,23 @@ export const OmnichannelRoomIcon = ({ size, style, sourceType, status }: IOmnich
|
||||||
color={STATUS_COLORS[status || 'offline']}
|
color={STATUS_COLORS[status || 'offline']}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!svgError && sourceType?.type === OmnichannelSourceType.APP && sourceType.id && sourceType.sidebarIcon && connected) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<SvgUri
|
||||||
|
height={size}
|
||||||
|
width={size}
|
||||||
|
color={STATUS_COLORS[status || 'offline']}
|
||||||
|
uri={`${baseUrl}/api/apps/public/${sourceType.id}/get-sidebar-icon?icon=${sourceType.sidebarIcon}`}
|
||||||
|
style={style}
|
||||||
|
onError={() => setSvgError(true)}
|
||||||
|
onLoad={() => setLoading(false)}
|
||||||
|
/>
|
||||||
|
{loading ? customIcon : null}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return customIcon;
|
||||||
};
|
};
|
||||||
|
|
|
@ -571,7 +571,7 @@ PODS:
|
||||||
- RNScreens (3.13.1):
|
- RNScreens (3.13.1):
|
||||||
- React-Core
|
- React-Core
|
||||||
- React-RCTImage
|
- React-RCTImage
|
||||||
- RNSVG (12.3.0):
|
- RNSVG (13.8.0):
|
||||||
- React-Core
|
- React-Core
|
||||||
- RNVectorIcons (9.1.0):
|
- RNVectorIcons (9.1.0):
|
||||||
- React-Core
|
- React-Core
|
||||||
|
@ -992,7 +992,7 @@ SPEC CHECKSUMS:
|
||||||
RNReanimated: 64573e25e078ae6bec03b891586d50b9ec284393
|
RNReanimated: 64573e25e078ae6bec03b891586d50b9ec284393
|
||||||
RNRootView: 895a4813dedeaca82db2fa868ca1c333d790e494
|
RNRootView: 895a4813dedeaca82db2fa868ca1c333d790e494
|
||||||
RNScreens: 40a2cb40a02a609938137a1e0acfbf8fc9eebf19
|
RNScreens: 40a2cb40a02a609938137a1e0acfbf8fc9eebf19
|
||||||
RNSVG: 302bfc9905bd8122f08966dc2ce2d07b7b52b9f8
|
RNSVG: c1e76b81c76cdcd34b4e1188852892dc280eb902
|
||||||
RNVectorIcons: 7923e585eaeb139b9f4531d25a125a1500162a0b
|
RNVectorIcons: 7923e585eaeb139b9f4531d25a125a1500162a0b
|
||||||
SDWebImage: a47aea9e3d8816015db4e523daff50cfd294499d
|
SDWebImage: a47aea9e3d8816015db4e523daff50cfd294499d
|
||||||
SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d
|
SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d
|
||||||
|
|
|
@ -122,7 +122,7 @@
|
||||||
"react-native-simple-crypto": "RocketChat/react-native-simple-crypto#0.5.1",
|
"react-native-simple-crypto": "RocketChat/react-native-simple-crypto#0.5.1",
|
||||||
"react-native-skeleton-placeholder": "^5.2.3",
|
"react-native-skeleton-placeholder": "^5.2.3",
|
||||||
"react-native-slowlog": "^1.0.2",
|
"react-native-slowlog": "^1.0.2",
|
||||||
"react-native-svg": "^12.3.0",
|
"react-native-svg": "^13.8.0",
|
||||||
"react-native-ui-lib": "RocketChat/react-native-ui-lib",
|
"react-native-ui-lib": "RocketChat/react-native-ui-lib",
|
||||||
"react-native-vector-icons": "9.1.0",
|
"react-native-vector-icons": "9.1.0",
|
||||||
"react-native-webview": "10.3.2",
|
"react-native-webview": "10.3.2",
|
||||||
|
|
87
yarn.lock
87
yarn.lock
|
@ -9431,15 +9431,15 @@ css-select@^1.1.0:
|
||||||
domutils "1.5.1"
|
domutils "1.5.1"
|
||||||
nth-check "~1.0.1"
|
nth-check "~1.0.1"
|
||||||
|
|
||||||
css-select@^4.2.1:
|
css-select@^5.1.0:
|
||||||
version "4.2.1"
|
version "5.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/css-select/-/css-select-4.2.1.tgz#9e665d6ae4c7f9d65dbe69d0316e3221fb274cdd"
|
resolved "https://registry.yarnpkg.com/css-select/-/css-select-5.1.0.tgz#b8ebd6554c3637ccc76688804ad3f6a6fdaea8a6"
|
||||||
integrity sha512-/aUslKhzkTNCQUB2qTX84lVmfia9NyjP3WpDGtj/WxhwBzWBYUV3DgUpurHTme8UTPcPlAD1DJ+b0nN/t50zDQ==
|
integrity sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==
|
||||||
dependencies:
|
dependencies:
|
||||||
boolbase "^1.0.0"
|
boolbase "^1.0.0"
|
||||||
css-what "^5.1.0"
|
css-what "^6.1.0"
|
||||||
domhandler "^4.3.0"
|
domhandler "^5.0.2"
|
||||||
domutils "^2.8.0"
|
domutils "^3.0.1"
|
||||||
nth-check "^2.0.1"
|
nth-check "^2.0.1"
|
||||||
|
|
||||||
css-selector-parser@^1.0.0:
|
css-selector-parser@^1.0.0:
|
||||||
|
@ -9456,7 +9456,7 @@ css-to-react-native@^2.2.1:
|
||||||
css-color-keywords "^1.0.0"
|
css-color-keywords "^1.0.0"
|
||||||
postcss-value-parser "^3.3.0"
|
postcss-value-parser "^3.3.0"
|
||||||
|
|
||||||
css-tree@^1.0.0-alpha.39:
|
css-tree@^1.1.3:
|
||||||
version "1.1.3"
|
version "1.1.3"
|
||||||
resolved "https://registry.yarnpkg.com/css-tree/-/css-tree-1.1.3.tgz#eb4870fb6fd7707327ec95c2ff2ab09b5e8db91d"
|
resolved "https://registry.yarnpkg.com/css-tree/-/css-tree-1.1.3.tgz#eb4870fb6fd7707327ec95c2ff2ab09b5e8db91d"
|
||||||
integrity sha512-tRpdppF7TRazZrjJ6v3stzv93qxRcSsFmW6cX0Zm2NVKpxE1WV1HblnghVv9TreireHkqI/VDEsfolRF1p6y7Q==
|
integrity sha512-tRpdppF7TRazZrjJ6v3stzv93qxRcSsFmW6cX0Zm2NVKpxE1WV1HblnghVv9TreireHkqI/VDEsfolRF1p6y7Q==
|
||||||
|
@ -9469,10 +9469,10 @@ css-what@2.1:
|
||||||
resolved "https://registry.yarnpkg.com/css-what/-/css-what-2.1.3.tgz#a6d7604573365fe74686c3f311c56513d88285f2"
|
resolved "https://registry.yarnpkg.com/css-what/-/css-what-2.1.3.tgz#a6d7604573365fe74686c3f311c56513d88285f2"
|
||||||
integrity sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==
|
integrity sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==
|
||||||
|
|
||||||
css-what@^5.1.0:
|
css-what@^6.1.0:
|
||||||
version "5.1.0"
|
version "6.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/css-what/-/css-what-5.1.0.tgz#3f7b707aadf633baf62c2ceb8579b545bb40f7fe"
|
resolved "https://registry.yarnpkg.com/css-what/-/css-what-6.1.0.tgz#fb5effcf76f1ddea2c81bdfaa4de44e79bac70f4"
|
||||||
integrity sha512-arSMRWIIFY0hV8pIxZMEfmMI47Wj3R/aWpZDDxWYCPEiOMv6tfOrnpDtgxBYPEQD4V0Y/958+1TdC3iWTFcUPw==
|
integrity sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==
|
||||||
|
|
||||||
cssesc@^3.0.0:
|
cssesc@^3.0.0:
|
||||||
version "3.0.0"
|
version "3.0.0"
|
||||||
|
@ -9872,14 +9872,14 @@ dom-serializer@0:
|
||||||
domelementtype "^2.0.1"
|
domelementtype "^2.0.1"
|
||||||
entities "^2.0.0"
|
entities "^2.0.0"
|
||||||
|
|
||||||
dom-serializer@^1.0.1:
|
dom-serializer@^2.0.0:
|
||||||
version "1.3.2"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-1.3.2.tgz#6206437d32ceefaec7161803230c7a20bc1b4d91"
|
resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-2.0.0.tgz#e41b802e1eedf9f6cae183ce5e622d789d7d8e53"
|
||||||
integrity sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig==
|
integrity sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==
|
||||||
dependencies:
|
dependencies:
|
||||||
domelementtype "^2.0.1"
|
domelementtype "^2.3.0"
|
||||||
domhandler "^4.2.0"
|
domhandler "^5.0.2"
|
||||||
entities "^2.0.0"
|
entities "^4.2.0"
|
||||||
|
|
||||||
dom-walk@^0.1.0:
|
dom-walk@^0.1.0:
|
||||||
version "0.1.2"
|
version "0.1.2"
|
||||||
|
@ -9901,10 +9901,10 @@ domelementtype@^2.0.1:
|
||||||
resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.0.1.tgz#1f8bdfe91f5a78063274e803b4bdcedf6e94f94d"
|
resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.0.1.tgz#1f8bdfe91f5a78063274e803b4bdcedf6e94f94d"
|
||||||
integrity sha512-5HOHUDsYZWV8FGWN0Njbr/Rn7f/eWSQi1v7+HsUVwXgn8nWWlL64zKDkS0n8ZmQ3mlWOMuXOnR+7Nx/5tMO5AQ==
|
integrity sha512-5HOHUDsYZWV8FGWN0Njbr/Rn7f/eWSQi1v7+HsUVwXgn8nWWlL64zKDkS0n8ZmQ3mlWOMuXOnR+7Nx/5tMO5AQ==
|
||||||
|
|
||||||
domelementtype@^2.2.0:
|
domelementtype@^2.3.0:
|
||||||
version "2.2.0"
|
version "2.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.2.0.tgz#9a0b6c2782ed6a1c7323d42267183df9bd8b1d57"
|
resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.3.0.tgz#5c45e8e869952626331d7aab326d01daf65d589d"
|
||||||
integrity sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==
|
integrity sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==
|
||||||
|
|
||||||
domhandler@^2.3.0:
|
domhandler@^2.3.0:
|
||||||
version "2.4.2"
|
version "2.4.2"
|
||||||
|
@ -9913,12 +9913,12 @@ domhandler@^2.3.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
domelementtype "1"
|
domelementtype "1"
|
||||||
|
|
||||||
domhandler@^4.2.0, domhandler@^4.3.0:
|
domhandler@^5.0.1, domhandler@^5.0.2:
|
||||||
version "4.3.1"
|
version "5.0.3"
|
||||||
resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-4.3.1.tgz#8d792033416f59d68bc03a5aa7b018c1ca89279c"
|
resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-5.0.3.tgz#cc385f7f751f1d1fc650c21374804254538c7d31"
|
||||||
integrity sha512-GrwoxYN+uWlzO8uhUXRl0P+kHE4GtVPfYzVLcUxPL7KNdHKj66vvlhiweIHqYYXWlw+T8iLMp42Lm67ghw4WMQ==
|
integrity sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==
|
||||||
dependencies:
|
dependencies:
|
||||||
domelementtype "^2.2.0"
|
domelementtype "^2.3.0"
|
||||||
|
|
||||||
domutils@1.5.1:
|
domutils@1.5.1:
|
||||||
version "1.5.1"
|
version "1.5.1"
|
||||||
|
@ -9936,14 +9936,14 @@ domutils@^1.5.1:
|
||||||
dom-serializer "0"
|
dom-serializer "0"
|
||||||
domelementtype "1"
|
domelementtype "1"
|
||||||
|
|
||||||
domutils@^2.8.0:
|
domutils@^3.0.1:
|
||||||
version "2.8.0"
|
version "3.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/domutils/-/domutils-2.8.0.tgz#4437def5db6e2d1f5d6ee859bd95ca7d02048135"
|
resolved "https://registry.yarnpkg.com/domutils/-/domutils-3.0.1.tgz#696b3875238338cb186b6c0612bd4901c89a4f1c"
|
||||||
integrity sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==
|
integrity sha512-z08c1l761iKhDFtfXO04C7kTdPBLi41zwOZl00WS8b5eiaebNpY00HKbztwBq+e3vyqWNwWF3mP9YLUeqIrF+Q==
|
||||||
dependencies:
|
dependencies:
|
||||||
dom-serializer "^1.0.1"
|
dom-serializer "^2.0.0"
|
||||||
domelementtype "^2.2.0"
|
domelementtype "^2.3.0"
|
||||||
domhandler "^4.2.0"
|
domhandler "^5.0.1"
|
||||||
|
|
||||||
dot-case@^3.0.3:
|
dot-case@^3.0.3:
|
||||||
version "3.0.3"
|
version "3.0.3"
|
||||||
|
@ -10162,6 +10162,11 @@ entities@^2.0.0:
|
||||||
resolved "https://registry.yarnpkg.com/entities/-/entities-2.0.2.tgz#ac74db0bba8d33808bbf36809c3a5c3683531436"
|
resolved "https://registry.yarnpkg.com/entities/-/entities-2.0.2.tgz#ac74db0bba8d33808bbf36809c3a5c3683531436"
|
||||||
integrity sha512-dmD3AvJQBUjKpcNkoqr+x+IF0SdRtPz9Vk0uTy4yWqga9ibB6s4v++QFWNohjiUGoMlF552ZvNyXDxz5iW0qmw==
|
integrity sha512-dmD3AvJQBUjKpcNkoqr+x+IF0SdRtPz9Vk0uTy4yWqga9ibB6s4v++QFWNohjiUGoMlF552ZvNyXDxz5iW0qmw==
|
||||||
|
|
||||||
|
entities@^4.2.0:
|
||||||
|
version "4.4.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/entities/-/entities-4.4.0.tgz#97bdaba170339446495e653cfd2db78962900174"
|
||||||
|
integrity sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA==
|
||||||
|
|
||||||
env-editor@^0.4.1:
|
env-editor@^0.4.1:
|
||||||
version "0.4.2"
|
version "0.4.2"
|
||||||
resolved "https://registry.yarnpkg.com/env-editor/-/env-editor-0.4.2.tgz#4e76568d0bd8f5c2b6d314a9412c8fe9aa3ae861"
|
resolved "https://registry.yarnpkg.com/env-editor/-/env-editor-0.4.2.tgz#4e76568d0bd8f5c2b6d314a9412c8fe9aa3ae861"
|
||||||
|
@ -17500,13 +17505,13 @@ react-native-slowlog@^1.0.2:
|
||||||
resolved "https://registry.yarnpkg.com/react-native-slowlog/-/react-native-slowlog-1.0.2.tgz#5520979e3ef9d5273495d431ff3be34f02e35c89"
|
resolved "https://registry.yarnpkg.com/react-native-slowlog/-/react-native-slowlog-1.0.2.tgz#5520979e3ef9d5273495d431ff3be34f02e35c89"
|
||||||
integrity sha1-VSCXnj751Sc0ldQx/zvjTwLjXIk=
|
integrity sha1-VSCXnj751Sc0ldQx/zvjTwLjXIk=
|
||||||
|
|
||||||
react-native-svg@^12.3.0:
|
react-native-svg@^13.8.0:
|
||||||
version "12.3.0"
|
version "13.8.0"
|
||||||
resolved "https://registry.yarnpkg.com/react-native-svg/-/react-native-svg-12.3.0.tgz#40f657c5d1ee366df23f3ec8dae76fd276b86248"
|
resolved "https://registry.yarnpkg.com/react-native-svg/-/react-native-svg-13.8.0.tgz#b6a22cf77f8098f910490a13aeb160a37e182f97"
|
||||||
integrity sha512-ESG1g1j7/WLD7X3XRFTQHVv0r6DpbHNNcdusngAODIxG88wpTWUZkhcM3A2HJTb+BbXTFDamHv7FwtRKWQ/ALg==
|
integrity sha512-G8Mx6W86da+vFimZBJvA93POw8yz0fgDS5biy6oIjMWVJVQSDzCyzwO/zY0yuZmCDhKSZzogl5m0wXXvW2OcTA==
|
||||||
dependencies:
|
dependencies:
|
||||||
css-select "^4.2.1"
|
css-select "^5.1.0"
|
||||||
css-tree "^1.0.0-alpha.39"
|
css-tree "^1.1.3"
|
||||||
|
|
||||||
react-native-swipe-gestures@^1.0.5:
|
react-native-swipe-gestures@^1.0.5:
|
||||||
version "1.0.5"
|
version "1.0.5"
|
||||||
|
|
Loading…
Reference in New Issue