Add support for mentioning users; change loading screen loading animation to falling; restore chat close functionality on mobile; make message input resize on message send.
This commit is contained in:
parent
82c99e128e
commit
f0066d6015
8 changed files with 264 additions and 49 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { loadChat, loadChatsSorted, loadLatestMessages, loadMedia, loadOlderMessages, upsertChats, upsertMedia, upsertMessages } from "./db";
|
||||
import { waha } from "./waha";
|
||||
import type { Chat, Message, AppUser, ContactInfo, UserAboutResponse, ChatPictureResponse, StatusResponse, DownloadedMedia } from "./types";
|
||||
import type { Chat, Message, AppUser, ContactInfo, UserAboutResponse, ChatPictureResponse, StatusResponse, DownloadedMedia, GroupUser, Contact } from "./types";
|
||||
|
||||
let online = false;
|
||||
let chats: Chat[] = [];
|
||||
|
|
@ -60,6 +60,14 @@ export async function getUserAbout(userId: string): Promise<UserAboutResponse |
|
|||
}
|
||||
}
|
||||
|
||||
export async function getContact(id: string): Promise<Contact | undefined> {
|
||||
if (online) {
|
||||
return await waha.getContact(id);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
export function getChats(): Chat[] {
|
||||
return chats;
|
||||
}
|
||||
|
|
@ -164,4 +172,28 @@ export async function markRead(chatId: string): Promise<Chat | undefined> {
|
|||
await upsertChats([chat]);
|
||||
}
|
||||
return chat;
|
||||
}
|
||||
|
||||
export async function getGroupUsers(groupId: string): Promise<GroupUser[] | undefined> {
|
||||
if (online) {
|
||||
return await waha.getGroupUsers(groupId);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export async function getUsersFromGroup(users: (GroupUser | undefined)[]): Promise<(Contact | undefined)[]> {
|
||||
if (!online) {
|
||||
return users.map(() => undefined);
|
||||
}
|
||||
|
||||
return Promise.all(
|
||||
users.map(async u => {
|
||||
if (u?.id._serialized) {
|
||||
return await getContact(u.id._serialized);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
})
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue