mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
feat/messages additions (in memory of Leonard Nimoy) (#118)
* feat(resouces/messages): broadcast messagse to participants * feat(phone/messages): notifications for messages * remove weird empty onNet * reformat? * last reformat! This pr will be squashed * tweak(phone/messages): send groupName to notification alert * fix identifer * fixing notification groupName * resbasee...i think * feat(messages): check for unread messages * send nui event is count > 0 * remove usless test * import.sql update * Refactor NotificationsProvider and fix messages notifications * Send groupId on message broadcast * Update phone/src/apps/messages/components/modal/Conversation.tsx * Update phone/src/apps/messages/hooks/useMessageNotifications.ts * Update phone/src/os/notifications/providers/NotificationsProvider.tsx * Update phone/src/common/typings/messages.ts * Update phone/src/apps/messages/hooks/useMessageNotifications.ts * clean sql file * Update resources/server/sv_messages.ts * Fetch message groups when other person created for you * fix sql * Select unreadCount from messageGroups * whatever husky again * Add members menu and add contact in messages * Add from group bubbles * Fix messages scroll with new msg * Message image menu flicker + justify bottom messages * Improve debugging * Add container to Slider * Improve logger * Fix create message * add creator identifier to group hash * Fix dafuq i broke * group_id bigger varchar in column * group_id bigger varchar in column * Phone visibility default browser * Add debugging Co-authored-by: J Francisco Rader <[email protected]> Co-authored-by: J Francisco Rader <[email protected]>
This commit is contained in:
38 files changed
+634
-328
No files matched your search
@@ -65,7 +65,7 @@ export const useCallNotifications = () => {
|
||||
</CallNotification>
|
||||
),
|
||||
},
|
||||
true,
|
||||
(n) => addNotification(n)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@ InjectDebugData<CallProps | boolean>([
|
||||
app: 'CALL',
|
||||
method: 'setCaller',
|
||||
data: {
|
||||
accepted: false,
|
||||
accepted: true,
|
||||
isTransmitter: false,
|
||||
transmitter: 'Chip',
|
||||
receiver: 'Taso',
|
||||
|
||||
@@ -40,13 +40,13 @@ export const NotificationsContext = createContext<{
|
||||
icons: INotificationIcon[];
|
||||
count: number;
|
||||
removeAlerts(): void;
|
||||
addOrUpdateNotification(add: INotification, update?: INotification): void;
|
||||
addNotification(value: INotification): void;
|
||||
removeNotification(idx: number): void;
|
||||
updateId(id: string, value: Partial<INotification>): void;
|
||||
removeId(id: string): void;
|
||||
hasNotification(app: string): number;
|
||||
addNotificationAlert(n: INotification, persist: boolean, update?: Partial<INotification>);
|
||||
hasNotification(id: string): INotification | null;
|
||||
hasAppNotification(app: string): number;
|
||||
addNotificationAlert(n: INotification, cb?: (n: INotification) => void);
|
||||
}>(null);
|
||||
|
||||
export function NotificationsProvider({ children }) {
|
||||
@@ -62,7 +62,7 @@ export function NotificationsProvider({ children }) {
|
||||
|
||||
const alertTimeout = useRef<NodeJS.Timeout>();
|
||||
const [alerts, setAlerts] = useState<
|
||||
Array<[INotification, boolean, Partial<INotification>, string | undefined]>
|
||||
Array<[INotification, (n: INotification) => void, string | undefined]>
|
||||
>([]);
|
||||
const [currentAlert, setCurrentAlert] = useState<INotificationAlert>();
|
||||
|
||||
@@ -96,32 +96,28 @@ export function NotificationsProvider({ children }) {
|
||||
* Checks if a notification exists for current app
|
||||
* and returns its index or -1 if not found.
|
||||
*/
|
||||
const hasNotification = useCallback(
|
||||
const hasAppNotification = useCallback(
|
||||
(appId: string): number => {
|
||||
return notifications.findIndex((n) => n.app === appId);
|
||||
},
|
||||
[notifications],
|
||||
);
|
||||
|
||||
const addOrUpdateNotification = useCallback(
|
||||
(add: INotification, update?: INotification) => {
|
||||
const exists = hasNotification(add.app);
|
||||
if (update && exists !== -1) {
|
||||
updateNotification(exists, update);
|
||||
return;
|
||||
}
|
||||
addNotification(add);
|
||||
/**
|
||||
* Checks if a notification exists by its `id`
|
||||
*/
|
||||
const hasNotification = useCallback(
|
||||
(id: string): INotification | null => {
|
||||
return notifications.find((n) => n.id === id) || null;
|
||||
},
|
||||
[addNotification, hasNotification, updateNotification],
|
||||
[notifications]
|
||||
);
|
||||
|
||||
const _showAlert = useCallback(
|
||||
(n: INotification, persist: boolean, update: Partial<INotification>, soundUrl: string) => {
|
||||
(n: INotification, cb: (n: INotification) => void, soundUrl: string) => {
|
||||
return new Promise<void>((res) => {
|
||||
const resolve = () => {
|
||||
if (persist) {
|
||||
addOrUpdateNotification(n, update ? { ...n, ...update } : null);
|
||||
}
|
||||
cb?.(n);
|
||||
res();
|
||||
};
|
||||
|
||||
@@ -153,29 +149,25 @@ export function NotificationsProvider({ children }) {
|
||||
}, DEFAULT_ALERT_HIDE_TIME + 300);
|
||||
});
|
||||
},
|
||||
[addOrUpdateNotification, play],
|
||||
[play]
|
||||
);
|
||||
|
||||
const addNotificationAlert = (
|
||||
n: INotification,
|
||||
persist?: boolean,
|
||||
update?: Partial<INotification>,
|
||||
cb: (n: INotification) => void
|
||||
) => {
|
||||
if (n.sound) {
|
||||
const { sound, volume } = getSoundSettings('notiSound', settings, n.app);
|
||||
mount(sound, volume, false).then(({ url }) =>
|
||||
setAlerts((curr) => [...curr, [n, persist, update, url]]),
|
||||
setAlerts((curr) => [...curr, [n, cb, url]])
|
||||
);
|
||||
return;
|
||||
}
|
||||
setAlerts((curr) => [...curr, [n, persist, update, undefined]]);
|
||||
setAlerts((curr) => [...curr, [n, cb, undefined]]);
|
||||
};
|
||||
|
||||
const removeId = (id: string) => {
|
||||
const idx = notifications.findIndex((n) => n.id === id);
|
||||
if (idx !== -1) {
|
||||
removeNotification(idx);
|
||||
}
|
||||
setNotifications((curr) => curr.filter((n) => n.id !== id));
|
||||
};
|
||||
|
||||
const updateId = (id: string, value: Partial<INotification>) => {
|
||||
@@ -231,8 +223,8 @@ export function NotificationsProvider({ children }) {
|
||||
updateId,
|
||||
removeId,
|
||||
hasNotification,
|
||||
hasAppNotification,
|
||||
addNotificationAlert,
|
||||
addOrUpdateNotification,
|
||||
icons,
|
||||
count: notifications.length,
|
||||
}}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
export const setClipboard = (value: string) => {
|
||||
// 420 Blaze it
|
||||
// YOLO
|
||||
// Only live once for tonight
|
||||
const clipElem = document.createElement('input');
|
||||
clipElem.value = value;
|
||||
document.body.appendChild(clipElem);
|
||||
|
||||
@@ -38,7 +38,7 @@ export const usePhoneVisibility = () => {
|
||||
|
||||
const bottom = useMemo(() => {
|
||||
if (!visibility) {
|
||||
return `calc(-728px * ${zoom})`;
|
||||
return `${-728 * zoom.value}px`;
|
||||
}
|
||||
return 0;
|
||||
}, [visibility, zoom]);
|
||||
|
||||
Reference in new issue
Block a user