fix: split undefined error
This commit is contained in:
@@ -22,7 +22,7 @@ interface Data {
|
||||
}
|
||||
|
||||
const renderPreview = (data: Data) => {
|
||||
const { file_type, name, content } = data;
|
||||
const { file_type, name = "", content } = data;
|
||||
let preview: null | ReactElement = null;
|
||||
|
||||
const checks = {
|
||||
|
||||
@@ -60,12 +60,19 @@ const User: FC<Props> = ({
|
||||
const nameClass = clsx(
|
||||
`text-sm text-gray-500 max-w-[190px] truncate font-semibold dark:text-white`
|
||||
);
|
||||
const statusContainerClass = `absolute -bottom-[2.5px] -right-[2.5px] border-content rounded-full border-[1px] border-white dark:border-gray-300`;
|
||||
const statusClass = clsx(
|
||||
`absolute -bottom-[2.5px] -right-[2.5px] border-content rounded-full border-[1px] border-white dark:border-gray-300`,
|
||||
statusContainerClass,
|
||||
online ? "bg-green-500" : "bg-zinc-400",
|
||||
compact ? "w-[15px] h-[15px]" : "w-3 h-3"
|
||||
);
|
||||
const statusElement = showStatus ? <div className={statusClass}></div> : null;
|
||||
const statusElement = curr.is_bot ? (
|
||||
<div className={statusContainerClass}>
|
||||
<IconBot className={compact ? "w-[15px] h-[15px]" : "w-3 h-3"} />
|
||||
</div>
|
||||
) : showStatus ? (
|
||||
<div className={statusClass}></div>
|
||||
) : null;
|
||||
if (!popover)
|
||||
return (
|
||||
<ContextMenu
|
||||
@@ -102,7 +109,6 @@ const User: FC<Props> = ({
|
||||
</span>
|
||||
)}
|
||||
{!compact && curr.is_admin && !curr.is_bot && <IconAdmin />}
|
||||
{!compact && curr.is_bot && <IconBot />}
|
||||
</div>
|
||||
</ContextMenu>
|
||||
);
|
||||
@@ -147,7 +153,6 @@ const User: FC<Props> = ({
|
||||
</span>
|
||||
)}
|
||||
{!compact && curr.is_admin && !curr.is_bot && <IconAdmin />}
|
||||
{!compact && curr.is_bot && <IconBot className="!w-4 !h-4" />}
|
||||
</div>
|
||||
</Tippy>
|
||||
</ContextMenu>
|
||||
|
||||
+6
-4
@@ -109,6 +109,7 @@ export const getImageSize = (url: string) => {
|
||||
});
|
||||
};
|
||||
export const getInitials = (name: string, length: number = 4) => {
|
||||
if (!name) return "";
|
||||
const arr = name
|
||||
.split(
|
||||
// eslint-disable-next-line no-misleading-character-class
|
||||
@@ -181,7 +182,7 @@ export const getFileIcon = (type: string, name = "", className = "icon") => {
|
||||
doc: /^text/gi,
|
||||
pdf: /\/pdf$/gi
|
||||
};
|
||||
const _arr = name.split(".");
|
||||
const _arr = (name ?? "").split(".");
|
||||
const _type = type || _arr[_arr.length - 1];
|
||||
switch (true) {
|
||||
case checks.image.test(_type):
|
||||
@@ -305,14 +306,14 @@ export const compareVersion = (
|
||||
) => {
|
||||
//remove anything after - 1.1.2-3-a4agbr-dirty
|
||||
function cropDash(s: string) {
|
||||
let idx = (s ?? "").indexOf("-");
|
||||
let idx = s.indexOf("-");
|
||||
if (idx !== -1) {
|
||||
s = s.substring(0, idx);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
v1 = cropDash(v1);
|
||||
v2 = cropDash(v2);
|
||||
v1 = cropDash(v1 ?? "");
|
||||
v2 = cropDash(v2 ?? "");
|
||||
let lexicographical = options && options.lexicographical,
|
||||
zeroExtend = options && options.zeroExtend,
|
||||
v1parts = v1.split("."),
|
||||
@@ -357,6 +358,7 @@ export const compareVersion = (
|
||||
* @return {String} The contrasting color (black or white)
|
||||
*/
|
||||
export const getContrastColor = (hexcolor: string) => {
|
||||
if (!hexcolor) return "";
|
||||
// If a leading # is provided, remove it
|
||||
if (hexcolor.slice(0, 1) === "#") {
|
||||
hexcolor = hexcolor.slice(1);
|
||||
|
||||
Reference in New Issue
Block a user