From 37cff405ed620a9a885475f63067446c56c58415 Mon Sep 17 00:00:00 2001 From: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Thu, 30 Nov 2023 01:08:29 +0900 Subject: enhance(frontend): Shareページでの投稿完了時にpostMessageを発火するように (#12505) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * enhance(frontend): Shareページでの投稿完了時にpostMessageを発火 * Update Changelog * fix * 名前の混同をさける * 名前をわかりやすくする * watchを使わずパフォーマンス改善 --- packages/frontend/src/scripts/post-message.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 packages/frontend/src/scripts/post-message.ts (limited to 'packages/frontend/src/scripts') diff --git a/packages/frontend/src/scripts/post-message.ts b/packages/frontend/src/scripts/post-message.ts new file mode 100644 index 0000000000..80441caf15 --- /dev/null +++ b/packages/frontend/src/scripts/post-message.ts @@ -0,0 +1,25 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export const postMessageEventTypes = [ + 'misskey:shareForm:shareCompleted', +] as const; + +export type PostMessageEventType = typeof postMessageEventTypes[number]; + +export type MiPostMessageEvent = { + type: PostMessageEventType; + payload?: any; +}; + +/** + * 親フレームにイベントを送信 + */ +export function postMessageToParentWindow(type: PostMessageEventType, payload?: any): void { + window.postMessage({ + type, + payload, + }, '*'); +} -- cgit v1.2.3-freya