Skip to content

Commit

Permalink
fix(frontend): PlayのAiScriptランタイムが停止したときに画面が初期化されていない問題を修正 (misskey-d…
Browse files Browse the repository at this point in the history
…ev#13747)

* fix(frontend): PlayのAiScriptランタイムが停止したときに画面が初期化されていない問題を修正

* fix

* Update Changelog

* typo
  • Loading branch information
kakkokari-gtyih authored Apr 27, 2024
1 parent f53e22d commit 0a31e13
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 18 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- Enhance: リプライにて引用がある場合テキストが空でもノートできるように
- 引用したいノートのURLをコピーしリプライ投稿画面にペーストして添付することで達成できます
- Enhance: フォローするかどうかの確認ダイアログを出せるように
- Enhance: Playを手動でリロードできるように
- Chore: AiScriptを0.18.0にバージョンアップ
- Fix: 一部のページ内リンクが正しく動作しない問題を修正
- Fix: 周年の実績が閏年を考慮しない問題を修正
Expand All @@ -50,6 +51,7 @@
- Fix: ノート詳細ページにおいてCW付き引用リノートのCWボタンのラベルに「引用」が含まれていない問題を修正
- Fix: ダイアログの入力で字数制限に違反していてもEnterキーが押せてしまう問題を修正
- Fix: ダイレクト投稿の宛先が保存されない問題を修正
- Fix: Playのページを離れたときに、Playが正常に初期化されない問題を修正

### Server
- Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに
Expand Down
82 changes: 64 additions & 18 deletions packages/frontend/src/pages/flash/flash.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkAsUi v-if="root" :component="root" :components="components"/>
</div>
<div class="actions _panel">
<MkButton v-if="flash.isLiked" v-tooltip="i18n.ts.unlike" asLike class="button" rounded primary @click="unlike()"><i class="ti ti-heart"></i><span v-if="flash.likedCount > 0" style="margin-left: 6px;">{{ flash.likedCount }}</span></MkButton>
<MkButton v-else v-tooltip="i18n.ts.like" asLike class="button" rounded @click="like()"><i class="ti ti-heart"></i><span v-if="flash.likedCount > 0" style="margin-left: 6px;">{{ flash.likedCount }}</span></MkButton>
<MkButton v-tooltip="i18n.ts.shareWithNote" class="button" rounded @click="shareWithNote"><i class="ti ti-repeat ti-fw"></i></MkButton>
<MkButton v-tooltip="i18n.ts.copyLink" class="button" rounded @click="copyLink"><i class="ti ti-link ti-fw"></i></MkButton>
<MkButton v-if="isSupportShare()" v-tooltip="i18n.ts.share" class="button" rounded @click="share"><i class="ti ti-share ti-fw"></i></MkButton>
<div class="items">
<MkButton v-tooltip="i18n.ts.reload" class="button" rounded @click="reset"><i class="ti ti-reload"></i></MkButton>
</div>
<div class="items">
<MkButton v-if="flash.isLiked" v-tooltip="i18n.ts.unlike" asLike class="button" rounded primary @click="unlike()"><i class="ti ti-heart"></i><span v-if="flash?.likedCount && flash.likedCount > 0" style="margin-left: 6px;">{{ flash.likedCount }}</span></MkButton>
<MkButton v-else v-tooltip="i18n.ts.like" asLike class="button" rounded @click="like()"><i class="ti ti-heart"></i><span v-if="flash?.likedCount && flash.likedCount > 0" style="margin-left: 6px;">{{ flash.likedCount }}</span></MkButton>
<MkButton v-tooltip="i18n.ts.copyLink" class="button" rounded @click="copyLink"><i class="ti ti-link ti-fw"></i></MkButton>
<MkButton v-tooltip="i18n.ts.share" class="button" rounded @click="share"><i class="ti ti-share ti-fw"></i></MkButton>
</div>
</div>
</div>
<div v-else :class="$style.ready">
Expand Down Expand Up @@ -49,7 +53,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkA v-if="$i && $i.id === flash.userId" :to="`/play/${flash.id}/edit`" style="color: var(--accent);">{{ i18n.ts._play.editThisPage }}</MkA>
<MkAd :prefer="['horizontal', 'horizontal-big']"/>
</div>
<MkError v-else-if="error" @retry="fetchPage()"/>
<MkError v-else-if="error" @retry="fetchFlash()"/>
<MkLoading v-else/>
</Transition>
</MkSpacer>
Expand Down Expand Up @@ -94,12 +98,33 @@ function fetchFlash() {
});
}
function share(ev: MouseEvent) {
if (!flash.value) return;
os.popupMenu([
{
text: i18n.ts.shareWithNote,
icon: 'ti ti-pencil',
action: shareWithNote,
},
...(isSupportShare() ? [{
text: i18n.ts.share,
icon: 'ti ti-share',
action: shareWithNavigator,
}] : []),
], ev.currentTarget ?? ev.target);
}
function copyLink() {
if (!flash.value) return;
copyToClipboard(`${url}/play/${flash.value.id}`);
os.success();
}
function share() {
function shareWithNavigator() {
if (!flash.value) return;
navigator.share({
title: flash.value.title,
text: flash.value.summary,
Expand All @@ -108,21 +133,28 @@ function share() {
}
function shareWithNote() {
if (!flash.value) return;
os.post({
initialText: `${flash.value.title} ${url}/play/${flash.value.id}`,
initialText: `${flash.value.title}\n${url}/play/${flash.value.id}`,
instant: true,
});
}
function like() {
if (!flash.value) return;
os.apiWithDialog('flash/like', {
flashId: flash.value.id,
}).then(() => {
flash.value.isLiked = true;
flash.value.likedCount++;
flash.value!.isLiked = true;
flash.value!.likedCount++;
});
}
async function unlike() {
if (!flash.value) return;
const confirm = await os.confirm({
type: 'warning',
text: i18n.ts.unlikeConfirm,
Expand All @@ -131,8 +163,8 @@ async function unlike() {
os.apiWithDialog('flash/unlike', {
flashId: flash.value.id,
}).then(() => {
flash.value.isLiked = false;
flash.value.likedCount--;
flash.value!.isLiked = false;
flash.value!.likedCount--;
});
}
Expand All @@ -152,6 +184,7 @@ function start() {
async function run() {
if (aiscript.value) aiscript.value.abort();
if (!flash.value) return;
aiscript.value = new Interpreter({
...createAiScriptEnv({
Expand Down Expand Up @@ -193,12 +226,17 @@ async function run() {
}
}
onDeactivated(() => {
function reset() {
if (aiscript.value) aiscript.value.abort();
started.value = false;
}
onDeactivated(() => {
reset();
});
onUnmounted(() => {
if (aiscript.value) aiscript.value.abort();
reset();
});
const headerActions = computed(() => []);
Expand Down Expand Up @@ -265,11 +303,19 @@ definePageMetadata(() => ({
}
> .actions {
display: flex;
justify-content: center;
gap: 12px;
margin-top: 16px;
padding: 16px;
> .items {
display: flex;
justify-content: center;
gap: 12px;
padding: 16px;
border-bottom: 1px solid var(--divider);
&:last-child {
border-bottom: none;
}
}
}
}
}
Expand Down

0 comments on commit 0a31e13

Please sign in to comment.