more timeout mess aroundary

This commit is contained in:
erik-sn committed 2020-11-21 10:09:20 -05:00
1 parent 9cccf91a84
commit 8191a9431c
5 files changed
+28 -23

No files matched your search

@@ -35,7 +35,7 @@ export default function AlertBar() {
useEffect(() => {
if (!createMessageGroupResult) return;
const { error, phoneNumber, duplicate } = createMessageGroupResult;
const { error, phoneNumber, duplicate, mine } = createMessageGroupResult;
if (error && phoneNumber) {
const error = `${t("APPS_MESSAGES_INVALID_PHONE_NUMBER")}${phoneNumber}`;
setOpen(true);
@@ -45,6 +45,10 @@ export default function AlertBar() {
setOpen(true);
setSeverity("error");
setMessage(t("APPS_MESSAGES_MESSAGE_GROUP_DUPLICATE"));
} else if (error && mine) {
setOpen(true);
setSeverity("error");
setMessage(t("APPS_MESSAGES_MESSAGE_GROUP_CREATE_MINE"));
} else if (error) {
setOpen(true);
setSeverity("error");
@@ -27,11 +27,24 @@ export const MessageModal = () => {
};
useEffect(() => {
if (!activeMessageGroup?.groupId) return;
const timeout = window.setTimeout(() => {
setMimimumLoadPassed(true);
}, MINIMUM_LOAD_TIME);
return () => window.clearTimeout(timeout);
});
const interval = window.setInterval(() => {
if (!activeMessageGroup) return;
Nui.send("phone:fetchMessages", {
groupId: activeMessageGroup.groupId,
});
}, MESSAGES_REFRESH_RATE);
return () => {
window.clearInterval(interval);
window.clearTimeout(timeout);
};
}, [activeMessageGroup?.groupId]);
useEffect(() => {
// when we get a new message group we should scroll to the
@@ -44,14 +57,6 @@ export const MessageModal = () => {
}
}, [minimumLoadPassed, messages?.length]);
useEffect(() => {
const interval = window.setInterval(() => {
if (!activeMessageGroup) return;
Nui.send("phone:fetchMessages", { groupId: activeMessageGroup.groupId });
}, MESSAGES_REFRESH_RATE);
return () => window.clearInterval(interval);
});
// we add a minimum (but short) load time here so that
// there isn't a quick flash of loading and immediately
// another flash to the tweets screen.
+1
View File
@@ -23,4 +23,5 @@ export interface CreateMessageGroupResult {
phoneNumber?: string;
duplicate?: boolean;
groupId?: string;
mine?: boolean;
}
+2 -1
View File
@@ -60,6 +60,7 @@
"APPS_MESSAGES_NEW_MESSAGE_GROUP_SUBMIT": "Submit",
"APPS_MESSAGES_INVALID_PHONE_NUMBER": "Invalid phone number: ",
"APPS_MESSAGES_MESSAGE_GROUP_DUPLICATE": "This message group already exists",
"APPS_MESSAGES_MESSAGE_GROUP_CREATE_FAILED": "Failed to create message group"
"APPS_MESSAGES_MESSAGE_GROUP_CREATE_FAILED": "Failed to create message group",
"APPS_MESSAGES_MESSAGE_GROUP_CREATE_MINE": "You cannot add yourself!"
}
}