Skip to content

Commit

Permalink
Merge pull request #388 from lobehub/fix/weather-plugin
Browse files Browse the repository at this point in the history
🐛 fix: fix a bug that weather plugin is not work correctly
  • Loading branch information
arvinxx authored Oct 31, 2023
2 parents 5078aae + 0673b0a commit ddb662a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/issue-auto-comments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN}}
issuesOpened: |
👀 @{{ author }}
Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible.
Please make sure you have given us as much context as possible.\
非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。
Expand All @@ -35,7 +36,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN}}
issuesClosed: |
✅ @{{ author }}
<br/>
This issue is closed, If you have any questions, you can comment and reply.\
此问题已经关闭。如果您有任何问题,可以留言并回复。
- name: Auto Comment on Pull Request Opened
Expand All @@ -44,7 +45,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN}}
pullRequestOpened: |
👍 @{{ author }}
<br>
Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.\
Expand All @@ -57,7 +58,7 @@ jobs:
token: ${{ secrets.GH_TOKEN }}
comment: |
❤️ Great PR @${{ github.event.pull_request.user.login }} ❤️
<br>
The growth of project is inseparable from user feedback and contribution, thanks for your contribution!\
项目的成长离不开用户反馈和贡献,感谢您的贡献!
emoji: 'hooray'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { Skeleton } from 'antd';
import { memo, useRef, useState } from 'react';

import { useOnPluginReadyForInteraction } from '../../utils/iframeOnReady';
import { sendMessageToPlugin } from '../../utils/postMessage';
import { useOnPluginFetchMessage } from '../../utils/listenToPlugin';
import { sendMessageContentToPlugin } from '../../utils/postMessage';

interface IFrameRenderProps extends PluginRenderProps {
height?: number;
Expand All @@ -20,7 +21,15 @@ const IFrameRender = memo<IFrameRenderProps>(({ url, width = 800, height = 300,
const iframeWin = iframeRef.current?.contentWindow;

if (iframeWin) {
sendMessageToPlugin(iframeWin, props);
sendMessageContentToPlugin(iframeWin, props);
}
}, [props]);

// when get iframe fetch message ,send message content
useOnPluginFetchMessage(() => {
const iframeWin = iframeRef.current?.contentWindow;
if (iframeWin) {
sendMessageContentToPlugin(iframeWin, props);
}
}, [props]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
useOnPluginFillContent,
} from '../utils/listenToPlugin';
import {
sendMessageToPlugin,
sendMessageContentToPlugin,
sendPayloadToPlugin,
sendPluginSettingsToPlugin,
sendPluginStateToPlugin,
Expand Down Expand Up @@ -58,7 +58,7 @@ const IFrameRender = memo<IFrameRenderProps>(({ url, id, payload, width = 600, h
props.content = message.content || '';
}

sendMessageToPlugin(iframeWin, props);
sendMessageContentToPlugin(iframeWin, props);
}
}, []);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PluginChannel } from '@lobehub/chat-plugin-sdk/client';

export const sendMessageToPlugin = (window: Window, props: any) => {
export const sendMessageContentToPlugin = (window: Window, props: any) => {
window.postMessage({ props, type: PluginChannel.renderPlugin }, '*');
};

Expand Down

0 comments on commit ddb662a

Please sign in to comment.