Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
addressing type warnings; account for no-messages returned
gingervitis12201d008834
diff --git a/web/package-lock.json b/web/package-lock.jsonindex 9ba0310bd4..0fc497d0be 100644--- a/web/package-lock.json+++ b/web/package-lock.json@@ -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",diff --git a/web/package.json b/web/package.jsonindex 2e7d684aa0..f61e05f811 100644--- a/web/package.json+++ b/web/package.json@@ -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",diff --git a/web/pages/chat.tsx b/web/pages/chat.tsxindex f82eb9ef90..fe7d1bdffc 100644--- a/web/pages/chat.tsx+++ b/web/pages/chat.tsx@@ -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);},};diff --git a/web/utils/format.ts b/web/utils/format.tsindex a34ce1773c..549f8b8260 100644--- a/web/utils/format.ts+++ b/web/utils/format.ts@@ -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;