Skip to content

Commit

Permalink
新しい実績を追加 (#11817)
Browse files Browse the repository at this point in the history
* (add) new achievement

* (update) changelog

* Update test-notification.ts

* tweak

---------

Co-authored-by: syuilo <[email protected]>
  • Loading branch information
kakkokari-gtyih and syuilo authored Sep 12, 2023
1 parent 42c7aad commit 3456680
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 39 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- センシティブチャンネルのノートはユーザープロフィールに表示されません
- 二要素認証のバックアップコードが生成されるようになりました ref. https://github.com/MisskeyIO/misskey/pull/121
- 二要素認証でパスキーをサポートするようになりました
- 通知をテストできるようになりました

### Client
- プロフィールにその人が作ったPlayの一覧出せるように
Expand All @@ -33,7 +34,6 @@
- 投稿フォームのプレビューの表示状態を記憶するように
- AiScriptからMisskeyサーバーAPIを呼び出す際の制限を撤廃
- Playで直接投稿フォームを埋め込めるように(`Ui:C:postForm`)
- 通知をテストできるように
- Enhance: ユーザーメニューでスイッチでユーザーリストに追加・削除できるように
- Enhance: 自分が押したリアクションのデザインを改善
- Enhance: ノート検索にローカルのみ検索可能なオプションの追加
Expand All @@ -46,6 +46,7 @@
- リアクションの表示サイズをより大きくできるように
- ノート詳細ページ読み込み時のパフォーマンスを改善
- タイムラインでリスト/アンテナ選択時のパフォーマンスを改善
- 新しい実績を追加
- Fix: サーバー情報画面(`/instance-info/{domain}`)でブロックができないのを修正
- Fix: 未読のお知らせの「わかった」をクリック・タップしてもその場で「わかった」が消えない問題を修正
- Fix: iOSで画面を回転させるとテキストサイズが変わる問題を修正
Expand Down
4 changes: 4 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,10 @@ export interface Locale {
"description": string;
"flavor": string;
};
"_smashTestNotificationButton": {
"title": string;
"description": string;
};
};
};
"_role": {
Expand Down
3 changes: 3 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,9 @@ _achievements:
title: "Brain Diver"
description: "Brain Diverへのリンクを投稿した"
flavor: "Misskey-Misskey La-Tu-Ma"
_smashTestNotificationButton:
title: "テスト過剰"
description: "通知のテストをごく短時間のうちに連続して行った"

_role:
new: "ロールの作成"
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/core/AchievementService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const ACHIEVEMENT_TYPES = [
'setNameToSyuilo',
'cookieClicked',
'brainDiver',
'smashTestNotificationButton',
] as const;

@Injectable()
Expand Down
32 changes: 30 additions & 2 deletions packages/frontend/src/pages/settings/general.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<option value="horizontal"><i class="ti ti-carousel-horizontal"></i> {{ i18n.ts.horizontal }}</option>
</MkRadios>

<MkButton @click="testNotification('client')">{{ i18n.ts._notification.checkNotificationBehavior }}</MkButton>
<MkButton @click="testNotification">{{ i18n.ts._notification.checkNotificationBehavior }}</MkButton>
</div>
</FormSection>

Expand Down Expand Up @@ -176,6 +176,7 @@ SPDX-License-Identifier: AGPL-3.0-only

<script lang="ts" setup>
import { computed, ref, watch } from 'vue';
import * as Misskey from 'misskey-js';
import MkSwitch from '@/components/MkSwitch.vue';
import MkSelect from '@/components/MkSelect.vue';
import MkRadios from '@/components/MkRadios.vue';
Expand All @@ -192,7 +193,8 @@ import { unisonReload } from '@/scripts/unison-reload';
import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';
import { miLocalStorage } from '@/local-storage';
import { testNotification } from '@/scripts/test-notification';
import { globalEvents } from '@/events';
import { claimAchievement } from '@/scripts/achievements';

const lang = ref(miLocalStorage.getItem('lang'));
const fontSize = ref(miLocalStorage.getItem('fontSize'));
Expand Down Expand Up @@ -305,6 +307,32 @@ function removeEmojiIndex(lang: string) {
os.promiseDialog(main());
}

let smashCount = 0;
let smashTimer: number | null = null;
function testNotification(): void {
const notification: Misskey.entities.Notification = {
id: Math.random().toString(),
createdAt: new Date().toUTCString(),
isRead: false,
type: 'test',
};

globalEvents.emit('clientNotification', notification);

// セルフ通知破壊 実績関連
smashCount++;
if (smashCount >= 10) {
claimAchievement('smashTestNotificationButton');
smashCount = 0;
}
if (smashTimer) {
clearTimeout(smashTimer);
}
smashTimer = window.setTimeout(() => {
smashCount = 0;
}, 300);
}

const headerActions = $computed(() => []);

const headerTabs = $computed(() => []);
Expand Down
7 changes: 5 additions & 2 deletions packages/frontend/src/pages/settings/notifications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</FormSection>
<FormSection>
<div class="_gaps_m">
<FormLink @click="testNotification('server')">{{ i18n.ts._notification.sendTestNotification }}</FormLink>
<FormLink @click="testNotification">{{ i18n.ts._notification.sendTestNotification }}</FormLink>
</div>
</FormSection>
<FormSection>
Expand Down Expand Up @@ -46,7 +46,6 @@ import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';
import MkPushNotificationAllowButton from '@/components/MkPushNotificationAllowButton.vue';
import { notificationTypes } from '@/const';
import { testNotification } from '@/scripts/test-notification';

let allowButton = $shallowRef<InstanceType<typeof MkPushNotificationAllowButton>>();
let pushRegistrationInServer = $computed(() => allowButton?.pushRegistrationInServer);
Expand Down Expand Up @@ -89,6 +88,10 @@ function onChangeSendReadMessage(v: boolean) {
});
}

function testNotification(): void {
os.api('notifications/test-notification');
}

const headerActions = $computed(() => []);

const headerTabs = $computed(() => []);
Expand Down
6 changes: 6 additions & 0 deletions packages/frontend/src/scripts/achievements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const ACHIEVEMENT_TYPES = [
'setNameToSyuilo',
'cookieClicked',
'brainDiver',
'smashTestNotificationButton',
] as const;

export const ACHIEVEMENT_BADGES = {
Expand Down Expand Up @@ -454,6 +455,11 @@ export const ACHIEVEMENT_BADGES = {
bg: 'linear-gradient(0deg, rgb(144, 224, 255), rgb(255, 168, 252))',
frame: 'bronze',
},
'smashTestNotificationButton': {
img: '/fluent-emoji/1f514.png',
bg: 'linear-gradient(0deg, rgb(187 183 59), rgb(255 143 77))',
frame: 'bronze',
},
/* @see <https://github.com/misskey-dev/misskey/pull/10365#discussion_r1155511107>
} as const satisfies Record<typeof ACHIEVEMENT_TYPES[number], {
img: string;
Expand Down
34 changes: 0 additions & 34 deletions packages/frontend/src/scripts/test-notification.ts

This file was deleted.

0 comments on commit 3456680

Please sign in to comment.