Compare commits
	
		
			36 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					195f676500 | ||
| 
						 | 
					a9a2f4820b | ||
| 
						 | 
					8414db57f0 | ||
| 
						 | 
					609d68933e | ||
| 
						 | 
					a23b8cebbc | ||
| 
						 | 
					89f6b03cd6 | ||
| 
						 | 
					7bc9de03a6 | ||
| 
						 | 
					3c865d6054 | ||
| 
						 | 
					fd770b008e | ||
| 
						 | 
					b0d60ef2c2 | ||
| 
						 | 
					7b9cea06ef | ||
| 
						 | 
					30608d3e22 | ||
| 
						 | 
					8bf4e55338 | ||
| 
						 | 
					6ead1de383 | ||
| 
						 | 
					3b628ec3c4 | ||
| 
						 | 
					0ed704d173 | ||
| 
						 | 
					87b6ef0ec5 | ||
| 
						 | 
					5184a07cf2 | ||
| 
						 | 
					dba04cc59c | ||
| 
						 | 
					f4045fb5b3 | ||
| 
						 | 
					16c36163b4 | ||
| 
						 | 
					1ac033ff18 | ||
| 
						 | 
					ccfd48232a | ||
| 
						 | 
					429bf179dc | ||
| 
						 | 
					8ba3fb13eb | ||
| 
						 | 
					11496d887e | ||
| 
						 | 
					bec48319ec | ||
| 
						 | 
					71a93b2b43 | ||
| 
						 | 
					6ed3f9e414 | ||
| 
						 | 
					dc8f592c1f | ||
| 
						 | 
					f66c31c771 | ||
| 
						 | 
					55e2ae1408 | ||
| 
						 | 
					19c72627fc | ||
| 
						 | 
					2a4c53c3a4 | ||
| 
						 | 
					1f2ebce8ed | ||
| 
						 | 
					fcea9dacb7 | 
