Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
fix: no-nested-ternary warning
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathakurxd authored Jan 24, 2024
1 parent 8e99216 commit 2c95597
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 25 deletions.
15 changes: 10 additions & 5 deletions src/components/AppData/useSidepane.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,18 @@ export const useWidgetToggle = () => {
const toggleWidget = useCallback(
id => {
id = typeof id === "string" ? id : undefined;
let viewToShow;
if (id) {
viewToShow = WIDGET_VIEWS.VOTE;
} else if (widgetView) {
viewToShow = null;
} else {
viewToShow = WIDGET_VIEWS.LANDING;
}

setWidgetState({
[WIDGET_STATE.pollInView]: id,
[WIDGET_STATE.view]: id
? WIDGET_VIEWS.VOTE
: widgetView
? null
: WIDGET_VIEWS.LANDING,
[WIDGET_STATE.view]: viewToShow,
});
},
[widgetView, setWidgetState]
Expand Down
21 changes: 13 additions & 8 deletions src/components/Chat/Chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,19 @@ export const Chat = () => {
CHAT_SELECTOR.ROLE
);
const peerName = useHMSStore(selectPeerNameByID(peerSelector));
const [chatOptions, setChatOptions] = useState({
role: roleSelector || "",
peerId: peerSelector && peerName ? peerSelector : "",
selection: roleSelector
? roleSelector
: peerSelector && peerName
? peerName
: "Everyone",
const [chatOptions, setChatOptions] = useState(() => {
const roleValue = roleSelector || "";
const peerIdValue = peerSelector && peerName ? peerSelector : "";
const selectionValue =
roleSelector || (peerSelector && peerName)
? roleSelector || peerName
: "Everyone";

return {
role: roleValue,
peerId: peerIdValue,
selection: selectionValue,
};
});
const [isSelectorOpen, setSelectorOpen] = useState(false);
const listRef = useRef(null);
Expand Down
14 changes: 9 additions & 5 deletions src/components/Chat/useUnreadCount.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ import {
} from "@100mslive/react-sdk";

export const useUnreadCount = ({ role, peerId }) => {
const unreadCountSelector = role
? selectMessagesUnreadCountByRole(role)
: peerId
? selectMessagesUnreadCountByPeerID(peerId)
: selectUnreadHMSMessagesCount;
let unreadCountSelector;

if (role) {
unreadCountSelector = selectMessagesUnreadCountByRole(role);
} else if (peerId) {
unreadCountSelector = selectMessagesUnreadCountByPeerID(peerId);
} else {
unreadCountSelector = selectUnreadHMSMessagesCount;
}

const unreadCount = useHMSStore(unreadCountSelector);
return unreadCount;
Expand Down
15 changes: 8 additions & 7 deletions src/components/hooks/useSetPinnedMessage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-check
import { useCallback } from "react";
import {
selectPeerNameByID,
Expand All @@ -23,14 +22,16 @@ export const useSetPinnedMessage = () => {
* @param {import("@100mslive/react-sdk").HMSMessage | undefined} message
*/
async message => {
const senderId = message?.sender;
const peerName =
vanillaStore.getState(selectPeerNameByID(message?.sender)) ||
vanillaStore.getState(selectPeerNameByID(senderId)) ||
message?.senderName;
const newPinnedMessage = message
? peerName
? `${peerName}: ${message.message}`
: message.message
: null;

const messageContent = message ? message.message : null;
const newPinnedMessage = peerName
? `${peerName}: ${messageContent}`
: messageContent;

if (newPinnedMessage !== pinnedMessage) {
await hmsActions.sessionStore
.set(SESSION_STORE_KEY.PINNED_MESSAGE, newPinnedMessage)
Expand Down

2 comments on commit 2c95597

@vercel
Copy link

@vercel vercel bot commented on 2c95597 Jan 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

100ms-web – ./

100ms-web-ten.vercel.app
100ms-web-git-main-ragzzy.vercel.app
100ms-web-ragzzy.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 2c95597 Jan 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.