feat: add preview message to chats
This commit is contained in:
Vendored
+3
-1
@@ -2,7 +2,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name WhatsApp Web Bridge
|
// @name WhatsApp Web Bridge
|
||||||
// @namespace https://rul.sh/
|
// @namespace https://rul.sh/
|
||||||
// @version 0.0.2
|
// @version 0.0.3
|
||||||
// @description WhatsApp Web WebSocket bridge
|
// @description WhatsApp Web WebSocket bridge
|
||||||
// @match https://web.whatsapp.com/*
|
// @match https://web.whatsapp.com/*
|
||||||
// @updateURL https://git.rul.sh/khairul169/whatsapp-bridge/raw/branch/main/dist/whatsapp-bridge.user.js
|
// @updateURL https://git.rul.sh/khairul169/whatsapp-bridge/raw/branch/main/dist/whatsapp-bridge.user.js
|
||||||
@@ -93,6 +93,7 @@
|
|||||||
return Object.keys(result).length ? result : String(id);
|
return Object.keys(result).length ? result : String(id);
|
||||||
}
|
}
|
||||||
function serializeChat(chat) {
|
function serializeChat(chat) {
|
||||||
|
const rawPreviewMessage = safeProperty(chat, "previewMessage");
|
||||||
return {
|
return {
|
||||||
id: serializeId(chat.id),
|
id: serializeId(chat.id),
|
||||||
accountLid: chat.accountLid,
|
accountLid: chat.accountLid,
|
||||||
@@ -103,6 +104,7 @@
|
|||||||
isReadOnly: chat.isReadOnly,
|
isReadOnly: chat.isReadOnly,
|
||||||
archived: chat.archived,
|
archived: chat.archived,
|
||||||
unreadCount: chat.unreadCount,
|
unreadCount: chat.unreadCount,
|
||||||
|
previewMessage: rawPreviewMessage ? serialize(rawPreviewMessage) : null,
|
||||||
timestamp: chat.t,
|
timestamp: chat.t,
|
||||||
lastMessage: chat.lastMessage ? serialize(chat.lastMessage) : null
|
lastMessage: chat.lastMessage ? serialize(chat.lastMessage) : null
|
||||||
};
|
};
|
||||||
|
|||||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
+1
-1
@@ -14,7 +14,7 @@ await esbuild.build({
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name WhatsApp Web Bridge
|
// @name WhatsApp Web Bridge
|
||||||
// @namespace https://rul.sh/
|
// @namespace https://rul.sh/
|
||||||
// @version 0.0.2
|
// @version 0.0.3
|
||||||
// @description WhatsApp Web WebSocket bridge
|
// @description WhatsApp Web WebSocket bridge
|
||||||
// @match https://web.whatsapp.com/*
|
// @match https://web.whatsapp.com/*
|
||||||
// @updateURL https://git.rul.sh/khairul169/whatsapp-bridge/raw/branch/main/dist/whatsapp-bridge.user.js
|
// @updateURL https://git.rul.sh/khairul169/whatsapp-bridge/raw/branch/main/dist/whatsapp-bridge.user.js
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ export interface ChatDTO {
|
|||||||
lastMessage?: MessageDTO | null;
|
lastMessage?: MessageDTO | null;
|
||||||
contact?: ContactDTO | null;
|
contact?: ContactDTO | null;
|
||||||
groupMetadata?: GroupMetadataDTO | null;
|
groupMetadata?: GroupMetadataDTO | null;
|
||||||
|
|
||||||
|
previewMessage?: MessageDTO | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GroupMetadataDTO {
|
export interface GroupMetadataDTO {
|
||||||
|
|||||||
@@ -137,6 +137,8 @@ export function serializeId(id: any): SerializedId | string | null {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function serializeChat(chat: any): ChatDTO {
|
export function serializeChat(chat: any): ChatDTO {
|
||||||
|
const rawPreviewMessage = safeProperty<any>(chat, "previewMessage");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: serializeId(chat.id),
|
id: serializeId(chat.id),
|
||||||
accountLid: chat.accountLid,
|
accountLid: chat.accountLid,
|
||||||
@@ -148,6 +150,7 @@ export function serializeChat(chat: any): ChatDTO {
|
|||||||
isReadOnly: chat.isReadOnly,
|
isReadOnly: chat.isReadOnly,
|
||||||
archived: chat.archived,
|
archived: chat.archived,
|
||||||
unreadCount: chat.unreadCount,
|
unreadCount: chat.unreadCount,
|
||||||
|
previewMessage: rawPreviewMessage ? serialize(rawPreviewMessage) : null,
|
||||||
|
|
||||||
timestamp: chat.t,
|
timestamp: chat.t,
|
||||||
lastMessage: chat.lastMessage ? serialize(chat.lastMessage) : null,
|
lastMessage: chat.lastMessage ? serialize(chat.lastMessage) : null,
|
||||||
|
|||||||
Reference in New Issue
Block a user