fix: fix rn plugin error and plain message

pull/90/head
moonrailgun 2 years ago
parent 0e5692dc86
commit fcf837394a

@ -6,6 +6,6 @@
"version": "0.0.0", "version": "0.0.0",
"author": "moonrailgun", "author": "moonrailgun",
"description": "Add support for ReactNative environment in Tailchat", "description": "Add support for ReactNative environment in Tailchat",
"description.zh-CN": "在Tailchat添加对ReactNative环境的支持", "description.zh-CN": "在 Tailchat 添加对 ReactNative 环境的支持",
"requireRestart": true "requireRestart": true
} }

@ -2,7 +2,7 @@
"name": "@plugins/com.msgbyte.env.rn", "name": "@plugins/com.msgbyte.env.rn",
"main": "src/index.tsx", "main": "src/index.tsx",
"version": "0.0.0", "version": "0.0.0",
"description": "在Tailchat添加对ReactNative环境的支持", "description": "Add support for ReactNative environment in Tailchat",
"private": true, "private": true,
"scripts": { "scripts": {
"sync:declaration": "tailchat declaration github" "sync:declaration": "tailchat declaration github"

@ -3,10 +3,11 @@ import {
sharedEvent, sharedEvent,
getCachedUserInfo, getCachedUserInfo,
getCachedBaseGroupInfo, getCachedBaseGroupInfo,
getMessageTextDecorators,
} from '@capital/common'; } from '@capital/common';
import { Translate } from './translate'; import { Translate } from './translate';
const PLUGIN_NAME = 'ReactNative支持'; const PLUGIN_NAME = 'ReactNative Support';
console.log(`Plugin ${PLUGIN_NAME} is loaded`); console.log(`Plugin ${PLUGIN_NAME} is loaded`);
@ -25,6 +26,11 @@ function forwardSharedEvent(
let type = eventName; let type = eventName;
if (processPayload) { if (processPayload) {
const res = await processPayload(payload); const res = await processPayload(payload);
if (!res) {
// Skip if res is undefined
return;
}
payload = res.payload; payload = res.payload;
type = res.type; type = res.type;
} }
@ -60,7 +66,7 @@ forwardSharedEvent('receiveUnmutedMessage', async (payload) => {
const content = message.content; const content = message.content;
const title = `${Translate.from} [${scopeName}] ${nickname}`; const title = `${Translate.from} [${scopeName}] ${nickname}`;
const body = content; const body = getMessageTextDecorators().serialize(content);
return { return {
type: 'showNotification', type: 'showNotification',

Loading…
Cancel
Save