mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
more timeout mess aroundary
This commit is contained in:
1 parent
9cccf91a84
commit
8191a9431c
5 files changed
+27
-22
No files matched your search
@@ -35,7 +35,7 @@ export default function AlertBar() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!createMessageGroupResult) return;
|
if (!createMessageGroupResult) return;
|
||||||
|
|
||||||
const { error, phoneNumber, duplicate } = createMessageGroupResult;
|
const { error, phoneNumber, duplicate, mine } = createMessageGroupResult;
|
||||||
if (error && phoneNumber) {
|
if (error && phoneNumber) {
|
||||||
const error = `${t("APPS_MESSAGES_INVALID_PHONE_NUMBER")}${phoneNumber}`;
|
const error = `${t("APPS_MESSAGES_INVALID_PHONE_NUMBER")}${phoneNumber}`;
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
@@ -45,6 +45,10 @@ export default function AlertBar() {
|
|||||||
setOpen(true);
|
setOpen(true);
|
||||||
setSeverity("error");
|
setSeverity("error");
|
||||||
setMessage(t("APPS_MESSAGES_MESSAGE_GROUP_DUPLICATE"));
|
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) {
|
} else if (error) {
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
setSeverity("error");
|
setSeverity("error");
|
||||||
|
|||||||
@@ -27,11 +27,24 @@ export const MessageModal = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!activeMessageGroup?.groupId) return;
|
||||||
|
|
||||||
const timeout = window.setTimeout(() => {
|
const timeout = window.setTimeout(() => {
|
||||||
setMimimumLoadPassed(true);
|
setMimimumLoadPassed(true);
|
||||||
}, MINIMUM_LOAD_TIME);
|
}, 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(() => {
|
useEffect(() => {
|
||||||
// when we get a new message group we should scroll to the
|
// when we get a new message group we should scroll to the
|
||||||
@@ -44,14 +57,6 @@ export const MessageModal = () => {
|
|||||||
}
|
}
|
||||||
}, [minimumLoadPassed, messages?.length]);
|
}, [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
|
// we add a minimum (but short) load time here so that
|
||||||
// there isn't a quick flash of loading and immediately
|
// there isn't a quick flash of loading and immediately
|
||||||
// another flash to the tweets screen.
|
// another flash to the tweets screen.
|
||||||
|
|||||||
@@ -23,4 +23,5 @@ export interface CreateMessageGroupResult {
|
|||||||
phoneNumber?: string;
|
phoneNumber?: string;
|
||||||
duplicate?: boolean;
|
duplicate?: boolean;
|
||||||
groupId?: string;
|
groupId?: string;
|
||||||
|
mine?: boolean;
|
||||||
}
|
}
|
||||||
@@ -60,6 +60,7 @@
|
|||||||
"APPS_MESSAGES_NEW_MESSAGE_GROUP_SUBMIT": "Submit",
|
"APPS_MESSAGES_NEW_MESSAGE_GROUP_SUBMIT": "Submit",
|
||||||
"APPS_MESSAGES_INVALID_PHONE_NUMBER": "Invalid phone number: ",
|
"APPS_MESSAGES_INVALID_PHONE_NUMBER": "Invalid phone number: ",
|
||||||
"APPS_MESSAGES_MESSAGE_GROUP_DUPLICATE": "This message group already exists",
|
"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!"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,17 +180,6 @@ async function checkIfMessageGroupExists(groupId: string): Promise<boolean> {
|
|||||||
return count > 0;
|
return count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getParticipantsByGroup(groupId: string): Promise<string[]> {
|
|
||||||
const query = `
|
|
||||||
SELECT participant_identifier as identifier
|
|
||||||
FROM npwd_messages_groups
|
|
||||||
WHERE group_id = ?;
|
|
||||||
`;
|
|
||||||
const [results] = await pool.query(query, [ groupId]);
|
|
||||||
const rows = (<any>results);
|
|
||||||
return rows.map((row: any) => row.identifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consolidate raw message groups into a mapping that groups participants
|
* Consolidate raw message groups into a mapping that groups participants
|
||||||
* by the message group. The goal of this is to reduce the rows of message
|
* by the message group. The goal of this is to reduce the rows of message
|
||||||
@@ -267,6 +256,11 @@ async function createMessageGroupsFromPhoneNumbers(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// don't allow explicitly adding yourself
|
||||||
|
if (identifiers.some(identifier => identifier === userIdentifier)) {
|
||||||
|
return { error: true, mine: true };
|
||||||
|
}
|
||||||
|
|
||||||
// make sure we are always in a consistent order. It is very important
|
// make sure we are always in a consistent order. It is very important
|
||||||
// that this not change! Changing this order can result in the ability
|
// that this not change! Changing this order can result in the ability
|
||||||
// of duplicate message groups being created.
|
// of duplicate message groups being created.
|
||||||
|
|||||||
Reference in new issue
Block a user