From 1561391293a0573c64b024efd6edc3e1380cb0a8 Mon Sep 17 00:00:00 2001
From: syuilo <Syuilotan@yahoo.co.jp>
Date: Fri, 13 Aug 2021 17:59:54 +0900
Subject: [PATCH] =?UTF-8?q?feat(client):=20Misskey=E6=9B=B4=E6=96=B0?=
 =?UTF-8?q?=E6=99=82=E3=81=AB=E3=83=80=E3=82=A4=E3=82=A2=E3=83=AD=E3=82=B0?=
 =?UTF-8?q?=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?=
 =?UTF-8?q?=E3=81=AB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 CHANGELOG.md                      |  7 ++++
 locales/ja-JP.yml                 |  2 ++
 package.json                      |  7 ++--
 src/client/components/updated.vue | 58 +++++++++++++++++++++++++++++++
 src/client/init.ts                |  6 ++--
 yarn.lock                         |  5 +++
 6 files changed, 80 insertions(+), 5 deletions(-)
 create mode 100644 src/client/components/updated.vue

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4fc982beb..da90a5c07 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,13 @@
 
 -->
 
+## 12.x.x (unreleased)
+
+### Improvements
+- Misskey更新時にダイアログを表示するように
+
+### Bugfixes
+
 ## 12.87.0 (2021/08/12)
 
 ### Improvements
diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml
index be4792401..2d18d4325 100644
--- a/locales/ja-JP.yml
+++ b/locales/ja-JP.yml
@@ -773,6 +773,8 @@ hashtags: "ハッシュタグ"
 troubleshooting: "トラブルシューティング"
 useBlurEffect: "UIにぼかし効果を使用"
 learnMore: "詳しく"
+misskeyUpdated: "Misskeyが更新されました!"
+whatIsNew: "更新情報を見る"
 
 _docs: 
   continueReading: "続きを読む"
diff --git a/package.json b/package.json
index 79a312725..5dce4baac 100644
--- a/package.json
+++ b/package.json
@@ -61,9 +61,6 @@
 		"@types/jsonld": "1.5.6",
 		"@types/katex": "0.11.1",
 		"@types/koa": "2.13.4",
-		"@types/koa__cors": "3.0.3",
-		"@types/koa__multer": "2.0.3",
-		"@types/koa__router": "8.0.7",
 		"@types/koa-bodyparser": "4.3.3",
 		"@types/koa-cors": "0.0.2",
 		"@types/koa-favicon": "2.0.21",
@@ -71,6 +68,9 @@
 		"@types/koa-mount": "4.0.0",
 		"@types/koa-send": "4.1.3",
 		"@types/koa-views": "7.0.0",
+		"@types/koa__cors": "3.0.3",
+		"@types/koa__multer": "2.0.3",
+		"@types/koa__router": "8.0.7",
 		"@types/markdown-it": "12.0.3",
 		"@types/matter-js": "0.17.5",
 		"@types/mocha": "8.2.3",
@@ -122,6 +122,7 @@
 		"chart.js": "2.9.4",
 		"cli-highlight": "2.1.11",
 		"commander": "7.2.0",
+		"compare-versions": "3.6.0",
 		"concurrently": "6.2.0",
 		"content-disposition": "0.5.3",
 		"core-js": "3.16.1",
diff --git a/src/client/components/updated.vue b/src/client/components/updated.vue
new file mode 100644
index 000000000..5033d866f
--- /dev/null
+++ b/src/client/components/updated.vue
@@ -0,0 +1,58 @@
+<template>
+<MkModal ref="modal" @click="$refs.modal.close()" @closed="$emit('closed')">
+	<div class="ewlycnyt">
+		<div class="title">{{ $ts.misskeyUpdated }}</div>
+		<div class="version">✨{{ version }}🚀</div>
+		<MkButton full @click="whatIsNew">{{ $ts.whatIsNew }}</MkButton>
+		<MkButton primary full @click="$refs.modal.close()">{{ $ts.gotIt }}</MkButton>
+	</div>
+</MkModal>
+</template>
+
+<script lang="ts">
+import { defineComponent } from 'vue';
+import MkModal from '@client/components/ui/modal.vue';
+import MkButton from '@client/components/ui/button.vue';
+import { version } from '@client/config';
+
+export default defineComponent({
+	components: {
+		MkModal,
+		MkButton,
+	},
+
+	data() {
+		return {
+			version: version,
+		};
+	},
+
+	methods: {
+		whatIsNew() {
+			this.$refs.modal.close();
+			this.$router.push('/docs/general/changelog');
+		}
+	}
+});
+</script>
+
+<style lang="scss" scoped>
+.ewlycnyt {
+	position: relative;
+	padding: 32px;
+	min-width: 320px;
+	max-width: 480px;
+	box-sizing: border-box;
+	text-align: center;
+	background: var(--panel);
+	border-radius: var(--radius);
+
+	> .title {
+		font-weight: bold;
+	}
+
+	> .version {
+		margin: 1em 0;
+	}
+}
+</style>
diff --git a/src/client/init.ts b/src/client/init.ts
index 95aa18862..2feeaf0ce 100644
--- a/src/client/init.ts
+++ b/src/client/init.ts
@@ -7,6 +7,7 @@ import '@client/style.scss';
 import * as Sentry from '@sentry/browser';
 import { Integrations } from '@sentry/tracing';
 import { computed, createApp, watch, markRaw } from 'vue';
+import compareVersions from 'compare-versions';
 
 import widgets from '@client/widgets';
 import directives from '@client/directives';
@@ -206,8 +207,9 @@ if (lastVersion !== version) {
 	// テーマリビルドするため
 	localStorage.removeItem('theme');
 
-	// TODO: バージョンが新しくなった時だけダイアログ出す
-	//popup();
+	if (lastVersion != null && compareVersions(version, lastVersion) === 1) {
+		popup(import('@client/components/updated.vue'), {}, {}, 'closed');
+	}
 }
 
 // NOTE: この処理は必ず↑のクライアント更新時処理より後に来ること(テーマ再構築のため)
diff --git a/yarn.lock b/yarn.lock
index a51decac7..d074b77d8 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3364,6 +3364,11 @@ commondir@^1.0.1:
   resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
   integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=
 
+compare-versions@3.6.0:
+  version "3.6.0"
+  resolved "https://registry.yarnpkg.com/compare-versions/-/compare-versions-3.6.0.tgz#1a5689913685e5a87637b8d3ffca75514ec41d62"
+  integrity sha512-W6Af2Iw1z4CB7q4uU4hv646dW9GQuBM+YpC0UvUCWSD8w90SJjp+ujJuXaEMtAXBtSqGfMPuFOVn4/+FlaqfBA==
+
 component-emitter@^1.2.1:
   version "1.3.0"
   resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0"