Skip to content

Commit

Permalink
c2c msg sync
Browse files Browse the repository at this point in the history
  • Loading branch information
takayama-lily committed Sep 18, 2021
1 parent f8651c1 commit f4b7b91
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions assets/default-theme/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ function genUserMessage(data) {
return "";
}
let title = "";
data.user_id = data.sender.user_id;

if (data.anonymous) {
data.sender.card = data.anonymous.name;
Expand Down
2 changes: 1 addition & 1 deletion assets/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
function onHostMessage(data) {
if (!data.echo) {
if (data.post_type === "message") {
if (data.post_type === "message" || (data.post_type === "sync" && data.sync_type === "message")) {
vsc.dispatchEvent(new window.CustomEvent("message", { detail: data }));
} else if (data.post_type === "notice") {
vsc.dispatchEvent(new window.CustomEvent("notice", { detail: data }));
Expand Down
3 changes: 2 additions & 1 deletion src/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function openChatView(id: string) {
});
}

function postC2CEvent(data: oicq.FriendNoticeEventData | oicq.PrivateMessageEventData) {
function postC2CEvent(data: oicq.FriendNoticeEventData | oicq.PrivateMessageEventData | oicq.SyncMessageEventData) {
const id = genContactId("u", data.user_id);
webviewMap.get(id)?.webview.postMessage(data);
}
Expand Down Expand Up @@ -166,4 +166,5 @@ export function bind() {
client.on("notice.group", postGroupEvent);
client.on("notice.friend.recall", postC2CEvent);
client.on("notice.friend.poke", postC2CEvent);
client.on("sync.message", postC2CEvent);
}

0 comments on commit f4b7b91

Please sign in to comment.