toast cleanup

This commit is contained in:
talksik
2022-06-20 07:09:15 -05:00
parent 8b8c645ec4
commit 8a26212f50
4 changed files with 29 additions and 29 deletions
@@ -44,10 +44,11 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
fetchUser()
.then((response) => {
toast.success('authenticated user');
// toast.success('authenticated user');
})
.catch(() => {
toast.error('problem in authenticating jwt token');
.catch((error) => {
toast.error('problem in authenticating');
console.error(error);
});
}
}, [jwtToken, fetchUser]);
@@ -58,10 +59,10 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
fetchUser()
.then((response) => {
toast.success('authenticated user');
// toast.success('authenticated user');
})
.catch(() => {
toast.error('logged out');
.catch((error) => {
// toast.error('logged out');
});
setJwtToken(undefined);
@@ -98,7 +98,7 @@ export function ConversationProvider({ children }: { children: React.ReactNode }
$ws.on(ServerResponseChannels.SOMEONE_CONNECTED_TO_LINE, (res: SomeoneConnectedResponse) => {
setConversationMap((draft) => {
if (!draft[res.lineId]) {
toast.error('no line');
console.error('no line');
return;
}
@@ -110,7 +110,7 @@ export function ConversationProvider({ children }: { children: React.ReactNode }
$ws.on(ServerResponseChannels.SOMEONE_TUNED_INTO_LINE, (res: SomeoneTunedResponse) => {
setConversationMap((draft) => {
if (!draft[res.lineId]) {
toast.error('no line');
console.error('no line');
return;
}
@@ -123,7 +123,7 @@ export function ConversationProvider({ children }: { children: React.ReactNode }
(res: SomeoneUntunedFromLineResponse) => {
setConversationMap((draft) => {
if (!draft[res.lineId]) {
toast.error('no line');
console.error('no line');
return;
}
@@ -141,7 +141,7 @@ export function ConversationProvider({ children }: { children: React.ReactNode }
(res: SomeoneDisconnectedResponse) => {
setConversationMap((draft) => {
if (!draft[res.lineId]) {
toast.error('there was a problem updating rooms!!!');
console.error('there was a problem updating rooms!!!');
return;
}
@@ -208,8 +208,6 @@ export function ConversationProvider({ children }: { children: React.ReactNode }
let conversationToSelect: MasterConversation;
if (allConversationIds.includes(conversationId)) {
toast.success('we have that conversation!!!');
conversationToSelect = conversationMap[conversationId];
} else {
// TODO: somehow use handleAddToCache instead of this duplicated code
@@ -290,7 +288,8 @@ export function ConversationProvider({ children }: { children: React.ReactNode }
*/
if (!otherUsers || otherUsers.length === 0) {
toast.error('Must provider users');
toast.error('Must select other people!');
return false;
}
@@ -305,7 +304,7 @@ export function ConversationProvider({ children }: { children: React.ReactNode }
// if we found a conversation
if (conversationDmCheck.data) {
toast.success('already have this user...quick dialing');
console.log('already have this user...quick dialing');
selectConversation(conversationDmCheck.data, true);
return true;
@@ -318,8 +317,6 @@ export function ConversationProvider({ children }: { children: React.ReactNode }
selectConversation(createdConversationResult.data.conversationId.toString(), true);
toast.success('started conversation');
return true;
} catch (error) {
console.error(error);
@@ -464,11 +461,10 @@ function Room({
const allOtherUserIds = conversation.tunedInUsers.filter(
(memberUserId) => memberUserId !== user._id.toString(),
);
toast.success('calling bunch of people');
// for each person, create peer object
allOtherUserIds.forEach((otherUserId) => {
const connectingToast = toast.loading('calling peer for a snappy experience');
const connectingToast = toast.loading('connecting you for a snappy experience');
// ========= PEER CREATION =============
// make sure this peer gets destroyed when it's time to remove this listener
@@ -483,7 +479,7 @@ function Room({
// ========= PEER EVENT HANDLERS =============
localPeerConnection.on('signal', (signal) => {
console.log('have a signal to make call to someone ');
// console.log('have a signal to make call to someone ');
$ws.emit(
ServerRequestChannels.RTC_CALL_SOMEONE_FOR_LINE,
@@ -506,7 +502,7 @@ function Room({
localPeerConnection.on('stream', (remoteStream: MediaStream) => {
// globally updating conversation so that other views can render what they want
toast.success('got stream from remote, going to add to our ');
// toast.success('got stream from remote, going to add to our ');
console.log('got stream from master');
@@ -522,7 +518,7 @@ function Room({
});
localPeerConnection.on('connect', () => {
toast.success('successfully connected to another peer');
// toast.success('successfully connected to another peer');
setConversationMap((draft) => {
if (draft[conversation._id.toString()].room[otherUserId]) {
draft[conversation._id.toString()].room[otherUserId].isConnecting = false;
@@ -553,7 +549,7 @@ function Room({
localPeerConnection.on('error', (err) => {
console.error(err);
toast.error('there was a problem with the peer connection');
toast.error('there was a problem with the connecting');
});
});
}
@@ -570,7 +566,7 @@ function Room({
}:${conversation._id.toString()}`;
$ws.on(someoneJoinedChannelNameForRoom, (res: RtcNewUserJoinedResponse) => {
toast.success('NEWBIE JOINED!!!');
// toast.success('NEWBIE JOINED!!!');
console.log('someone calling me', res);
// todo, take trickle into account to not overwrite prev peer
@@ -606,7 +602,7 @@ function Room({
peerForMeAndNewbie.on('stream', (remoteStream: MediaStream) => {
// globally updating conversation so that other views can render what they want
toast.success('got stream from remote, going to add to our ');
// toast.success('got stream from remote, going to add to our ');
console.log('got stream from newbie');
@@ -654,12 +650,12 @@ function Room({
peerForMeAndNewbie.on('error', (err) => {
console.error(err);
toast.error('there was a problem with the peer connection');
toast.error('there was a problem with connecting');
});
});
$ws.on(mastersAnswerReceivedChannelNameForRoom, (res: RtcReceiveAnswerResponse) => {
toast.success('MASTER gave me an answer!!!');
// toast.success('MASTER gave me an answer!!!');
console.log('master gave me this answer: ', res);
@@ -24,7 +24,7 @@ export function SocketProvider({ children }: { children: React.ReactNode }) {
const initiateSocketStabilityListeners = useCallback(
(socketConnection: Socket) => {
socketConnection.on('connect', () => {
toast.success('sockets connected');
// toast.success('sockets connected');
});
socketConnection.io.on('close', () => {
@@ -88,8 +88,11 @@ export default function NewConversationDialog() {
return;
}
if (selectedUsers.length + 1 >= NirvanaRules.maxMembersPerConversation) {
toast.error('A group can only have 8 people including you!');
// everyone else + me should be less than or equal to max
if (selectedUsers.length + 1 > NirvanaRules.maxMembersPerConversation) {
toast.error(
`A group can only have ${NirvanaRules.maxMembersPerConversation} people including you!`,
);
return;
}