From d01c465a8d855846dbda35995d013445adfa46ca Mon Sep 17 00:00:00 2001
From: syuilo <syuilotan@yahoo.co.jp>
Date: Sun, 8 Nov 2020 12:40:56 +0900
Subject: ユーザーピッカーに最近使用したユーザーを表示するように
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/client/components/user-select-dialog.vue | 36 +++++++++++++++++++++++++---
 1 file changed, 33 insertions(+), 3 deletions(-)

(limited to 'src/client/components/user-select-dialog.vue')

diff --git a/src/client/components/user-select-dialog.vue b/src/client/components/user-select-dialog.vue
index e7bfcafbb3..cdb8990051 100644
--- a/src/client/components/user-select-dialog.vue
+++ b/src/client/components/user-select-dialog.vue
@@ -14,10 +14,10 @@
 			<MkInput v-model:value="host" class="input" @update:value="search"><span>{{ $t('host') }}</span><template #prefix>@</template></MkInput>
 		</div>
 	</div>
-	<div class="tbhwbxda _section" :style="users.length > 0 ? 'padding: 0;' : ''">
+	<div class="tbhwbxda _section result" v-if="username != '' || host != ''" :class="{ hit: users.length > 0 }">
 		<div class="users" v-if="users.length > 0">
 			<div class="user" v-for="user in users" :key="user.id" :class="{ selected: selected && selected.id === user.id }" @click="selected = user" @dblclick="ok()">
-				<MkAvatar :user="user" class="avatar" :disable-link="true"/>
+				<MkAvatar :user="user" class="avatar"/>
 				<div class="body">
 					<MkUserName :user="user" class="name"/>
 					<MkAcct :user="user" class="acct"/>
@@ -28,6 +28,17 @@
 			<span>{{ $t('noUsers') }}</span>
 		</div>
 	</div>
+	<div class="tbhwbxda _section recent" v-if="username == '' && host == ''">
+		<div class="users">
+			<div class="user" v-for="user in recentUsers" :key="user.id" :class="{ selected: selected && selected.id === user.id }" @click="selected = user" @dblclick="ok()">
+				<MkAvatar :user="user" class="avatar"/>
+				<div class="body">
+					<MkUserName :user="user" class="name"/>
+					<MkAcct :user="user" class="acct"/>
+				</div>
+			</div>
+		</div>
+	</div>
 </XModalWindow>
 </template>
 
@@ -53,18 +64,23 @@ export default defineComponent({
 		return {
 			username: '',
 			host: '',
+			recentUsers: [],
 			users: [],
 			selected: null,
 			faTimes, faCheck
 		};
 	},
 
-	mounted() {
+	async mounted() {
 		this.focus();
 
 		this.$nextTick(() => {
 			this.focus();
 		});
+
+		this.recentUsers = await os.api('users/show', {
+			userIds: this.$store.state.device.recentlyUsedUsers
+		});
 	},
 
 	methods: {
@@ -90,6 +106,12 @@ export default defineComponent({
 		ok() {
 			this.$emit('ok', this.selected);
 			this.$refs.dialog.close();
+
+			// 最近使ったユーザー更新
+			let recents = this.$store.state.device.recentlyUsedUsers;
+			recents = recents.filter(x => x !== this.selected.id);
+			recents.unshift(this.selected.id);
+			this.$store.commit('device/set', { key: 'recentlyUsedUsers', value: recents.splice(0, 16) });
 		},
 
 		cancel() {
@@ -107,6 +129,14 @@ export default defineComponent({
 	overflow: auto;
 	height: 100%;
 
+	&.result.hit {
+		padding: 0;
+	}
+
+	&.recent {
+		padding: 0;
+	}
+
 	> .inputs {
 		> .input {
 			display: inline-block;
-- 
cgit v1.2.3-freya

