From d99be6697e06ee87b4e00ab6421a2bdb1a9e1609 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 7 Jan 2023 11:49:00 +0900 Subject: [PATCH] enhance(client): donation dialog --- locales/ja-JP.yml | 4 + .../frontend/src/components/MkDonation.vue | 109 ++++++++++++++++++ packages/frontend/src/init.ts | 8 ++ packages/frontend/src/local-storage.ts | 2 + packages/frontend/src/store.ts | 8 -- 5 files changed, 123 insertions(+), 8 deletions(-) create mode 100644 packages/frontend/src/components/MkDonation.vue diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 32bafcd66..b49d872a0 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -920,6 +920,10 @@ like: "いいね!" unlike: "いいねを解除" numberOfLikes: "いいね数" show: "表示" +neverShow: "今後表示しない" +remindMeLater: "また後で" +didYouLikeMisskey: "Misskeyを気に入っていただけましたか?" +pleaseDonate: "Misskeyは{host}が使用している無料のソフトウェアです。これからも開発を続けられるように、ぜひ寄付をお願いします!" _sensitiveMediaDetection: description: "機械学習を使って自動でセンシティブなメディアを検出し、モデレーションに役立てることができます。サーバーの負荷が少し増えます。" diff --git a/packages/frontend/src/components/MkDonation.vue b/packages/frontend/src/components/MkDonation.vue new file mode 100644 index 000000000..707444abc --- /dev/null +++ b/packages/frontend/src/components/MkDonation.vue @@ -0,0 +1,109 @@ + + + + + diff --git a/packages/frontend/src/init.ts b/packages/frontend/src/init.ts index bd515f47e..e10315e1a 100644 --- a/packages/frontend/src/init.ts +++ b/packages/frontend/src/init.ts @@ -357,6 +357,14 @@ import { miLocalStorage } from './local-storage'; } miLocalStorage.setItem('lastUsed', Date.now().toString()); + const latestDonationInfoShownAt = miLocalStorage.getItem('latestDonationInfoShownAt'); + const neverShowDonationInfo = miLocalStorage.getItem('neverShowDonationInfo'); + if (neverShowDonationInfo !== 'true' && (new Date($i.createdAt).getTime() < (Date.now() - (1000 * 60 * 60 * 24 * 3)))) { + if (latestDonationInfoShownAt == null || (new Date(latestDonationInfoShownAt).getTime() < (Date.now() - (1000 * 60 * 60 * 24 * 30)))) { + popup(defineAsyncComponent(() => import('@/components/MkDonation.vue')), {}, {}, 'closed'); + } + } + if ('Notification' in window) { // 許可を得ていなかったらリクエスト if (Notification.permission === 'default') { diff --git a/packages/frontend/src/local-storage.ts b/packages/frontend/src/local-storage.ts index 5286a6f3a..50e28d621 100644 --- a/packages/frontend/src/local-storage.ts +++ b/packages/frontend/src/local-storage.ts @@ -4,6 +4,8 @@ type Keys = 'instance' | 'account' | 'accounts' | + 'latestDonationInfoShownAt' | + 'neverShowDonationInfo' | 'lastUsed' | 'lang' | 'drafts' | diff --git a/packages/frontend/src/store.ts b/packages/frontend/src/store.ts index 97b6ebc18..b2bf8db64 100644 --- a/packages/frontend/src/store.ts +++ b/packages/frontend/src/store.ts @@ -86,14 +86,6 @@ export const defaultStore = markRaw(new Storage('base', { where: 'account', default: [] as string[], }, - latestDonateDialogShowAt: { - where: 'account', - default: null, - }, - neverShowDonateDialog: { - where: 'account', - default: false, - }, menu: { where: 'deviceAccount',