@@ -1,8 +1,8 @@
 | 
			
		||||
{
 | 
			
		||||
	"name": "misskey",
 | 
			
		||||
	"author": "syuilo <i@syuilo.com>",
 | 
			
		||||
	"version": "8.47.0",
 | 
			
		||||
	"clientVersion": "1.0.9873",
 | 
			
		||||
	"version": "8.55.0",
 | 
			
		||||
	"clientVersion": "1.0.9909",
 | 
			
		||||
	"codename": "nighthike",
 | 
			
		||||
	"main": "./built/index.js",
 | 
			
		||||
	"private": true,
 | 
			
		||||
@@ -217,9 +217,9 @@
 | 
			
		||||
		"vuewordcloud": "18.7.11",
 | 
			
		||||
		"vuex": "3.0.1",
 | 
			
		||||
		"vuex-persistedstate": "2.5.4",
 | 
			
		||||
		"web-push": "3.3.2",
 | 
			
		||||
		"web-push": "3.3.3",
 | 
			
		||||
		"webfinger.js": "2.6.6",
 | 
			
		||||
		"webpack": "4.19.0",
 | 
			
		||||
		"webpack": "4.19.1",
 | 
			
		||||
		"webpack-cli": "3.1.0",
 | 
			
		||||
		"websocket": "1.0.26",
 | 
			
		||||
		"ws": "6.0.0",
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,24 @@
 | 
			
		||||
<template>
 | 
			
		||||
<router-view id="app"></router-view>
 | 
			
		||||
<router-view id="app" v-hotkey.global="keymap"></router-view>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script lang="ts">
 | 
			
		||||
import Vue from 'vue';
 | 
			
		||||
import { url, lang } from './config';
 | 
			
		||||
 | 
			
		||||
export default Vue.extend({
 | 
			
		||||
	computed: {
 | 
			
		||||
		keymap(): any {
 | 
			
		||||
			return {
 | 
			
		||||
				'h|slash': this.help
 | 
			
		||||
			};
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	methods: {
 | 
			
		||||
		help() {
 | 
			
		||||
			window.open(`${url}/docs/${lang}/keyboard-shortcut`, '_blank');
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
});
 | 
			
		||||
</script>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,28 +1,46 @@
 | 
			
		||||
import keyCode from './keycode';
 | 
			
		||||
import { concat } from '../../../prelude/array';
 | 
			
		||||
 | 
			
		||||
const getKeyMap = keymap => Object.keys(keymap).map(input => {
 | 
			
		||||
	const result = {} as any;
 | 
			
		||||
type pattern = {
 | 
			
		||||
	which: string[];
 | 
			
		||||
	ctrl?: boolean;
 | 
			
		||||
	shift?: boolean;
 | 
			
		||||
	alt?: boolean;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
	const { keyup, keydown } = keymap[input];
 | 
			
		||||
type action = {
 | 
			
		||||
	patterns: pattern[];
 | 
			
		||||
 | 
			
		||||
	input.split('+').forEach(keyName => {
 | 
			
		||||
		switch (keyName.toLowerCase()) {
 | 
			
		||||
			case 'ctrl':
 | 
			
		||||
			case 'alt':
 | 
			
		||||
			case 'shift':
 | 
			
		||||
			case 'meta':
 | 
			
		||||
				result[keyName] = true;
 | 
			
		||||
				break;
 | 
			
		||||
			default:
 | 
			
		||||
				result.keyCode = keyCode(keyName);
 | 
			
		||||
		}
 | 
			
		||||
	callback: Function;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const getKeyMap = keymap => Object.entries(keymap).map(([patterns, callback]): action => {
 | 
			
		||||
	const result = {
 | 
			
		||||
		patterns: [],
 | 
			
		||||
		callback: callback
 | 
			
		||||
	} as action;
 | 
			
		||||
 | 
			
		||||
	result.patterns = patterns.split('|').map(part => {
 | 
			
		||||
		const pattern = {
 | 
			
		||||
			which: [],
 | 
			
		||||
			ctrl: false,
 | 
			
		||||
			alt: false,
 | 
			
		||||
			shift: false
 | 
			
		||||
		} as pattern;
 | 
			
		||||
 | 
			
		||||
		part.trim().split('+').forEach(key => {
 | 
			
		||||
			key = key.trim().toLowerCase();
 | 
			
		||||
			switch (key) {
 | 
			
		||||
				case 'ctrl': pattern.ctrl = true; break;
 | 
			
		||||
				case 'alt': pattern.alt = true; break;
 | 
			
		||||
				case 'shift': pattern.shift = true; break;
 | 
			
		||||
				default: pattern.which = keyCode(key).map(k => k.toLowerCase());
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		return pattern;
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	result.callback = {
 | 
			
		||||
		keydown: keydown || keymap[input],
 | 
			
		||||
		keyup
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	return result;
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@@ -34,28 +52,40 @@ export default {
 | 
			
		||||
			bind(el, binding) {
 | 
			
		||||
				el._hotkey_global = binding.modifiers.global === true;
 | 
			
		||||
 | 
			
		||||
				el._keymap = getKeyMap(binding.value);
 | 
			
		||||
				const actions = getKeyMap(binding.value);
 | 
			
		||||
 | 
			
		||||
				el.dataset.reservedKeyCodes = el._keymap.map(key => `'${key.keyCode}'`).join(' ');
 | 
			
		||||
				// flatten
 | 
			
		||||
				const reservedKeys = concat(concat(actions.map(a => a.patterns.map(p => p.which))));
 | 
			
		||||
 | 
			
		||||
				el.dataset.reservedKeys = reservedKeys.map(key => `'${key}'`).join(' ');
 | 
			
		||||
 | 
			
		||||
				el._keyHandler = e => {
 | 
			
		||||
					const reservedKeyCodes = document.activeElement ? ((document.activeElement as any).dataset || {}).reservedKeyCodes || '' : '';
 | 
			
		||||
					const key = e.code.toLowerCase();
 | 
			
		||||
 | 
			
		||||
					const targetReservedKeys = document.activeElement ? ((document.activeElement as any).dataset || {}).reservedKeys || '' : '';
 | 
			
		||||
					if (document.activeElement && ignoreElemens.some(el => document.activeElement.matches(el))) return;
 | 
			
		||||
 | 
			
		||||
					for (const hotkey of el._keymap) {
 | 
			
		||||
						if (el._hotkey_global && reservedKeyCodes.includes(`'${e.keyCode}'`)) break;
 | 
			
		||||
					for (const action of actions) {
 | 
			
		||||
						if (el._hotkey_global && targetReservedKeys.includes(`'${key}'`)) break;
 | 
			
		||||
 | 
			
		||||
						const callback = hotkey.keyCode === e.keyCode &&
 | 
			
		||||
							!!hotkey.ctrl === e.ctrlKey &&
 | 
			
		||||
							!!hotkey.alt === e.altKey &&
 | 
			
		||||
							!!hotkey.shift === e.shiftKey &&
 | 
			
		||||
							!!hotkey.meta === e.metaKey &&
 | 
			
		||||
							hotkey.callback[e.type];
 | 
			
		||||
						const matched = action.patterns.some(pattern => {
 | 
			
		||||
							const matched = pattern.which.includes(key) &&
 | 
			
		||||
								pattern.ctrl == e.ctrlKey &&
 | 
			
		||||
								pattern.shift == e.shiftKey &&
 | 
			
		||||
								pattern.alt == e.altKey;
 | 
			
		||||
 | 
			
		||||
						if (callback) {
 | 
			
		||||
							e.preventDefault();
 | 
			
		||||
							e.stopPropagation();
 | 
			
		||||
							callback(e);
 | 
			
		||||
							if (matched) {
 | 
			
		||||
								e.preventDefault();
 | 
			
		||||
								e.stopPropagation();
 | 
			
		||||
								action.callback(e);
 | 
			
		||||
								return true;
 | 
			
		||||
							} else {
 | 
			
		||||
								return false;
 | 
			
		||||
							}
 | 
			
		||||
						});
 | 
			
		||||
 | 
			
		||||
						if (matched) {
 | 
			
		||||
							break;
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
				};
 | 
			
		||||
 
 | 
			
		||||
@@ -1,117 +1,20 @@
 | 
			
		||||
export default searchInput => {
 | 
			
		||||
	// Keyboard Events
 | 
			
		||||
	if (searchInput && typeof searchInput === 'object') {
 | 
			
		||||
		const hasKeyCode = searchInput.which || searchInput.keyCode || searchInput.charCode;
 | 
			
		||||
		if (hasKeyCode) {
 | 
			
		||||
			searchInput = hasKeyCode;
 | 
			
		||||
		}
 | 
			
		||||
export default (input: string): string[] => {
 | 
			
		||||
	if (Object.keys(aliases).some(a => a.toLowerCase() == input.toLowerCase())) {
 | 
			
		||||
		const codes = aliases[input];
 | 
			
		||||
		return Array.isArray(codes) ? codes : [codes];
 | 
			
		||||
	} else {
 | 
			
		||||
		return [input];
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Numbers
 | 
			
		||||
	// if (typeof searchInput === 'number') {
 | 
			
		||||
	//   return names[searchInput]
 | 
			
		||||
	// }
 | 
			
		||||
 | 
			
		||||
	// Everything else (cast to string)
 | 
			
		||||
	const search = String(searchInput);
 | 
			
		||||
 | 
			
		||||
	// check codes
 | 
			
		||||
	const foundNamedKeyCodes = codes[search.toLowerCase()];
 | 
			
		||||
	if (foundNamedKeyCodes) {
 | 
			
		||||
		return foundNamedKeyCodes;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// check aliases
 | 
			
		||||
	const foundNamedKeyAliases = aliases[search.toLowerCase()];
 | 
			
		||||
	if (foundNamedKeyAliases) {
 | 
			
		||||
		return foundNamedKeyAliases;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// weird character?
 | 
			
		||||
	if (search.length === 1) {
 | 
			
		||||
		return search.charCodeAt(0);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return undefined;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Get by name
 | 
			
		||||
 *
 | 
			
		||||
 *   exports.code['enter'] // => 13
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
export const codes = {
 | 
			
		||||
	'backspace': 8,
 | 
			
		||||
	'tab': 9,
 | 
			
		||||
	'enter': 13,
 | 
			
		||||
	'shift': 16,
 | 
			
		||||
	'ctrl': 17,
 | 
			
		||||
	'alt': 18,
 | 
			
		||||
	'pause/break': 19,
 | 
			
		||||
	'caps lock': 20,
 | 
			
		||||
	'esc': 27,
 | 
			
		||||
	'space': 32,
 | 
			
		||||
	'page up': 33,
 | 
			
		||||
	'page down': 34,
 | 
			
		||||
	'end': 35,
 | 
			
		||||
	'home': 36,
 | 
			
		||||
	'left': 37,
 | 
			
		||||
	'up': 38,
 | 
			
		||||
	'right': 39,
 | 
			
		||||
	'down': 40,
 | 
			
		||||
	// 'add': 43,
 | 
			
		||||
	'insert': 45,
 | 
			
		||||
	'delete': 46,
 | 
			
		||||
	'command': 91,
 | 
			
		||||
	'left command': 91,
 | 
			
		||||
	'right command': 93,
 | 
			
		||||
	'numpad *': 106,
 | 
			
		||||
	// 'numpad +': 107,
 | 
			
		||||
	'numpad +': 43,
 | 
			
		||||
	'numpad add': 43, // as a trick
 | 
			
		||||
	'numpad -': 109,
 | 
			
		||||
	'numpad .': 110,
 | 
			
		||||
	'numpad /': 111,
 | 
			
		||||
	'num lock': 144,
 | 
			
		||||
	'scroll lock': 145,
 | 
			
		||||
	'my computer': 182,
 | 
			
		||||
	'my calculator': 183,
 | 
			
		||||
	';': 186,
 | 
			
		||||
	'=': 187,
 | 
			
		||||
	',': 188,
 | 
			
		||||
	'-': 189,
 | 
			
		||||
	'.': 190,
 | 
			
		||||
	'/': 191,
 | 
			
		||||
	'`': 192,
 | 
			
		||||
	'[': 219,
 | 
			
		||||
	'\\': 220,
 | 
			
		||||
	']': 221,
 | 
			
		||||
	"'": 222
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Helper aliases
 | 
			
		||||
 | 
			
		||||
export const aliases = {
 | 
			
		||||
	'windows': 91,
 | 
			
		||||
	'⇧': 16,
 | 
			
		||||
	'⌥': 18,
 | 
			
		||||
	'⌃': 17,
 | 
			
		||||
	'⌘': 91,
 | 
			
		||||
	'ctl': 17,
 | 
			
		||||
	'control': 17,
 | 
			
		||||
	'option': 18,
 | 
			
		||||
	'pause': 19,
 | 
			
		||||
	'break': 19,
 | 
			
		||||
	'caps': 20,
 | 
			
		||||
	'return': 13,
 | 
			
		||||
	'escape': 27,
 | 
			
		||||
	'spc': 32,
 | 
			
		||||
	'pgup': 33,
 | 
			
		||||
	'pgdn': 34,
 | 
			
		||||
	'ins': 45,
 | 
			
		||||
	'del': 46,
 | 
			
		||||
	'cmd': 91
 | 
			
		||||
	'esc': 'Escape',
 | 
			
		||||
	'enter': ['Enter', 'NumpadEnter'],
 | 
			
		||||
	'up': 'ArrowUp',
 | 
			
		||||
	'down': 'ArrowDown',
 | 
			
		||||
	'left': 'ArrowLeft',
 | 
			
		||||
	'right': 'ArrowRight',
 | 
			
		||||
	'plus': ['NumpadAdd', 'Semicolon'],
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
@@ -120,20 +23,11 @@ export const aliases = {
 | 
			
		||||
 | 
			
		||||
// lower case chars
 | 
			
		||||
for (let i = 97; i < 123; i++) {
 | 
			
		||||
	codes[String.fromCharCode(i)] = i - 32;
 | 
			
		||||
	const char = String.fromCharCode(i);
 | 
			
		||||
	aliases[char] = `Key${char.toUpperCase()}`;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// numbers
 | 
			
		||||
for (let i = 48; i < 58; i++) {
 | 
			
		||||
	codes[i - 48] = i;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// function keys
 | 
			
		||||
for (let i = 1; i < 13; i++) {
 | 
			
		||||
	codes['f' + i] = i + 111;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// numpad keys
 | 
			
		||||
for (let i = 0; i < 10; i++) {
 | 
			
		||||
	codes['numpad ' + i] = i + 96;
 | 
			
		||||
	aliases[i] = [`Numpad${i}`, `Digit${i}`];
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,9 +2,9 @@
 | 
			
		||||
<div class="onchrpzrvnoruiaenfcqvccjfuupzzwv">
 | 
			
		||||
	<div class="backdrop" ref="backdrop" @click="close"></div>
 | 
			
		||||
	<div class="popover" :class="{ hukidasi }" ref="popover">
 | 
			
		||||
		<template v-for="item in items">
 | 
			
		||||
		<template v-for="item, i in items">
 | 
			
		||||
			<div v-if="item === null"></div>
 | 
			
		||||
			<button v-if="item" @click="clicked(item.action)" v-html="item.icon ? item.icon + ' ' + item.text : item.text"></button>
 | 
			
		||||
			<button v-if="item" @click="clicked(item.action)" v-html="item.icon ? item.icon + ' ' + item.text : item.text" :tabindex="i"></button>
 | 
			
		||||
		</template>
 | 
			
		||||
	</div>
 | 
			
		||||
</div>
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
	<div class="backdrop" ref="backdrop" @click="close"></div>
 | 
			
		||||
	<div class="popover" :class="{ compact, big }" ref="popover">
 | 
			
		||||
		<p v-if="!compact">{{ title }}</p>
 | 
			
		||||
		<div>
 | 
			
		||||
		<div ref="buttons" :class="{ showFocus }">
 | 
			
		||||
			<button @click="react('like')" @mouseover="onMouseover" @mouseout="onMouseout" tabindex="1" title="%i18n:common.reactions.like%"><mk-reaction-icon reaction='like'/></button>
 | 
			
		||||
			<button @click="react('love')" @mouseover="onMouseover" @mouseout="onMouseout" tabindex="2" title="%i18n:common.reactions.love%"><mk-reaction-icon reaction='love'/></button>
 | 
			
		||||
			<button @click="react('laugh')" @mouseover="onMouseover" @mouseout="onMouseout" tabindex="3" title="%i18n:common.reactions.laugh%"><mk-reaction-icon reaction='laugh'/></button>
 | 
			
		||||
@@ -50,18 +50,37 @@ export default Vue.extend({
 | 
			
		||||
			type: Boolean,
 | 
			
		||||
			required: false,
 | 
			
		||||
			default: false
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		showFocus: {
 | 
			
		||||
			type: Boolean,
 | 
			
		||||
			required: false,
 | 
			
		||||
			default: false
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		animation: {
 | 
			
		||||
			type: Boolean,
 | 
			
		||||
			required: false,
 | 
			
		||||
			default: true
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	data() {
 | 
			
		||||
		return {
 | 
			
		||||
			title: placeholder
 | 
			
		||||
			title: placeholder,
 | 
			
		||||
			focus: null
 | 
			
		||||
		};
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	computed: {
 | 
			
		||||
		keymap(): any {
 | 
			
		||||
			return {
 | 
			
		||||
				'esc': this.close,
 | 
			
		||||
				'enter|space|plus': this.choose,
 | 
			
		||||
				'up|k': this.focusUp,
 | 
			
		||||
				'left|h|shift+tab': this.focusLeft,
 | 
			
		||||
				'right|l|tab': this.focusRight,
 | 
			
		||||
				'down|j': this.focusDown,
 | 
			
		||||
				'1': () => this.react('like'),
 | 
			
		||||
				'2': () => this.react('love'),
 | 
			
		||||
				'3': () => this.react('laugh'),
 | 
			
		||||
@@ -76,8 +95,20 @@ export default Vue.extend({
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	watch: {
 | 
			
		||||
		focus(i) {
 | 
			
		||||
			this.$refs.buttons.children[i].focus();
 | 
			
		||||
 | 
			
		||||
			if (this.showFocus) {
 | 
			
		||||
				this.title = this.$refs.buttons.children[i].title;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	mounted() {
 | 
			
		||||
		this.$nextTick(() => {
 | 
			
		||||
			this.focus = 0;
 | 
			
		||||
 | 
			
		||||
			const popover = this.$refs.popover as any;
 | 
			
		||||
 | 
			
		||||
			const rect = this.source.getBoundingClientRect();
 | 
			
		||||
@@ -99,7 +130,7 @@ export default Vue.extend({
 | 
			
		||||
			anime({
 | 
			
		||||
				targets: this.$refs.backdrop,
 | 
			
		||||
				opacity: 1,
 | 
			
		||||
				duration: 100,
 | 
			
		||||
				duration: this.animation ? 100 : 0,
 | 
			
		||||
				easing: 'linear'
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
@@ -107,7 +138,7 @@ export default Vue.extend({
 | 
			
		||||
				targets: this.$refs.popover,
 | 
			
		||||
				opacity: 1,
 | 
			
		||||
				scale: [0.5, 1],
 | 
			
		||||
				duration: 500
 | 
			
		||||
				duration: this.animation ? 500 : 0
 | 
			
		||||
			});
 | 
			
		||||
		});
 | 
			
		||||
	},
 | 
			
		||||
@@ -137,7 +168,7 @@ export default Vue.extend({
 | 
			
		||||
			anime({
 | 
			
		||||
				targets: this.$refs.backdrop,
 | 
			
		||||
				opacity: 0,
 | 
			
		||||
				duration: 200,
 | 
			
		||||
				duration: this.animation ? 200 : 0,
 | 
			
		||||
				easing: 'linear'
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
@@ -146,13 +177,33 @@ export default Vue.extend({
 | 
			
		||||
				targets: this.$refs.popover,
 | 
			
		||||
				opacity: 0,
 | 
			
		||||
				scale: 0.5,
 | 
			
		||||
				duration: 200,
 | 
			
		||||
				duration: this.animation ? 200 : 0,
 | 
			
		||||
				easing: 'easeInBack',
 | 
			
		||||
				complete: () => {
 | 
			
		||||
					this.$emit('closed');
 | 
			
		||||
					this.destroyDom();
 | 
			
		||||
				}
 | 
			
		||||
			});
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		focusUp() {
 | 
			
		||||
			this.focus = this.focus == 0 ? 9 : this.focus < 5 ? (this.focus + 4) : (this.focus - 5);
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		focusDown() {
 | 
			
		||||
			this.focus = this.focus == 9 ? 0 : this.focus >= 5 ? (this.focus - 4) : (this.focus + 5);
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		focusRight() {
 | 
			
		||||
			this.focus = this.focus == 9 ? 0 : (this.focus + 1);
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		focusLeft() {
 | 
			
		||||
			this.focus = this.focus == 0 ? 9 : (this.focus - 1);
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		choose() {
 | 
			
		||||
			this.$refs.buttons.childNodes[this.focus].click();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
});
 | 
			
		||||
@@ -238,6 +289,21 @@ root(isDark)
 | 
			
		||||
			width 240px
 | 
			
		||||
			text-align center
 | 
			
		||||
 | 
			
		||||
			&.showFocus
 | 
			
		||||
				> button:focus
 | 
			
		||||
					z-index 1
 | 
			
		||||
 | 
			
		||||
					&:after
 | 
			
		||||
						content ""
 | 
			
		||||
						pointer-events none
 | 
			
		||||
						position absolute
 | 
			
		||||
						top 0
 | 
			
		||||
						right 0
 | 
			
		||||
						bottom 0
 | 
			
		||||
						left 0
 | 
			
		||||
						border 2px solid rgba($theme-color, 0.3)
 | 
			
		||||
						border-radius 4px
 | 
			
		||||
 | 
			
		||||
			> button
 | 
			
		||||
				padding 0
 | 
			
		||||
				width 40px
 | 
			
		||||
 
 | 
			
		||||
@@ -40,18 +40,18 @@
 | 
			
		||||
			</div>
 | 
			
		||||
			<footer>
 | 
			
		||||
				<mk-reactions-viewer :note="p" ref="reactionsViewer"/>
 | 
			
		||||
				<button class="replyButton" @click="reply" title="%i18n:@reply%">
 | 
			
		||||
				<button class="replyButton" @click="reply()" title="%i18n:@reply%">
 | 
			
		||||
					<template v-if="p.reply">%fa:reply-all%</template>
 | 
			
		||||
					<template v-else>%fa:reply%</template>
 | 
			
		||||
					<p class="count" v-if="p.repliesCount > 0">{{ p.repliesCount }}</p>
 | 
			
		||||
				</button>
 | 
			
		||||
				<button class="renoteButton" @click="renote" title="%i18n:@renote%">
 | 
			
		||||
				<button class="renoteButton" @click="renote()" title="%i18n:@renote%">
 | 
			
		||||
					%fa:retweet%<p class="count" v-if="p.renoteCount > 0">{{ p.renoteCount }}</p>
 | 
			
		||||
				</button>
 | 
			
		||||
				<button class="reactionButton" :class="{ reacted: p.myReaction != null }" @click="react" ref="reactButton" title="%i18n:@add-reaction%">
 | 
			
		||||
				<button class="reactionButton" :class="{ reacted: p.myReaction != null }" @click="react()" ref="reactButton" title="%i18n:@add-reaction%">
 | 
			
		||||
					%fa:plus%<p class="count" v-if="p.reactions_count > 0">{{ p.reactions_count }}</p>
 | 
			
		||||
				</button>
 | 
			
		||||
				<button @click="menu" ref="menuButton">
 | 
			
		||||
				<button @click="menu()" ref="menuButton">
 | 
			
		||||
					%fa:ellipsis-h%
 | 
			
		||||
				</button>
 | 
			
		||||
				<!-- <button title="%i18n:@detail">
 | 
			
		||||
@@ -113,13 +113,25 @@ export default Vue.extend({
 | 
			
		||||
	computed: {
 | 
			
		||||
		keymap(): any {
 | 
			
		||||
			return {
 | 
			
		||||
				'r': this.reply,
 | 
			
		||||
				'a': this.react,
 | 
			
		||||
				'n': this.renote,
 | 
			
		||||
				'up': this.focusBefore,
 | 
			
		||||
				'shift+tab': this.focusBefore,
 | 
			
		||||
				'down': this.focusAfter,
 | 
			
		||||
				'tab': this.focusAfter,
 | 
			
		||||
				'r|left': () => this.reply(true),
 | 
			
		||||
				'e|a|plus': () => this.react(true),
 | 
			
		||||
				'q|right': () => this.renote(true),
 | 
			
		||||
				'ctrl+q|ctrl+right': this.renoteDirectly,
 | 
			
		||||
				'up|k|shift+tab': this.focusBefore,
 | 
			
		||||
				'down|j|tab': this.focusAfter,
 | 
			
		||||
				'esc': this.blur,
 | 
			
		||||
				'm|o': () => this.menu(true),
 | 
			
		||||
				's': this.toggleShowContent,
 | 
			
		||||
				'1': () => this.reactDirectly('like'),
 | 
			
		||||
				'2': () => this.reactDirectly('love'),
 | 
			
		||||
				'3': () => this.reactDirectly('laugh'),
 | 
			
		||||
				'4': () => this.reactDirectly('hmm'),
 | 
			
		||||
				'5': () => this.reactDirectly('surprise'),
 | 
			
		||||
				'6': () => this.reactDirectly('congrats'),
 | 
			
		||||
				'7': () => this.reactDirectly('angry'),
 | 
			
		||||
				'8': () => this.reactDirectly('confused'),
 | 
			
		||||
				'9': () => this.reactDirectly('rip'),
 | 
			
		||||
				'0': () => this.reactDirectly('pudding'),
 | 
			
		||||
			};
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
@@ -232,36 +244,63 @@ export default Vue.extend({
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		reply() {
 | 
			
		||||
		reply(viaKeyboard = false) {
 | 
			
		||||
			(this as any).os.new(MkPostFormWindow, {
 | 
			
		||||
				reply: this.p
 | 
			
		||||
				reply: this.p,
 | 
			
		||||
				animation: !viaKeyboard
 | 
			
		||||
			}).$once('closed', this.focus);
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		renote() {
 | 
			
		||||
		renote(viaKeyboard = false) {
 | 
			
		||||
			(this as any).os.new(MkRenoteFormWindow, {
 | 
			
		||||
				note: this.p
 | 
			
		||||
				note: this.p,
 | 
			
		||||
				animation: !viaKeyboard
 | 
			
		||||
			}).$once('closed', this.focus);
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		react() {
 | 
			
		||||
		renoteDirectly() {
 | 
			
		||||
			(this as any).api('notes/create', {
 | 
			
		||||
				renoteId: this.p.id
 | 
			
		||||
			});
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		react(viaKeyboard = false) {
 | 
			
		||||
			this.blur();
 | 
			
		||||
			(this as any).os.new(MkReactionPicker, {
 | 
			
		||||
				source: this.$refs.reactButton,
 | 
			
		||||
				note: this.p
 | 
			
		||||
				note: this.p,
 | 
			
		||||
				showFocus: viaKeyboard,
 | 
			
		||||
				animation: !viaKeyboard
 | 
			
		||||
			}).$once('closed', this.focus);
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		menu() {
 | 
			
		||||
		reactDirectly(reaction) {
 | 
			
		||||
			(this as any).api('notes/reactions/create', {
 | 
			
		||||
				noteId: this.p.id,
 | 
			
		||||
				reaction: reaction
 | 
			
		||||
			});
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		menu(viaKeyboard = false) {
 | 
			
		||||
			(this as any).os.new(MkNoteMenu, {
 | 
			
		||||
				source: this.$refs.menuButton,
 | 
			
		||||
				note: this.p
 | 
			
		||||
				note: this.p,
 | 
			
		||||
				animation: !viaKeyboard
 | 
			
		||||
			}).$once('closed', this.focus);
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		toggleShowContent() {
 | 
			
		||||
			this.showContent = !this.showContent;
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		focus() {
 | 
			
		||||
			this.$el.focus();
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		blur() {
 | 
			
		||||
			this.$el.blur();
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		focusBefore() {
 | 
			
		||||
			focus(this.$el, e => e.previousElementSibling);
 | 
			
		||||
		},
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,7 @@
 | 
			
		||||
	</div>
 | 
			
		||||
 | 
			
		||||
	<!-- トランジションを有効にするとなぜかメモリリークする -->
 | 
			
		||||
	<component :is="!$store.state.device.reduceMotion ? 'transition-group' : 'div'" name="mk-notes" class="notes transition" tag="div">
 | 
			
		||||
	<component :is="!$store.state.device.reduceMotion ? 'transition-group' : 'div'" name="mk-notes" class="notes transition" tag="div" ref="notes">
 | 
			
		||||
		<template v-for="(note, i) in _notes">
 | 
			
		||||
			<x-note :note="note" :key="note.id" @update:note="onNoteUpdated(i, $event)" ref="note"/>
 | 
			
		||||
			<p class="date" :key="note.id + '_date'" v-if="i != notes.length - 1 && note._date != _notes[i + 1]._date">
 | 
			
		||||
@@ -89,7 +89,7 @@ export default Vue.extend({
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		focus() {
 | 
			
		||||
			(this.$refs.note as any)[0].focus();
 | 
			
		||||
			(this.$refs.notes as any).children[0].focus ? (this.$refs.notes as any).children[0].focus() : (this.$refs.notes as any).$el.children[0].focus();
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		onNoteUpdated(i, note) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
<template>
 | 
			
		||||
<mk-window class="mk-post-form-window" ref="window" is-modal @closed="onWindowClosed">
 | 
			
		||||
<mk-window class="mk-post-form-window" ref="window" is-modal @closed="onWindowClosed" :animation="animation">
 | 
			
		||||
	<span slot="header" class="mk-post-form-window--header">
 | 
			
		||||
		<span class="icon" v-if="geo">%fa:map-marker-alt%</span>
 | 
			
		||||
		<span v-if="!reply">%i18n:@note%</span>
 | 
			
		||||
@@ -25,7 +25,19 @@
 | 
			
		||||
import Vue from 'vue';
 | 
			
		||||
 | 
			
		||||
export default Vue.extend({
 | 
			
		||||
	props: ['reply'],
 | 
			
		||||
	props: {
 | 
			
		||||
		reply: {
 | 
			
		||||
			type: Object,
 | 
			
		||||
			required: false
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		animation: {
 | 
			
		||||
			type: Boolean,
 | 
			
		||||
			required: false,
 | 
			
		||||
			default: true
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	data() {
 | 
			
		||||
		return {
 | 
			
		||||
			uploadings: [],
 | 
			
		||||
@@ -33,11 +45,13 @@ export default Vue.extend({
 | 
			
		||||
			geo: null
 | 
			
		||||
		};
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	mounted() {
 | 
			
		||||
		this.$nextTick(() => {
 | 
			
		||||
			(this.$refs.form as any).focus();
 | 
			
		||||
		});
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	methods: {
 | 
			
		||||
		onChangeUploadings(files) {
 | 
			
		||||
			this.uploadings = files;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
<template>
 | 
			
		||||
<mk-window ref="window" is-modal @closed="onWindowClosed">
 | 
			
		||||
<mk-window ref="window" is-modal @closed="onWindowClosed" :animation="animation">
 | 
			
		||||
	<span slot="header" :class="$style.header">%fa:retweet%%i18n:@title%</span>
 | 
			
		||||
	<mk-renote-form ref="form" :note="note" @posted="onPosted" @canceled="onCanceled" v-hotkey.global="keymap"/>
 | 
			
		||||
</mk-window>
 | 
			
		||||
@@ -9,13 +9,25 @@
 | 
			
		||||
import Vue from 'vue';
 | 
			
		||||
 | 
			
		||||
export default Vue.extend({
 | 
			
		||||
	props: ['note'],
 | 
			
		||||
	props: {
 | 
			
		||||
		note: {
 | 
			
		||||
			type: Object,
 | 
			
		||||
			required: true
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		animation: {
 | 
			
		||||
			type: Boolean,
 | 
			
		||||
			required: false,
 | 
			
		||||
			default: true
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	computed: {
 | 
			
		||||
		keymap(): any {
 | 
			
		||||
			return {
 | 
			
		||||
				'esc': this.close,
 | 
			
		||||
				'ctrl+enter': this.post
 | 
			
		||||
				'enter': this.post,
 | 
			
		||||
				'q': this.quote,
 | 
			
		||||
			};
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
@@ -24,6 +36,9 @@ export default Vue.extend({
 | 
			
		||||
		post() {
 | 
			
		||||
			(this.$refs.form as any).ok();
 | 
			
		||||
		},
 | 
			
		||||
		quote() {
 | 
			
		||||
			(this.$refs.form as any).onQuote();
 | 
			
		||||
		},
 | 
			
		||||
		close() {
 | 
			
		||||
			(this.$refs.window as any).close();
 | 
			
		||||
		},
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
<template>
 | 
			
		||||
<div class="account">
 | 
			
		||||
<div class="account" v-hotkey.global="keymap">
 | 
			
		||||
	<button class="header" :data-active="isOpen" @click="toggle">
 | 
			
		||||
		<span class="username">{{ $store.state.i.username }}<template v-if="!isOpen">%fa:angle-down%</template><template v-if="isOpen">%fa:angle-up%</template></span>
 | 
			
		||||
		<mk-avatar class="avatar" :user="$store.state.i"/>
 | 
			
		||||
@@ -63,6 +63,13 @@ export default Vue.extend({
 | 
			
		||||
			isOpen: false
 | 
			
		||||
		};
 | 
			
		||||
	},
 | 
			
		||||
	computed: {
 | 
			
		||||
		keymap(): any {
 | 
			
		||||
			return {
 | 
			
		||||
				'a|m': this.toggle
 | 
			
		||||
			};
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	beforeDestroy() {
 | 
			
		||||
		this.close();
 | 
			
		||||
	},
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
<template>
 | 
			
		||||
<div class="notifications">
 | 
			
		||||
<div class="notifications" v-hotkey.global="keymap">
 | 
			
		||||
	<button :data-active="isOpen" @click="toggle" title="%i18n:@title%">
 | 
			
		||||
		%fa:R bell%<template v-if="hasUnreadNotification">%fa:circle%</template>
 | 
			
		||||
	</button>
 | 
			
		||||
@@ -19,11 +19,19 @@ export default Vue.extend({
 | 
			
		||||
			isOpen: false
 | 
			
		||||
		};
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	computed: {
 | 
			
		||||
		hasUnreadNotification(): boolean {
 | 
			
		||||
			return this.$store.getters.isSignedIn && this.$store.state.i.hasUnreadNotification;
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		keymap(): any {
 | 
			
		||||
			return {
 | 
			
		||||
				'shift+n': this.toggle
 | 
			
		||||
			};
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	methods: {
 | 
			
		||||
		toggle() {
 | 
			
		||||
			this.isOpen ? this.close() : this.open();
 | 
			
		||||
 
 | 
			
		||||
@@ -76,6 +76,11 @@ export default Vue.extend({
 | 
			
		||||
		name: {
 | 
			
		||||
			type: String,
 | 
			
		||||
			default: null
 | 
			
		||||
		},
 | 
			
		||||
		animation: {
 | 
			
		||||
			type: Boolean,
 | 
			
		||||
			required: false,
 | 
			
		||||
			default: true
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
@@ -142,7 +147,7 @@ export default Vue.extend({
 | 
			
		||||
				anime({
 | 
			
		||||
					targets: bg,
 | 
			
		||||
					opacity: 1,
 | 
			
		||||
					duration: 100,
 | 
			
		||||
					duration: this.animation ? 100 : 0,
 | 
			
		||||
					easing: 'linear'
 | 
			
		||||
				});
 | 
			
		||||
			}
 | 
			
		||||
@@ -152,7 +157,7 @@ export default Vue.extend({
 | 
			
		||||
				targets: main,
 | 
			
		||||
				opacity: 1,
 | 
			
		||||
				scale: [1.1, 1],
 | 
			
		||||
				duration: 200,
 | 
			
		||||
				duration: this.animation ? 200 : 0,
 | 
			
		||||
				easing: 'easeOutQuad'
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
@@ -160,7 +165,7 @@ export default Vue.extend({
 | 
			
		||||
 | 
			
		||||
			setTimeout(() => {
 | 
			
		||||
				this.$emit('opened');
 | 
			
		||||
			}, 300);
 | 
			
		||||
			}, this.animation ? 300 : 0);
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		close() {
 | 
			
		||||
@@ -174,7 +179,7 @@ export default Vue.extend({
 | 
			
		||||
				anime({
 | 
			
		||||
					targets: bg,
 | 
			
		||||
					opacity: 0,
 | 
			
		||||
					duration: 300,
 | 
			
		||||
					duration: this.animation ? 300 : 0,
 | 
			
		||||
					easing: 'linear'
 | 
			
		||||
				});
 | 
			
		||||
			}
 | 
			
		||||
@@ -185,14 +190,14 @@ export default Vue.extend({
 | 
			
		||||
				targets: main,
 | 
			
		||||
				opacity: 0,
 | 
			
		||||
				scale: 0.8,
 | 
			
		||||
				duration: 300,
 | 
			
		||||
				duration: this.animation ? 300 : 0,
 | 
			
		||||
				easing: [0.5, -0.5, 1, 0.5]
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
			setTimeout(() => {
 | 
			
		||||
				this.$emit('closed');
 | 
			
		||||
				this.destroyDom();
 | 
			
		||||
			}, 300);
 | 
			
		||||
			}, this.animation ? 300 : 0);
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		popout() {
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@
 | 
			
		||||
		<main>
 | 
			
		||||
			<div class="main">
 | 
			
		||||
				<x-header :user="user"/>
 | 
			
		||||
				<mk-note-detail v-if="user.pinnedNote" :note="user.pinnedNote" :compact="true"/>
 | 
			
		||||
				<mk-note-detail v-for="n in user.pinnedNotes" :key="n.id" :note="n" :compact="true"/>
 | 
			
		||||
				<x-timeline class="timeline" ref="tl" :user="user"/>
 | 
			
		||||
			</div>
 | 
			
		||||
			<div class="side">
 | 
			
		||||
@@ -28,7 +28,6 @@
 | 
			
		||||
<script lang="ts">
 | 
			
		||||
import Vue from 'vue';
 | 
			
		||||
import parseAcct from '../../../../../../misc/acct/parse';
 | 
			
		||||
import getUserName from '../../../../../../misc/get-user-name';
 | 
			
		||||
import Progress from '../../../../common/scripts/loading';
 | 
			
		||||
import XHeader from './user.header.vue';
 | 
			
		||||
import XTimeline from './user.timeline.vue';
 | 
			
		||||
 
 | 
			
		||||
@@ -35,7 +35,7 @@
 | 
			
		||||
					<span :data-active="src == 'mentions'" @click="src = 'mentions'">%fa:at% %i18n:@mentions%</span>
 | 
			
		||||
					<span :data-active="src == 'messages'" @click="src = 'messages'">%fa:envelope R% %i18n:@messages%</span>
 | 
			
		||||
					<template v-if="lists">
 | 
			
		||||
						<div class="hr"></div>
 | 
			
		||||
						<div class="hr" v-if="lists.length > 0"></div>
 | 
			
		||||
						<span v-for="l in lists" :data-active="src == 'list' && list == l" @click="src = 'list'; list = l" :key="l.id">%fa:list% {{ l.title }}</span>
 | 
			
		||||
					</template>
 | 
			
		||||
					<div class="hr" v-if="$store.state.settings.tagTimelines && $store.state.settings.tagTimelines.length > 0"></div>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
<template>
 | 
			
		||||
<div class="root home">
 | 
			
		||||
	<mk-note-detail v-if="user.pinnedNote" :note="user.pinnedNote" :compact="true"/>
 | 
			
		||||
	<mk-note-detail v-for="n in user.pinnedNotes" :key="n.id" :note="n" :compact="true"/>
 | 
			
		||||
	<section class="recent-notes">
 | 
			
		||||
		<h2>%fa:R comments%%i18n:@recent-notes%</h2>
 | 
			
		||||
		<div>
 | 
			
		||||
 
 | 
			
		||||
@@ -101,15 +101,15 @@ props:
 | 
			
		||||
      ja-JP: "投稿の数"
 | 
			
		||||
      en-US: "The number of the notes of this user"
 | 
			
		||||
 | 
			
		||||
  pinnedNote:
 | 
			
		||||
    type: "entity(Note)"
 | 
			
		||||
  pinnedNotes:
 | 
			
		||||
    type: "entity(Note)[]"
 | 
			
		||||
    optional: true
 | 
			
		||||
    desc:
 | 
			
		||||
      ja-JP: "ピン留めされた投稿"
 | 
			
		||||
      en-US: "The pinned note of this user"
 | 
			
		||||
 | 
			
		||||
  pinnedNoteId:
 | 
			
		||||
    type: "id(Note)"
 | 
			
		||||
  pinnedNoteIds:
 | 
			
		||||
    type: "id(Note)[]"
 | 
			
		||||
    optional: true
 | 
			
		||||
    desc:
 | 
			
		||||
      ja-JP: "ピン留めされた投稿のID"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										96
									
								
								src/docs/keyboard-shortcut.ja-JP.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								src/docs/keyboard-shortcut.ja-JP.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,96 @@
 | 
			
		||||
# Misskeyキーボードショートカットまとめ
 | 
			
		||||
 | 
			
		||||
## グローバル
 | 
			
		||||
これらのショートカットは基本的にどこでも使えます。
 | 
			
		||||
<table>
 | 
			
		||||
	<thead>
 | 
			
		||||
		<tr><th>ショートカット</th><th>効果</th><th>由来</th></tr>
 | 
			
		||||
	</thead>
 | 
			
		||||
	<tbody>
 | 
			
		||||
		<tr><td><kbd class="key">P</kbd>, <kbd class="key">N</kbd></td><td>新規投稿</td><td><b>P</b>ost, <b>N</b>ew, <b>N</b>ote</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">T</kbd></td><td>タイムラインの最も新しい投稿にフォーカス</td><td><b>T</b>imeline, <b>T</b>op</td></tr>
 | 
			
		||||
		<tr><td><kbd class="group"><kbd class="key">Shift</kbd> + <kbd class="key">N</kbd></kbd></td><td>通知を表示/隠す</td><td><b>N</b>otifications</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">A</kbd>, <kbd class="key">M</kbd></td><td>アカウントメニューを表示/隠す</td><td><b>A</b>ccount, <b>M</b>y, <b>M</b>e, <b>M</b>enu</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">Z</kbd></td><td>上部のバーを隠す</td><td><b>Z</b>en</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">H</kbd>, <kbd class="key">?</kbd></td><td>ヘルプを表示</td><td><b>H</b>elp</td></tr>
 | 
			
		||||
	</tbody>
 | 
			
		||||
</table>
 | 
			
		||||
 | 
			
		||||
## 投稿にフォーカスされた状態
 | 
			
		||||
<table>
 | 
			
		||||
	<thead>
 | 
			
		||||
		<tr><th>ショートカット</th><th>効果</th><th>由来</th></tr>
 | 
			
		||||
	</thead>
 | 
			
		||||
	<tbody>
 | 
			
		||||
		<tr><td><kbd class="key">↑</kbd>, <kbd class="key">K</kbd>, <kbd class="group"><kbd class="key">Shift</kbd> + <kbd class="key">Tab</kbd></kbd></td><td>上の投稿にフォーカスを移動</td><td>-</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">↓</kbd>, <kbd class="key">J</kbd>, <kbd class="key">Tab</kbd></td><td>下の投稿にフォーカスを移動</td><td>-</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">←</kbd>, <kbd class="key">R</kbd></td><td>返信フォームを開く</td><td><b>R</b>eply</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">→</kbd>, <kbd class="key">Q</kbd></td><td>Renoteフォームを開く</td><td><b>Q</b>uote</td></tr>
 | 
			
		||||
		<tr><td><kbd class="group"><kbd class="key">Ctrl</kbd> + <kbd class="key">→</kbd></kbd>, <kbd class="group"><kbd class="key">Ctrl</kbd> + <kbd class="key">Q</kbd></kbd></td><td>即刻Renoteする(フォームを開かずに)</td><td>-</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">E</kbd>, <kbd class="key">A</kbd>, <kbd class="key">+</kbd></td><td>リアクションフォームを開く</td><td><b>E</b>mote, re<b>A</b>ction</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">0</kbd>~<kbd class="key">9</kbd></td><td>数字に対応したリアクションをする(対応については後述)</td><td>-</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">M</kbd>, <kbd class="key">O</kbd></td><td>投稿に対するメニューを開く</td><td><b>M</b>ore, <b>O</b>ther</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">S</kbd></td><td>CWで隠された部分を表示 or 隠す</td><td><b>S</b>how, <b>S</b>ee</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">Esc</kbd></td><td>フォーカスを外す</td><td>-</td></tr>
 | 
			
		||||
	</tbody>
 | 
			
		||||
</table>
 | 
			
		||||
 | 
			
		||||
## Renoteフォーム
 | 
			
		||||
<table>
 | 
			
		||||
	<thead>
 | 
			
		||||
		<tr><th>ショートカット</th><th>効果</th><th>由来</th></tr>
 | 
			
		||||
	</thead>
 | 
			
		||||
	<tbody>
 | 
			
		||||
		<tr><td><kbd class="key">Enter</kbd></td><td>Renoteする</td><td>-</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">Q</kbd></td><td>フォームを展開する</td><td><b>Q</b>uote</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">Esc</kbd></td><td>フォームを閉じる</td><td>-</td></tr>
 | 
			
		||||
	</tbody>
 | 
			
		||||
</table>
 | 
			
		||||
 | 
			
		||||
## リアクションフォーム
 | 
			
		||||
デフォルトで「👍」にフォーカスが当たっている状態です。
 | 
			
		||||
<table>
 | 
			
		||||
	<thead>
 | 
			
		||||
		<tr><th>ショートカット</th><th>効果</th><th>由来</th></tr>
 | 
			
		||||
	</thead>
 | 
			
		||||
	<tbody>
 | 
			
		||||
		<tr><td><kbd class="key">↑</kbd>, <kbd class="key">K</kbd></td><td>上のリアクションにフォーカスを移動</td><td>-</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">↓</kbd>, <kbd class="key">J</kbd></td><td>下のリアクションにフォーカスを移動</td><td>-</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">←</kbd>, <kbd class="key">H</kbd>, <kbd class="group"><kbd class="key">Shift</kbd> + <kbd class="key">Tab</kbd></kbd></td><td>左のリアクションにフォーカスを移動</td><td>-</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">→</kbd>, <kbd class="key">L</kbd>, <kbd class="key">Tab</kbd></td><td>右のリアクションにフォーカスを移動</td><td>-</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">Enter</kbd>, <kbd class="key">Space</kbd>, <kbd class="key">+</kbd></td><td>リアクション確定</td><td>-</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">0</kbd>~<kbd class="key">9</kbd></td><td>数字に対応したリアクションで確定(対応については後述)</td><td>-</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">Esc</kbd></td><td>リアクションするのをやめる</td><td>-</td></tr>
 | 
			
		||||
	</tbody>
 | 
			
		||||
</table>
 | 
			
		||||
 | 
			
		||||
## リアクションと数字キーの対応
 | 
			
		||||
<table>
 | 
			
		||||
	<thead>
 | 
			
		||||
		<tr><th>数字キー</th><th>リアクション</th></tr>
 | 
			
		||||
	</thead>
 | 
			
		||||
	<tbody>
 | 
			
		||||
		<tr><td><kbd class="key">1</kbd></td><td>👍</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">2</kbd></td><td>❤️</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">3</kbd></td><td>😆</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">4</kbd></td><td>🤔</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">5</kbd></td><td>😮</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">6</kbd></td><td>🎉</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">7</kbd></td><td>💢</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">8</kbd></td><td>😥</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">9</kbd></td><td>😇</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">0</kbd></td><td>🍮 or 🍣</td></tr>
 | 
			
		||||
	</tbody>
 | 
			
		||||
</table>
 | 
			
		||||
 | 
			
		||||
# 例
 | 
			
		||||
<table>
 | 
			
		||||
	<thead>
 | 
			
		||||
		<tr><th>ショートカット</th><th>動作</th></tr>
 | 
			
		||||
	</thead>
 | 
			
		||||
	<tbody>
 | 
			
		||||
		<tr><td><kbd class="key">t</kbd><kbd class="key">+</kbd><kbd class="key">+</kbd></td><td>タイムラインの最新の投稿に👍する</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">t</kbd><kbd class="key">1</kbd></td><td>タイムラインの最新の投稿に👍する</td></tr>
 | 
			
		||||
		<tr><td><kbd class="key">t</kbd><kbd class="key">0</kbd></td><td>タイムラインの最新の投稿に🍮する</td></tr>
 | 
			
		||||
	</tbody>
 | 
			
		||||
</table>
 | 
			
		||||
@@ -128,3 +128,24 @@ pre
 | 
			
		||||
	> code
 | 
			
		||||
		display block
 | 
			
		||||
		padding 16px
 | 
			
		||||
 | 
			
		||||
kbd.group
 | 
			
		||||
	display inline-block
 | 
			
		||||
	padding 4px
 | 
			
		||||
	background #fbfbfb
 | 
			
		||||
	border 1px solid #d6d6d6
 | 
			
		||||
	border-radius 4px
 | 
			
		||||
	box-shadow 0 1px 1px rgba(0, 0, 0, 0.1)
 | 
			
		||||
 | 
			
		||||
kbd.key
 | 
			
		||||
	display inline-block
 | 
			
		||||
	padding 6px 8px
 | 
			
		||||
	background #fff
 | 
			
		||||
	border solid 1px #cecece
 | 
			
		||||
	border-radius 4px
 | 
			
		||||
	box-shadow 0 1px 1px rgba(0, 0, 0, 0.1)
 | 
			
		||||
 | 
			
		||||
td
 | 
			
		||||
	> kbd.group,
 | 
			
		||||
	> kbd.key
 | 
			
		||||
		margin 4px
 | 
			
		||||
 
 | 
			
		||||
@@ -35,6 +35,28 @@ User.createIndex('uri', { sparse: true, unique: true });
 | 
			
		||||
 | 
			
		||||
export default User;
 | 
			
		||||
 | 
			
		||||
// 後方互換性のため
 | 
			
		||||
User.findOne({
 | 
			
		||||
	pinnedNoteId: { $exists: true }
 | 
			
		||||
}).then(async x => {
 | 
			
		||||
	if (x == null) return;
 | 
			
		||||
 | 
			
		||||
	const users = await User.find({
 | 
			
		||||
		pinnedNoteId: { $exists: true }
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	users.forEach(u => {
 | 
			
		||||
		User.update({ _id: u._id }, {
 | 
			
		||||
			$set: {
 | 
			
		||||
				pinnedNoteIds: [(u as any).pinnedNoteId]
 | 
			
		||||
			},
 | 
			
		||||
			$unset: {
 | 
			
		||||
				pinnedNoteId: ''
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	});
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
type IUserBase = {
 | 
			
		||||
	_id: mongo.ObjectID;
 | 
			
		||||
	createdAt: Date;
 | 
			
		||||
@@ -53,7 +75,7 @@ type IUserBase = {
 | 
			
		||||
	wallpaperUrl?: string;
 | 
			
		||||
	data: any;
 | 
			
		||||
	description: string;
 | 
			
		||||
	pinnedNoteId: mongo.ObjectID;
 | 
			
		||||
	pinnedNoteIds: mongo.ObjectID[];
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 凍結されているか否か
 | 
			
		||||
@@ -464,11 +486,11 @@ export const pack = (
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (opts.detail) {
 | 
			
		||||
		if (_user.pinnedNoteId) {
 | 
			
		||||
			// Populate pinned note
 | 
			
		||||
			_user.pinnedNote = packNote(_user.pinnedNoteId, meId, {
 | 
			
		||||
		if (_user.pinnedNoteIds) {
 | 
			
		||||
			// Populate pinned notes
 | 
			
		||||
			_user.pinnedNotes = Promise.all(_user.pinnedNoteIds.map((id: mongo.ObjectId) => packNote(id, meId, {
 | 
			
		||||
				detail: true
 | 
			
		||||
			});
 | 
			
		||||
			})));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (meId && !meId.equals(_user.id)) {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										9
									
								
								src/remote/activitypub/renderer/add.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								src/remote/activitypub/renderer/add.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
			
		||||
import config from '../../../config';
 | 
			
		||||
import { ILocalUser } from '../../../models/user';
 | 
			
		||||
 | 
			
		||||
export default (user: ILocalUser, target: any, object: any) => ({
 | 
			
		||||
	type: 'Add',
 | 
			
		||||
	actor: `${config.url}/users/${user._id}`,
 | 
			
		||||
	target,
 | 
			
		||||
	object
 | 
			
		||||
});
 | 
			
		||||
@@ -4,8 +4,9 @@
 | 
			
		||||
 * @param totalItems Total number of items
 | 
			
		||||
 * @param first URL of first page (optional)
 | 
			
		||||
 * @param last URL of last page (optional)
 | 
			
		||||
 * @param orderedItems attached objects (optional)
 | 
			
		||||
 */
 | 
			
		||||
export default function(id: string, totalItems: any, first: string, last: string) {
 | 
			
		||||
export default function(id: string, totalItems: any, first?: string, last?: string, orderedItems?: object) {
 | 
			
		||||
	const page: any = {
 | 
			
		||||
		id,
 | 
			
		||||
		type: 'OrderedCollection',
 | 
			
		||||
@@ -14,6 +15,7 @@ export default function(id: string, totalItems: any, first: string, last: string
 | 
			
		||||
 | 
			
		||||
	if (first) page.first = first;
 | 
			
		||||
	if (last) page.last = last;
 | 
			
		||||
	if (orderedItems) page.orderedItems = orderedItems;
 | 
			
		||||
 | 
			
		||||
	return page;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -21,6 +21,7 @@ export default async (user: ILocalUser) => {
 | 
			
		||||
		outbox: `${id}/outbox`,
 | 
			
		||||
		followers: `${id}/followers`,
 | 
			
		||||
		following: `${id}/following`,
 | 
			
		||||
		featured: `${id}/collections/featured`,
 | 
			
		||||
		sharedInbox: `${config.url}/inbox`,
 | 
			
		||||
		url: `${config.url}/@${user.username}`,
 | 
			
		||||
		preferredUsername: user.username,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										9
									
								
								src/remote/activitypub/renderer/remove.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								src/remote/activitypub/renderer/remove.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
			
		||||
import config from '../../../config';
 | 
			
		||||
import { ILocalUser } from '../../../models/user';
 | 
			
		||||
 | 
			
		||||
export default (user: ILocalUser, target: any, object: any) => ({
 | 
			
		||||
	type: 'Remove',
 | 
			
		||||
	actor: `${config.url}/users/${user._id}`,
 | 
			
		||||
	target,
 | 
			
		||||
	object
 | 
			
		||||
});
 | 
			
		||||
@@ -53,6 +53,7 @@ export interface IPerson extends IObject {
 | 
			
		||||
	publicKey: any;
 | 
			
		||||
	followers: any;
 | 
			
		||||
	following: any;
 | 
			
		||||
	featured?: any;
 | 
			
		||||
	outbox: any;
 | 
			
		||||
	endpoints: string[];
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,7 @@ import renderPerson from '../remote/activitypub/renderer/person';
 | 
			
		||||
import Outbox, { packActivity } from './activitypub/outbox';
 | 
			
		||||
import Followers from './activitypub/followers';
 | 
			
		||||
import Following from './activitypub/following';
 | 
			
		||||
import Featured from './activitypub/featured';
 | 
			
		||||
 | 
			
		||||
// Init router
 | 
			
		||||
const router = new Router();
 | 
			
		||||
@@ -74,6 +75,7 @@ router.get('/notes/:note', async (ctx, next) => {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ctx.body = pack(await renderNote(note, false));
 | 
			
		||||
	ctx.set('Cache-Control', 'public, max-age=180');
 | 
			
		||||
	setResponseType(ctx);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@@ -90,6 +92,7 @@ router.get('/notes/:note/activity', async ctx => {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ctx.body = pack(await packActivity(note));
 | 
			
		||||
	ctx.set('Cache-Control', 'public, max-age=180');
 | 
			
		||||
	setResponseType(ctx);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@@ -102,6 +105,9 @@ router.get('/users/:user/followers', Followers);
 | 
			
		||||
// following
 | 
			
		||||
router.get('/users/:user/following', Following);
 | 
			
		||||
 | 
			
		||||
// featured
 | 
			
		||||
router.get('/users/:user/collections/featured', Featured);
 | 
			
		||||
 | 
			
		||||
// publickey
 | 
			
		||||
router.get('/users/:user/publickey', async ctx => {
 | 
			
		||||
	const userId = new mongo.ObjectID(ctx.params.user);
 | 
			
		||||
@@ -118,6 +124,7 @@ router.get('/users/:user/publickey', async ctx => {
 | 
			
		||||
 | 
			
		||||
	if (isLocalUser(user)) {
 | 
			
		||||
		ctx.body = pack(renderKey(user));
 | 
			
		||||
		ctx.set('Cache-Control', 'public, max-age=180');
 | 
			
		||||
		setResponseType(ctx);
 | 
			
		||||
	} else {
 | 
			
		||||
		ctx.status = 400;
 | 
			
		||||
@@ -132,6 +139,7 @@ async function userInfo(ctx: Router.IRouterContext, user: IUser) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ctx.body = pack(await renderPerson(user as ILocalUser));
 | 
			
		||||
	ctx.set('Cache-Control', 'public, max-age=180');
 | 
			
		||||
	setResponseType(ctx);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										39
									
								
								src/server/activitypub/featured.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								src/server/activitypub/featured.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
import * as mongo from 'mongodb';
 | 
			
		||||
import * as Router from 'koa-router';
 | 
			
		||||
import config from '../../config';
 | 
			
		||||
import User from '../../models/user';
 | 
			
		||||
import pack from '../../remote/activitypub/renderer';
 | 
			
		||||
import renderOrderedCollection from '../../remote/activitypub/renderer/ordered-collection';
 | 
			
		||||
import { setResponseType } from '../activitypub';
 | 
			
		||||
import Note from '../../models/note';
 | 
			
		||||
import renderNote from '../../remote/activitypub/renderer/note';
 | 
			
		||||
 | 
			
		||||
export default async (ctx: Router.IRouterContext) => {
 | 
			
		||||
	const userId = new mongo.ObjectID(ctx.params.user);
 | 
			
		||||
 | 
			
		||||
	// Verify user
 | 
			
		||||
	const user = await User.findOne({
 | 
			
		||||
		_id: userId,
 | 
			
		||||
		host: null
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	if (user === null) {
 | 
			
		||||
		ctx.status = 404;
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	const pinnedNoteIds = user.pinnedNoteIds || [];
 | 
			
		||||
 | 
			
		||||
	const pinnedNotes = await Promise.all(pinnedNoteIds.map(id => Note.findOne({ _id: id })));
 | 
			
		||||
 | 
			
		||||
	const renderedNotes = await Promise.all(pinnedNotes.map(note => renderNote(note)));
 | 
			
		||||
 | 
			
		||||
	const rendered = renderOrderedCollection(
 | 
			
		||||
		`${config.url}/users/${userId}/collections/featured`,
 | 
			
		||||
		renderedNotes.length, null, null, renderedNotes
 | 
			
		||||
	);
 | 
			
		||||
 | 
			
		||||
	ctx.body = pack(rendered);
 | 
			
		||||
	ctx.set('Cache-Control', 'private, max-age=0, must-revalidate');
 | 
			
		||||
	setResponseType(ctx);
 | 
			
		||||
};
 | 
			
		||||
@@ -78,6 +78,7 @@ export default async (ctx: Router.IRouterContext) => {
 | 
			
		||||
		// index page
 | 
			
		||||
		const rendered = renderOrderedCollection(partOf, user.followersCount, `${partOf}?page=true`, null);
 | 
			
		||||
		ctx.body = pack(rendered);
 | 
			
		||||
		ctx.set('Cache-Control', 'private, max-age=0, must-revalidate');
 | 
			
		||||
		setResponseType(ctx);
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -78,6 +78,7 @@ export default async (ctx: Router.IRouterContext) => {
 | 
			
		||||
		// index page
 | 
			
		||||
		const rendered = renderOrderedCollection(partOf, user.followingCount, `${partOf}?page=true`, null);
 | 
			
		||||
		ctx.body = pack(rendered);
 | 
			
		||||
		ctx.set('Cache-Control', 'private, max-age=0, must-revalidate');
 | 
			
		||||
		setResponseType(ctx);
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -88,6 +88,7 @@ export default async (ctx: Router.IRouterContext) => {
 | 
			
		||||
		);
 | 
			
		||||
 | 
			
		||||
		ctx.body = pack(rendered);
 | 
			
		||||
		ctx.set('Cache-Control', 'private, max-age=0, must-revalidate');
 | 
			
		||||
		setResponseType(ctx);
 | 
			
		||||
	} else {
 | 
			
		||||
		// index page
 | 
			
		||||
@@ -96,6 +97,7 @@ export default async (ctx: Router.IRouterContext) => {
 | 
			
		||||
			`${partOf}?page=true&since_id=000000000000000000000000`
 | 
			
		||||
		);
 | 
			
		||||
		ctx.body = pack(rendered);
 | 
			
		||||
		ctx.set('Cache-Control', 'private, max-age=0, must-revalidate');
 | 
			
		||||
		setResponseType(ctx);
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,9 @@
 | 
			
		||||
import * as mongo from 'mongodb';
 | 
			
		||||
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
 | 
			
		||||
import User, { ILocalUser } from '../../../../models/user';
 | 
			
		||||
import Note from '../../../../models/note';
 | 
			
		||||
import { pack } from '../../../../models/user';
 | 
			
		||||
import { deliverPinnedChange } from '../../../../services/i/pin';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Pin note
 | 
			
		||||
@@ -21,9 +23,25 @@ export default async (params: any, user: ILocalUser) => new Promise(async (res,
 | 
			
		||||
		return rej('note not found');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	let addedId: mongo.ObjectID;
 | 
			
		||||
	let removedId: mongo.ObjectID;
 | 
			
		||||
 | 
			
		||||
	const pinnedNoteIds = user.pinnedNoteIds || [];
 | 
			
		||||
 | 
			
		||||
	if (pinnedNoteIds.some(id => id.equals(note._id))) {
 | 
			
		||||
		return rej('already exists');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	pinnedNoteIds.unshift(note._id);
 | 
			
		||||
	addedId = note._id;
 | 
			
		||||
 | 
			
		||||
	if (pinnedNoteIds.length > 5) {
 | 
			
		||||
		removedId = pinnedNoteIds.pop();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	await User.update(user._id, {
 | 
			
		||||
		$set: {
 | 
			
		||||
			pinnedNoteId: note._id
 | 
			
		||||
			pinnedNoteIds: pinnedNoteIds
 | 
			
		||||
		}
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
@@ -32,6 +50,9 @@ export default async (params: any, user: ILocalUser) => new Promise(async (res,
 | 
			
		||||
		detail: true
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	// Send Add/Remove to followers
 | 
			
		||||
	deliverPinnedChange(user._id, removedId, addedId);
 | 
			
		||||
 | 
			
		||||
	// Send response
 | 
			
		||||
	res(iObj);
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										61
									
								
								src/services/i/pin.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								src/services/i/pin.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,61 @@
 | 
			
		||||
import config from '../../config';
 | 
			
		||||
import * as mongo from 'mongodb';
 | 
			
		||||
import User, { isLocalUser, isRemoteUser, ILocalUser } from '../../models/user';
 | 
			
		||||
import Following from '../../models/following';
 | 
			
		||||
import renderAdd from '../../remote/activitypub/renderer/add';
 | 
			
		||||
import renderRemove from '../../remote/activitypub/renderer/remove';
 | 
			
		||||
import packAp from '../../remote/activitypub/renderer';
 | 
			
		||||
import { deliver } from '../../queue';
 | 
			
		||||
 | 
			
		||||
export async function deliverPinnedChange(userId: mongo.ObjectID, oldId?: mongo.ObjectID, newId?: mongo.ObjectID) {
 | 
			
		||||
	const user = await User.findOne({
 | 
			
		||||
		_id: userId
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	if (!isLocalUser(user)) return;
 | 
			
		||||
 | 
			
		||||
	const queue = await CreateRemoteInboxes(user);
 | 
			
		||||
 | 
			
		||||
	if (queue.length < 1) return;
 | 
			
		||||
 | 
			
		||||
	const target = `${config.url}/users/${user._id}/collections/featured`;
 | 
			
		||||
 | 
			
		||||
	if (oldId) {
 | 
			
		||||
		const oldItem = `${config.url}/notes/${oldId}`;
 | 
			
		||||
		const content = packAp(renderRemove(user, target, oldItem));
 | 
			
		||||
		queue.forEach(inbox => {
 | 
			
		||||
			deliver(user, content, inbox);
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (newId) {
 | 
			
		||||
		const newItem = `${config.url}/notes/${newId}`;
 | 
			
		||||
		const content = packAp(renderAdd(user, target, newItem));
 | 
			
		||||
		queue.forEach(inbox => {
 | 
			
		||||
			deliver(user, content, inbox);
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ローカルユーザーのリモートフォロワーのinboxリストを作成する
 | 
			
		||||
 * @param user ローカルユーザー
 | 
			
		||||
 */
 | 
			
		||||
async function CreateRemoteInboxes(user: ILocalUser): Promise<string[]> {
 | 
			
		||||
	const followers = await Following.find({
 | 
			
		||||
		followeeId: user._id
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	const queue: string[] = [];
 | 
			
		||||
 | 
			
		||||
	followers.map(following => {
 | 
			
		||||
		const follower = following._follower;
 | 
			
		||||
 | 
			
		||||
		if (isRemoteUser(follower)) {
 | 
			
		||||
			const inbox = follower.sharedInbox || follower.inbox;
 | 
			
		||||
			if (!queue.includes(inbox)) queue.push(inbox);
 | 
			
		||||
		}
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	return queue;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user