Compare commits

..

18 Commits

Author SHA1 Message Date
163cf49f16 10.60.0 2018-12-02 15:39:46 +09:00
c38a32dee9 🎨 2018-12-02 15:31:24 +09:00
4f5abed70d Fix 2018-12-02 15:30:48 +09:00
c9ac9923df Refactor: rename alert to dialog 2018-12-02 15:28:52 +09:00
bb14895fd8 [Client] Resolve #2225 2018-12-02 15:26:56 +09:00
6f92d601ec 🎨 2018-12-02 14:26:30 +09:00
345143b0c1 Suggest in CW (#3467) 2018-12-02 07:33:03 +09:00
dc80d5d376 10.59.4 2018-12-02 07:08:26 +09:00
d3544f9637 Update README.md [AUTOGEN] (#3466) 2018-12-02 07:05:22 +09:00
864b6ad1bd Resolve #1826 2018-12-02 07:02:08 +09:00
c58027e521 [MFM] Better hashtag detection 2018-12-02 06:53:57 +09:00
10fb399588 Merge branch 'develop' of https://github.com/syuilo/misskey into develop 2018-12-02 06:44:25 +09:00
10f466c895 Improve performance 2018-12-02 06:44:18 +09:00
32068b4bcc Update README.md [AUTOGEN] (#3465) 2018-12-02 06:16:24 +09:00
8bc5febe66 [Client] Add missing icon (#3464) 2018-12-02 03:43:05 +09:00
20335e23f9 Resolve external recommended users (#3462)
* Resolve external recommended users

* Skip unresolvable users

* Fix indent

* Use original for unresolvable users
2018-12-02 03:42:45 +09:00
fe707f88a4 [MFM] Better MFM parsing 2018-12-01 10:40:09 +09:00
9b23ebd4a3 🎨 2018-12-01 09:45:48 +09:00
51 changed files with 231 additions and 150 deletions

View File

@ -116,7 +116,7 @@ Please see [Contribution guide](./CONTRIBUTING.md).
<td><a href="https://www.patreon.com/user?u=12531784">Takashi Shibuya</a></td>
</tr></table>
**Last updated:** Tue, 27 Nov 2018 06:24:05 UTC
**Last updated:** Sat, 01 Dec 2018 22:05:05 UTC
<!-- PATREON_END -->
:four_leaf_clover: Copyright

View File

@ -1628,6 +1628,9 @@ mobile/views/pages/user.vue:
block: "ブロック"
unblock: "ブロック解除"
years-old: "{age}歳"
push-to-list: "リストに追加"
select-list: "リストを選択してください"
list-pushed: "{user}を{list}に追加しました"
mobile/views/pages/user/home.vue:
recent-notes: "最近の投稿"

View File

@ -1,8 +1,8 @@
{
"name": "misskey",
"author": "syuilo <i@syuilo.com>",
"version": "10.59.3",
"clientVersion": "2.0.12313",
"version": "10.60.0",
"clientVersion": "2.0.12331",
"codename": "nighthike",
"main": "./built/index.js",
"private": true,

View File

@ -48,7 +48,7 @@ export default Vue.extend({
},
remove(i) {
this.$root.alert({
this.$root.dialog({
type: 'warning',
text: this.$t('_remove.are-you-sure').replace('$1', this.announcements.find((_, j) => j == i).title),
showCancelButton: true
@ -56,7 +56,7 @@ export default Vue.extend({
if (!res) return;
this.announcements = this.announcements.filter((_, j) => j !== i);
this.save(true);
this.$root.alert({
this.$root.dialog({
type: 'success',
text: this.$t('_remove.removed')
});
@ -68,13 +68,13 @@ export default Vue.extend({
broadcasts: this.announcements
}).then(() => {
if (!silent) {
this.$root.alert({
this.$root.dialog({
type: 'success',
text: this.$t('saved')
});
}
}).catch(e => {
this.$root.alert({
this.$root.dialog({
type: 'error',
text: e
});

View File

@ -75,13 +75,13 @@ export default Vue.extend({
url: this.url,
aliases: this.aliases.split(' ').filter(x => x.length > 0)
}).then(() => {
this.$root.alert({
this.$root.dialog({
type: 'success',
text: this.$t('add-emoji.added')
});
this.fetchEmojis();
}).catch(e => {
this.$root.alert({
this.$root.dialog({
type: 'error',
text: e
});
@ -103,12 +103,12 @@ export default Vue.extend({
url: emoji.url,
aliases: emoji.aliases.split(' ').filter(x => x.length > 0)
}).then(() => {
this.$root.alert({
this.$root.dialog({
type: 'success',
text: this.$t('updated')
});
}).catch(e => {
this.$root.alert({
this.$root.dialog({
type: 'error',
text: e
});
@ -116,7 +116,7 @@ export default Vue.extend({
},
removeEmoji(emoji) {
this.$root.alert({
this.$root.dialog({
type: 'warning',
text: this.$t('remove-emoji.are-you-sure').replace('$1', emoji.name),
showCancelButton: true
@ -126,13 +126,13 @@ export default Vue.extend({
this.$root.api('admin/emoji/remove', {
id: emoji.id
}).then(() => {
this.$root.alert({
this.$root.dialog({
type: 'success',
text: this.$t('remove-emoji.removed')
});
this.fetchEmojis();
}).catch(e => {
this.$root.alert({
this.$root.dialog({
type: 'error',
text: e
});

View File

@ -212,7 +212,7 @@ export default Vue.extend({
this.$root.api('admin/invite').then(x => {
this.inviteCode = x.code;
}).catch(e => {
this.$root.alert({
this.$root.dialog({
type: 'error',
text: e
});
@ -258,12 +258,12 @@ export default Vue.extend({
smtpUser: this.smtpUser,
smtpPass: this.smtpPass
}).then(() => {
this.$root.alert({
this.$root.dialog({
type: 'success',
text: this.$t('saved')
});
}).catch(e => {
this.$root.alert({
this.$root.dialog({
type: 'error',
text: e
});

View File

@ -34,14 +34,14 @@ export default Vue.extend({
const process = async () => {
const user = await this.$root.api('users/show', parseAcct(this.username));
await this.$root.api('admin/moderators/add', { userId: user.id });
this.$root.alert({
this.$root.dialog({
type: 'success',
text: this.$t('add-moderator.added')
});
};
await process().catch(e => {
this.$root.alert({
this.$root.dialog({
type: 'error',
text: e.toString()
});

View File

@ -115,12 +115,12 @@ export default Vue.extend({
return await this.$root.api('users/show', this.target.startsWith('@') ? parseAcct(this.target) : { userId: this.target });
} catch (e) {
if (e == 'user not found') {
this.$root.alert({
this.$root.dialog({
type: 'error',
text: this.$t('user-not-found')
});
} else {
this.$root.alert({
this.$root.dialog({
type: 'error',
text: e.toString()
});
@ -138,7 +138,7 @@ export default Vue.extend({
async resetPassword() {
const user = await this.fetchUser();
this.$root.api('admin/reset-password', { userId: user.id }).then(res => {
this.$root.alert({
this.$root.dialog({
type: 'success',
text: this.$t('password-updated', { password: res.password })
});
@ -151,14 +151,14 @@ export default Vue.extend({
const process = async () => {
const user = await this.fetchUser();
await this.$root.api('admin/verify-user', { userId: user.id });
this.$root.alert({
this.$root.dialog({
type: 'success',
text: this.$t('verified')
});
};
await process().catch(e => {
this.$root.alert({
this.$root.dialog({
type: 'error',
text: e.toString()
});
@ -173,14 +173,14 @@ export default Vue.extend({
const process = async () => {
const user = await this.fetchUser();
await this.$root.api('admin/unverify-user', { userId: user.id });
this.$root.alert({
this.$root.dialog({
type: 'success',
text: this.$t('unverified')
});
};
await process().catch(e => {
this.$root.alert({
this.$root.dialog({
type: 'error',
text: e.toString()
});
@ -195,14 +195,14 @@ export default Vue.extend({
const process = async () => {
const user = await this.fetchUser();
await this.$root.api('admin/suspend-user', { userId: user.id });
this.$root.alert({
this.$root.dialog({
type: 'success',
text: this.$t('suspended')
});
};
await process().catch(e => {
this.$root.alert({
this.$root.dialog({
type: 'error',
text: e.toString()
});
@ -217,14 +217,14 @@ export default Vue.extend({
const process = async () => {
const user = await this.fetchUser();
await this.$root.api('admin/unsuspend-user', { userId: user.id });
this.$root.alert({
this.$root.dialog({
type: 'success',
text: this.$t('unsuspended')
});
};
await process().catch(e => {
this.$root.alert({
this.$root.dialog({
type: 'error',
text: e.toString()
});

View File

@ -22,7 +22,7 @@ export default async function($root: any, force = false, silent = false) {
}
/*if (!silent) {
$root.alert({
$root.dialog({
title: $root.$t('@.update-available-title'),
text: $root.$t('@.update-available', { newer, current })
});

View File

@ -4,7 +4,7 @@ export default ($root: any) => {
require('fuckadblock');
function adBlockDetected() {
$root.alert({
$root.dialog({
title: $root.$t('@.adblock.detected'),
text: $root.$t('@.adblock.warning')
});

View File

@ -142,7 +142,7 @@ export default (opts: Opts = {}) => ({
this.$root.api('notes/favorites/create', {
noteId: this.appearNote.id
}).then(() => {
this.$root.alert({
this.$root.dialog({
type: 'success',
splash: true
});

View File

@ -187,7 +187,8 @@ export default Vue.extend({
} else {
this.$root.api('users/search', {
query: this.q,
limit: 10
limit: 10,
detail: false
}).then(users => {
this.users = users;
this.fetching = false;

View File

@ -2,9 +2,12 @@
<div class="felqjxyj" :class="{ splash }">
<div class="bg" ref="bg" @click="onBgClick"></div>
<div class="main" ref="main">
<div class="icon" :class="type"><fa :icon="icon"/></div>
<div class="icon" v-if="type" :class="type"><fa :icon="icon"/></div>
<header v-if="title" v-html="title"></header>
<div class="body" v-if="text" v-html="text"></div>
<ui-select v-if="select" v-model="selectedValue">
<option v-for="item in select.items" :value="item.value">{{ item.text }}</option>
</ui-select>
<ui-horizon-group no-grow class="buttons fit-bottom" v-if="!splash">
<ui-button @click="ok" primary autofocus>OK</ui-button>
<ui-button @click="cancel" v-if="showCancelButton">Cancel</ui-button>
@ -33,6 +36,9 @@ export default Vue.extend({
type: String,
required: false
},
select: {
required: false
},
showCancelButton: {
type: Boolean,
default: false
@ -43,6 +49,12 @@ export default Vue.extend({
}
},
data() {
return {
selectedValue: null
};
},
computed: {
icon(): any {
switch (this.type) {
@ -83,7 +95,8 @@ export default Vue.extend({
methods: {
ok() {
this.$emit('ok');
const result = this.select ? this.selectedValue : true;
this.$emit('ok', result);
this.close();
},
@ -180,8 +193,11 @@ export default Vue.extend({
display block
margin 0 auto
& + header
margin-top 16px
> header
margin 16px 0 8px 0
margin 0 0 8px 0
font-weight bold
font-size 20px

View File

@ -1,5 +1,5 @@
<template>
<div class="onchrpzrvnoruiaenfcqvccjfuupzzwv">
<div class="onchrpzrvnoruiaenfcqvccjfuupzzwv" :class="{ big: $root.isMobile }">
<div class="backdrop" ref="backdrop" @click="close"></div>
<div class="popover" :class="{ hukidasi }" ref="popover">
<template v-for="item, i in items">
@ -125,6 +125,11 @@ export default Vue.extend({
position initial
&.big
> .popover
> button
font-size 15px
> .backdrop
position fixed
top 0

View File

@ -116,7 +116,8 @@ export default Vue.extend({
this.$root.api('users/search', {
query: this.q,
localOnly: true,
limit: 10
limit: 10,
detail: false
}).then(users => {
this.result = users.filter(user => user.id != this.$store.state.i.id);
});

View File

@ -78,7 +78,7 @@ export default Vue.extend({
this.$root.api('i/pin', {
noteId: this.note.id
}).then(() => {
this.$root.alert({
this.$root.dialog({
type: 'success',
splash: true
});
@ -95,7 +95,7 @@ export default Vue.extend({
},
del() {
this.$root.alert({
this.$root.dialog({
type: 'warning',
text: this.$t('delete-confirm'),
showCancelButton: true
@ -114,7 +114,7 @@ export default Vue.extend({
this.$root.api('notes/favorites/create', {
noteId: this.note.id
}).then(() => {
this.$root.alert({
this.$root.dialog({
type: 'success',
splash: true
});
@ -126,7 +126,7 @@ export default Vue.extend({
this.$root.api('notes/favorites/delete', {
noteId: this.note.id
}).then(() => {
this.$root.alert({
this.$root.dialog({
type: 'success',
splash: true
});

View File

@ -25,7 +25,7 @@ export default Vue.extend({
type: 'password'
}).then(newPassword2 => {
if (newPassword !== newPassword2) {
this.$root.alert({
this.$root.dialog({
title: null,
text: this.$t('not-match')
});

View File

@ -213,7 +213,7 @@ export default Vue.extend({
this.$store.state.i.bannerUrl = i.bannerUrl;
if (notify) {
this.$root.alert({
this.$root.dialog({
type: 'success',
text: this.$t('saved')
});

View File

@ -223,7 +223,7 @@ export default Vue.extend({
try {
theme = JSON5.parse(code);
} catch (e) {
this.$root.alert({
this.$root.dialog({
type: 'error',
text: this.$t('invalid-theme')
});
@ -236,7 +236,7 @@ export default Vue.extend({
}
if (theme.id == null) {
this.$root.alert({
this.$root.dialog({
type: 'error',
text: this.$t('invalid-theme')
});
@ -244,7 +244,7 @@ export default Vue.extend({
}
if (this.$store.state.device.themes.some(t => t.id == theme.id)) {
this.$root.alert({
this.$root.dialog({
type: 'info',
text: this.$t('already-installed')
});
@ -256,7 +256,7 @@ export default Vue.extend({
key: 'themes', value: themes
});
this.$root.alert({
this.$root.dialog({
type: 'success',
text: this.$t('installed').replace('{}', theme.name)
});
@ -269,7 +269,7 @@ export default Vue.extend({
key: 'themes', value: themes
});
this.$root.alert({
this.$root.dialog({
type: 'info',
text: this.$t('uninstalled').replace('{}', theme.name)
});
@ -306,7 +306,7 @@ export default Vue.extend({
const theme = this.myTheme;
if (theme.name == null || theme.name.trim() == '') {
this.$root.alert({
this.$root.dialog({
type: 'warning',
text: this.$t('theme-name-required')
});
@ -320,7 +320,7 @@ export default Vue.extend({
key: 'themes', value: themes
});
this.$root.alert({
this.$root.dialog({
type: 'success',
text: this.$t('saved')
});

View File

@ -8,7 +8,7 @@ export default ($root: any) => {
const regex = RegExp('\.(jpg|jpeg|png|gif|webp|bmp|tiff)$');
if (!regex.test(file.name) ) {
$root.alert({
$root.dialog({
title: '%fa:info-circle% %i18n:desktop.invalid-filetype%',
text: null
});
@ -87,7 +87,7 @@ export default ($root: any) => {
value: i.avatarUrl
});
$root.alert({
$root.dialog({
title: '%fa:info-circle% %i18n:desktop.avatar-updated%',
text: null
});

View File

@ -87,7 +87,7 @@ export default ($root: any) => {
value: i.bannerUrl
});
$root.alert({
$root.dialog({
title: '%fa:info-circle% %i18n:desktop.banner-updated%',
text: null
});

View File

@ -170,7 +170,7 @@ export default Vue.extend({
copyUrl() {
copyToClipboard(this.file.url);
this.$root.alert({
this.$root.dialog({
title: this.$t('contextmenu.copied'),
text: this.$t('contextmenu.copied-url-to-clipboard')
});

View File

@ -155,7 +155,7 @@ export default Vue.extend({
}).catch(err => {
switch (err) {
case 'detected-circular-definition':
this.$root.alert({
this.$root.dialog({
title: this.$t('unable-to-process'),
text: this.$t('circular-reference-detected')
});

View File

@ -313,7 +313,7 @@ export default Vue.extend({
}).catch(err => {
switch (err) {
case 'detected-circular-definition':
this.$root.alert({
this.$root.dialog({
title: this.$t('unable-to-process'),
text: this.$t('circular-reference-detected')
});
@ -340,7 +340,7 @@ export default Vue.extend({
folderId: this.folder ? this.folder.id : undefined
});
this.$root.alert({
this.$root.dialog({
title: this.$t('url-upload-requested'),
text: this.$t('may-take-time')
});

View File

@ -186,7 +186,7 @@ export default Vue.extend({
methods: {
hint() {
this.$root.alert({
this.$root.dialog({
title: this.$t('@.customization-tips.title'),
text: this.$t('@.customization-tips.paragraph')
});

View File

@ -39,7 +39,7 @@
</header>
<div class="body">
<p v-if="appearNote.cw != null" class="cw">
<span class="text" v-if="appearNote.cw != ''">{{ appearNote.cw }}</span>
<misskey-flavored-markdown v-if="appearNote.cw != ''" class="text" :text="appearNote.cw" :author="appearNote.user" :i="$store.state.i" :custom-emojis="appearNote.emojis" />
<mk-cw-button v-model="showContent"/>
</p>
<div class="content" v-show="appearNote.cw == null || showContent">

View File

@ -5,7 +5,7 @@
<mk-note-header class="header" :note="note" :mini="true"/>
<div class="body">
<p v-if="note.cw != null" class="cw">
<span class="text" v-if="note.cw != ''">{{ note.cw }}</span>
<misskey-flavored-markdown v-if="note.cw != ''" class="text" :text="note.cw" :author="note.user" :i="$store.state.i" :custom-emojis="note.emojis" />
<mk-cw-button v-model="showContent"/>
</p>
<div class="content" v-show="note.cw == null || showContent">

View File

@ -5,7 +5,7 @@
<mk-note-header class="header" :note="note"/>
<div class="body">
<p v-if="note.cw != null" class="cw">
<span class="text" v-if="note.cw != ''">{{ note.cw }}</span>
<misskey-flavored-markdown v-if="note.cw != ''" class="text" :text="note.cw" :author="note.user" :i="$store.state.i" :custom-emojis="note.emojis" />
<mk-cw-button v-model="showContent"/>
</p>
<div class="content" v-show="note.cw == null || showContent">

View File

@ -20,7 +20,7 @@
<mk-note-header class="header" :note="appearNote" :mini="mini"/>
<div class="body" v-if="appearNote.deletedAt == null">
<p v-if="appearNote.cw != null" class="cw">
<span class="text" v-if="appearNote.cw != ''">{{ appearNote.cw }}</span>
<misskey-flavored-markdown v-if="appearNote.cw != ''" class="text" :text="appearNote.cw" :author="appearNote.user" :i="$store.state.i" :custom-emojis="appearNote.emojis" />
<mk-cw-button v-model="showContent"/>
</p>
<div class="content" v-show="appearNote.cw == null || showContent">

View File

@ -265,6 +265,7 @@ export default Vue.extend({
display inline-block
overflow hidden
max-height 48px
word-break break-all
.note-ref
color var(--noteText)

View File

@ -15,7 +15,7 @@
<a v-for="tag in recentHashtags.slice(0, 5)" @click="addTag(tag)" :title="$t('click-to-tagging')">#{{ tag }}</a>
</div>
<div class="local-only" v-if="this.localOnly == true">{{ $t('local-only-message') }}</div>
<input v-show="useCw" v-model="cw" :placeholder="$t('annotations')">
<input v-show="useCw" ref="cw" v-model="cw" :placeholder="$t('annotations')" v-autocomplete="'cw'">
<div class="textarea">
<textarea :class="{ with: (files.length != 0 || poll) }"
ref="text" v-model="text" :disabled="posting"

View File

@ -596,12 +596,12 @@ export default Vue.extend({
this.checkingForUpdate = false;
this.latestVersion = newer;
if (newer == null) {
this.$root.alert({
this.$root.dialog({
title: this.$t('no-updates'),
text: this.$t('no-updates-desc')
});
} else {
this.$root.alert({
this.$root.dialog({
title: this.$t('update-available'),
text: this.$t('update-available-desc')
});
@ -610,7 +610,7 @@ export default Vue.extend({
},
clean() {
localStorage.clear();
this.$root.alert({
this.$root.dialog({
title: this.$t('cache-cleared'),
text: this.$t('cache-cleared-desc')
});

View File

@ -156,7 +156,7 @@ export default Vue.extend({
> .follow-button
position absolute
top 92px
top 8px
right 8px
</style>

View File

@ -307,7 +307,7 @@ export default Vue.extend({
listId: list.id,
userId: this.user.id
});
this.$root.alert({
this.$root.dialog({
type: 'success',
splash: true
});

View File

@ -73,7 +73,7 @@ export default Vue.extend({
},
block() {
this.$root.alert({
this.$root.dialog({
type: 'warning',
text: this.$t('block-confirm'),
showCancelButton: true
@ -108,9 +108,13 @@ export default Vue.extend({
listId: list.id,
userId: this.user.id
});
this.$root.alert({
this.$root.dialog({
type: 'success',
title: 'Done!',
text: this.$t('list-pushed').replace('{user}', this.user.name).replace('{list}', list.title)
text: this.$t('list-pushed', {
user: this.user.name,
list: list.title
})
});
});
}

View File

@ -15,7 +15,7 @@ import checkForUpdate from './common/scripts/check-for-update';
import MiOS from './mios';
import { clientVersion as version, codename, lang } from './config';
import { builtinThemes, lightTheme, applyTheme } from './theme';
import Alert from './common/views/components/alert.vue';
import Dialog from './common/views/components/dialog.vue';
if (localStorage.getItem('theme') == null) {
applyTheme(lightTheme);
@ -144,6 +144,8 @@ import {
faHdd as farHdd,
faMoon as farMoon,
faPlayCircle as farPlayCircle,
faLightbulb as farLightbulb,
faStickyNote as farStickyNote,
} from '@fortawesome/free-regular-svg-icons';
import {
@ -249,7 +251,7 @@ library.add(
faSync,
faArrowLeft,
faMapMarker,
faRobot,
faRobot,
farBell,
farEnvelope,
@ -270,6 +272,8 @@ library.add(
farHdd,
farMoon,
farPlayCircle,
farLightbulb,
farStickyNote,
fabTwitter,
fabGithub,
@ -453,10 +457,10 @@ export default (callback: (launch: (router: VueRouter) => [Vue, MiOS]) => void,
document.body.appendChild(x.$el);
return x;
},
alert(opts) {
dialog(opts) {
return new Promise((res) => {
const vm = this.new(Alert, opts);
vm.$once('ok', () => res(true));
const vm = this.new(Dialog, opts);
vm.$once('ok', result => res(result));
vm.$once('cancel', () => res(false));
});
}

View File

@ -41,6 +41,12 @@ import FolderChooser from './views/components/drive-folder-chooser.vue';
*/
init((launch) => {
Vue.mixin({
data() {
return {
isMobile: true
};
},
methods: {
$post(opts) {
const o = opts || {};

View File

@ -26,7 +26,7 @@
</header>
<div class="body">
<p v-if="appearNote.cw != null" class="cw">
<span class="text" v-if="appearNote.cw != ''">{{ appearNote.cw }}</span>
<misskey-flavored-markdown v-if="appearNote.cw != ''" class="text" :text="appearNote.cw" :author="appearNote.user" :i="$store.state.i" :custom-emojis="appearNote.emojis" />
<mk-cw-button v-model="showContent"/>
</p>
<div class="content" v-show="appearNote.cw == null || showContent">

View File

@ -5,7 +5,7 @@
<mk-note-header class="header" :note="note" :mini="true"/>
<div class="body">
<p v-if="note.cw != null" class="cw">
<span class="text" v-if="note.cw != ''">{{ note.cw }}</span>
<misskey-flavored-markdown v-if="note.cw != ''" class="text" :text="note.cw" :author="note.user" :i="$store.state.i" :custom-emojis="note.emojis" />
<mk-cw-button v-model="showContent"/>
</p>
<div class="content" v-show="note.cw == null || showContent">

View File

@ -16,7 +16,7 @@
<mk-note-header class="header" :note="appearNote" :mini="true"/>
<div class="body" v-if="appearNote.deletedAt == null">
<p v-if="appearNote.cw != null" class="cw">
<span class="text" v-if="appearNote.cw != ''">{{ appearNote.cw }}</span>
<misskey-flavored-markdown v-if="appearNote.cw != ''" class="text" :text="appearNote.cw" :author="appearNote.user" :i="$store.state.i" :custom-emojis="appearNote.emojis" />
<mk-cw-button v-model="showContent"/>
</p>
<div class="content" v-show="appearNote.cw == null || showContent">

View File

@ -16,7 +16,7 @@
<span v-for="u in visibleUsers">{{ u | userName }}<a @click="removeVisibleUser(u)">[x]</a></span>
<a @click="addVisibleUser">+{{ $t('add-visible-user') }}</a>
</div>
<input v-show="useCw" v-model="cw" :placeholder="$t('annotations')">
<input v-show="useCw" ref="cw" v-model="cw" :placeholder="$t('annotations')" v-autocomplete="'cw'">
<textarea v-model="text" ref="text" :disabled="posting" :placeholder="placeholder" v-autocomplete="'text'"></textarea>
<div class="attaches" v-show="files.length != 0">
<x-draggable class="files" :list="files" :options="{ animation: 150 }">

View File

@ -23,7 +23,7 @@ export default Vue.extend({
},
methods: {
fn() {
this.$root.alert({
this.$root.dialog({
type: 'warning',
text: this.$t('read-all'),
showCancelButton: true

View File

@ -402,12 +402,12 @@ export default Vue.extend({
this.checkingForUpdate = false;
this.latestVersion = newer;
if (newer == null) {
this.$root.alert({
this.$root.dialog({
title: this.$t('no-updates'),
text: this.$t('no-updates-desc')
});
} else {
this.$root.alert({
this.$root.dialog({
title: this.$t('update-available'),
text: this.$t('update-available-desc')
});

View File

@ -116,6 +116,34 @@ export default Vue.extend({
menu() {
let menu = [{
icon: ['fas', 'list'],
text: this.$t('push-to-list'),
action: async () => {
const lists = await this.$root.api('users/lists/list');
const listId = await this.$root.dialog({
type: null,
title: this.$t('select-list'),
select: {
items: lists.map(list => ({
value: list.id, text: list.title
}))
},
showCancelButton: true
});
if (!listId) return;
await this.$root.api('users/lists/push', {
listId: listId,
userId: this.user.id
});
this.$root.dialog({
type: 'success',
text: this.$t('list-pushed', {
user: this.user.name,
list: lists.find(l => l.id === listId).title
})
});
}
}, null, {
icon: this.user.isMuted ? ['fas', 'eye'] : ['far', 'eye-slash'],
text: this.user.isMuted ? this.$t('unmute') : this.$t('mute'),
action: () => {

View File

@ -63,7 +63,7 @@ export default Vue.extend({
methods: {
showDialog() {
this.$root.alert({
this.$root.dialog({
type: this.dialogType,
title: this.dialogTitle,
text: this.dialogText,

View File

@ -26,45 +26,6 @@ export default (source: string): Node[] => {
nodes = concatText(nodes);
concatTextRecursive(nodes);
function getBeforeTextNode(node: Node): Node {
if (node == null) return null;
if (node.name == 'text') return node;
if (node.children) return getBeforeTextNode(node.children[node.children.length - 1]);
return null;
}
function getAfterTextNode(node: Node): Node {
if (node == null) return null;
if (node.name == 'text') return node;
if (node.children) return getBeforeTextNode(node.children[0]);
return null;
}
function isBlockNode(node: Node): boolean {
return ['blockCode', 'center', 'quote', 'title'].includes(node.name);
}
/**
* ブロック要素の前後にある改行を削除します
* (ブロック要素自体が改行の役割を果たすため、余計に改行されてしまう)
* @param nodes
*/
const removeNeedlessLineBreaks = (nodes: Node[]) => {
nodes.forEach((node, i) => {
if (node.children) removeNeedlessLineBreaks(node.children);
if (isBlockNode(node)) {
const before = getBeforeTextNode(nodes[i - 1]);
const after = getAfterTextNode(nodes[i + 1]);
if (before && before.props.text.endsWith('\n')) {
before.props.text = before.props.text.substring(0, before.props.text.length - 1);
}
if (after && after.props.text.startsWith('\n')) {
after.props.text = after.props.text.substring(1);
}
}
});
};
const removeEmptyTextNodes = (nodes: Node[]) => {
nodes.forEach(n => {
if (n.children) {
@ -74,8 +35,6 @@ export default (source: string): Node[] => {
return nodes.filter(n => !(n.name == 'text' && n.props.text == ''));
};
removeNeedlessLineBreaks(nodes);
nodes = removeEmptyTextNodes(nodes);
return nodes;

View File

@ -162,7 +162,7 @@ const mfm = P.createLanguage({
let hashtag = match[1];
hashtag = hashtag.substr(0, getTrailingPosition(hashtag));
if (hashtag.match(/^[0-9]+$/)) return P.makeFailure(i, 'not a hashtag');
if (!['\n', ' ', ' ', '(', '「', null, undefined].includes(input[i - 1])) return P.makeFailure(i, 'require space before "#"');
if (input[i - 1] != null && input[i - 1].match(/[a-z0-9]/i)) return P.makeFailure(i, 'not a hashtag');
return P.makeSuccess(i + ('#' + hashtag).length, makeNode('hashtag', { hashtag: hashtag }));
}),
//#endregion
@ -254,7 +254,7 @@ const mfm = P.createLanguage({
const qInner = quote.join('\n').replace(/^>/gm, '').replace(/^ /gm, '');
if (qInner == '') return P.makeFailure(i, 'not a quote');
const contents = r.root.tryParse(qInner);
return P.makeSuccess(i + quote.join('\n').length, makeNodeWithChildren('quote', contents));
return P.makeSuccess(i + quote.join('\n').length + 1, makeNodeWithChildren('quote', contents));
})),
//#endregion

View File

@ -1,12 +1,13 @@
const ms = require('ms');
import $ from 'cafy';
import User, { pack } from '../../../../models/user';
import User, { pack, ILocalUser } from '../../../../models/user';
import { getFriendIds } from '../../common/get-friends';
import Mute from '../../../../models/mute';
import * as request from 'request';
import * as request from 'request-promise-native';
import config from '../../../../config';
import define from '../../define';
import fetchMeta from '../../../../misc/fetch-meta';
import resolveUser from '../../../../remote/resolve-user';
export const meta = {
desc: {
@ -53,13 +54,10 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
json: true,
followRedirect: true,
followAllRedirects: true
}, (error: any, response: any, body: any) => {
if (!error && response.statusCode == 200) {
res(body);
} else {
res([]);
}
});
})
.then(body => convertUsers(body, me))
.then(packed => res(packed))
.catch(e => rej(e));
} else {
// ID list of the user itself and other users who the user follows
const followingIds = await getFriendIds(me._id);
@ -90,3 +88,30 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
res(await Promise.all(users.map(user => pack(user, me, { detail: true }))));
}
}));
type IRecommendUser = {
name: string;
username: string;
host: string;
description: string;
avatarUrl: string;
};
/**
* Resolve/Pack dummy users
*/
async function convertUsers(src: IRecommendUser[], me: ILocalUser) {
const packed = await Promise.all(src.map(async x => {
const user = await resolveUser(x.username, x.host)
.catch(() => {
console.warn(`Can't resolve ${x.username}@${x.host}`);
return null;
});
if (user == null) return x;
return await pack(user, me, { detail: true });
}));
return packed;
}

View File

@ -41,6 +41,14 @@ export const meta = {
'ja-JP': 'ローカルユーザーのみ検索対象にするか否か'
}
},
detail: {
validator: $.bool.optional,
default: true,
desc: {
'ja-JP': '詳細なユーザー情報を含めるか否か'
}
},
},
};
@ -72,6 +80,5 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
}
}
// Serialize
res(await Promise.all(users.map(user => pack(user, me, { detail: true }))));
res(await Promise.all(users.map(user => pack(user, me, { detail: ps.detail }))));
}));

View File

@ -155,12 +155,14 @@ export default async (user: IUser, data: Option, silent = false) => new Promise<
// Parse MFM
const tokens = data.text ? parse(data.text) : [];
const cwTokens = data.cw ? parse(data.cw) : [];
const combinedTokens = tokens.concat(cwTokens);
const tags = extractHashtags(tokens);
const tags = extractHashtags(combinedTokens);
const emojis = extractEmojis(tokens);
const emojis = extractEmojis(combinedTokens);
const mentionedUsers = data.apMentions || await extractMentionedUsers(user, tokens);
const mentionedUsers = data.apMentions || await extractMentionedUsers(user, combinedTokens);
if (data.reply && !user._id.equals(data.reply.userId) && !mentionedUsers.some(u => u._id.equals(data.reply.userId))) {
mentionedUsers.push(await User.findOne({ _id: data.reply.userId }));

View File

@ -187,9 +187,9 @@ describe('Text', () => {
});
it('with text (zenkaku)', () => {
const tokens = analyze('こんにちは #世界');
const tokens = analyze('こんにちは#世界');
assert.deepEqual([
text('こんにちは '),
text('こんにちは'),
node('hashtag', { hashtag: '世界' })
], tokens);
});
@ -299,6 +299,7 @@ describe('Text', () => {
nodeWithChildren('quote', [
text('foo')
]),
text('\n'),
nodeWithChildren('quote', [
text('bar')
]),
@ -358,7 +359,7 @@ describe('Text', () => {
it('with before and after texts', () => {
const tokens = analyze('before\n> foo\nafter');
assert.deepEqual([
text('before'),
text('before\n'),
nodeWithChildren('quote', [
text('foo')
]),
@ -366,6 +367,24 @@ describe('Text', () => {
], tokens);
});
it('multiple quotes', () => {
const tokens = analyze('> foo\nbar\n\n> foo\nbar\n\n> foo\nbar');
assert.deepEqual([
nodeWithChildren('quote', [
text('foo')
]),
text('bar\n\n'),
nodeWithChildren('quote', [
text('foo')
]),
text('bar\n\n'),
nodeWithChildren('quote', [
text('foo')
]),
text('bar'),
], tokens);
});
it('require line break before ">"', () => {
const tokens = analyze('foo>bar');
assert.deepEqual([
@ -388,11 +407,11 @@ describe('Text', () => {
it('trim line breaks', () => {
const tokens = analyze('foo\n\n>a\n>>b\n>>\n>>>\n>>>c\n>>>\n>d\n\n');
assert.deepEqual([
text('foo\n'),
text('foo\n\n'),
nodeWithChildren('quote', [
text('a'),
text('a\n'),
nodeWithChildren('quote', [
text('b\n'),
text('b\n\n'),
nodeWithChildren('quote', [
text('\nc\n')
])
@ -664,7 +683,7 @@ describe('Text', () => {
it('with before and after texts', () => {
const tokens = analyze('before\n【foo】\nafter');
assert.deepEqual([
text('before'),
text('before\n'),
nodeWithChildren('title', [
text('foo')
]),