mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00
addressing type warnings; account for no-messages returned
This commit is contained in:
parent
422f37c477
commit
12201d0088
6
web/package-lock.json
generated
6
web/package-lock.json
generated
@ -1575,6 +1575,12 @@
|
||||
"moment": "^2.10.2"
|
||||
}
|
||||
},
|
||||
"@types/classnames": {
|
||||
"version": "2.2.11",
|
||||
"resolved": "https://registry.npmjs.org/@types/classnames/-/classnames-2.2.11.tgz",
|
||||
"integrity": "sha512-2koNhpWm3DgWRp5tpkiJ8JGc1xTn2q0l+jUNUE7oMKXUf5NpI9AIdC4kbjGNFBdHtcxBD18LAksoudAVhFKCjw==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/color-name": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
|
||||
|
@ -24,6 +24,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chart.js": "^2.9.28",
|
||||
"@types/classnames": "^2.2.11",
|
||||
"@types/node": "^14.11.2",
|
||||
"@types/prop-types": "^15.7.3",
|
||||
"@types/react": "^16.9.49",
|
||||
|
@ -2,12 +2,12 @@ import React, { useState, useEffect } from "react";
|
||||
import { Table, Typography, Tooltip, Button } from "antd";
|
||||
import { CheckCircleFilled, ExclamationCircleFilled, StopOutlined } from "@ant-design/icons";
|
||||
import classNames from 'classnames';
|
||||
import { RowSelectionType } from "antd/es/table/interface";
|
||||
import { ColumnsType } from 'antd/es/table';
|
||||
import format from 'date-fns/format'
|
||||
|
||||
import { CHAT_HISTORY, fetchData, UPDATE_CHAT_MESSGAE_VIZ } from "../utils/apis";
|
||||
import { MessageType } from '../types/chat';
|
||||
import { isEmptyObject } from "../utils/format";
|
||||
|
||||
const { Title } = Typography;
|
||||
|
||||
@ -47,7 +47,11 @@ export default function Chat() {
|
||||
const getInfo = async () => {
|
||||
try {
|
||||
const result = await fetchData(CHAT_HISTORY, { auth: true });
|
||||
setMessages(result);
|
||||
if (isEmptyObject(result)) {
|
||||
setMessages([]);
|
||||
} else {
|
||||
setMessages(result);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("==== error", error);
|
||||
}
|
||||
@ -62,9 +66,9 @@ export default function Chat() {
|
||||
|
||||
const nameFilters = createUserNameFilters(messages);
|
||||
|
||||
const rowSelection: RowSelectionType = {
|
||||
const rowSelection = {
|
||||
selectedRowKeys,
|
||||
onChange: selectedKeys => {
|
||||
onChange: (selectedKeys: string[]) => {
|
||||
setSelectedRows(selectedKeys);
|
||||
},
|
||||
};
|
||||
|
@ -15,9 +15,10 @@ export function formatIPAddress(ipAddress: string): string {
|
||||
|
||||
// check if obj is {}
|
||||
export function isEmptyObject(obj) {
|
||||
return !obj || Object.keys(obj).length === 0;
|
||||
return !obj || (Object.keys(obj).length === 0 && obj.constructor === Object);
|
||||
}
|
||||
|
||||
|
||||
export function parseSecondsToDurationString(seconds = 0) {
|
||||
const finiteSeconds = Number.isFinite(+seconds) ? Math.abs(seconds) : 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user