添付されたメディアのURLは省略して表示するように

This commit is contained in:
syuilo 2018-05-17 23:38:35 +09:00
parent e1672e539b
commit 89a58dc596
4 changed files with 47 additions and 3 deletions

View file

@ -0,0 +1,16 @@
export default function(note) {
if (note.text == null) return true;
let txt = note.text;
if (note.media) {
note.media.forEach(file => {
txt = txt.replace(file.url, '');
if (file.src) txt = txt.replace(file.src, '');
});
if (txt == '') return true;
}
return false;
}

View file

@ -44,7 +44,7 @@
<div class="text"> <div class="text">
<span v-if="p.isHidden" style="opacity: 0.5">(この投稿は非公開です)</span> <span v-if="p.isHidden" style="opacity: 0.5">(この投稿は非公開です)</span>
<a class="reply" v-if="p.reply">%fa:reply%</a> <a class="reply" v-if="p.reply">%fa:reply%</a>
<mk-note-html v-if="p.text" :text="p.text" :i="os.i" :class="$style.text"/> <mk-note-html v-if="p.text && !canHideText(p)" :text="p.text" :i="os.i" :class="$style.text"/>
<a class="rp" v-if="p.renote">RP:</a> <a class="rp" v-if="p.renote">RP:</a>
</div> </div>
<div class="media" v-if="p.media.length > 0"> <div class="media" v-if="p.media.length > 0">
@ -94,6 +94,7 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import dateStringify from '../../../common/scripts/date-stringify'; import dateStringify from '../../../common/scripts/date-stringify';
import canHideText from '../../../common/scripts/can-hide-text';
import parse from '../../../../../text/parse'; import parse from '../../../../../text/parse';
import MkPostFormWindow from './post-form-window.vue'; import MkPostFormWindow from './post-form-window.vue';
@ -130,16 +131,17 @@ export default Vue.extend({
}, },
computed: { computed: {
isRenote(): boolean { isRenote(): boolean {
return (this.note.renote && return (this.note.renote &&
this.note.text == null && this.note.text == null &&
this.note.mediaIds.length == 0 && this.note.mediaIds.length == 0 &&
this.note.poll == null); this.note.poll == null);
}, },
p(): any { p(): any {
return this.isRenote ? this.note.renote : this.note; return this.isRenote ? this.note.renote : this.note;
}, },
reactionsCount(): number { reactionsCount(): number {
return this.p.reactionCounts return this.p.reactionCounts
? Object.keys(this.p.reactionCounts) ? Object.keys(this.p.reactionCounts)
@ -147,9 +149,11 @@ export default Vue.extend({
.reduce((a, b) => a + b) .reduce((a, b) => a + b)
: 0; : 0;
}, },
title(): string { title(): string {
return dateStringify(this.p.createdAt); return dateStringify(this.p.createdAt);
}, },
urls(): string[] { urls(): string[] {
if (this.p.text) { if (this.p.text) {
const ast = parse(this.p.text); const ast = parse(this.p.text);
@ -205,6 +209,8 @@ export default Vue.extend({
}, },
methods: { methods: {
canHideText,
capture(withHandler = false) { capture(withHandler = false) {
if ((this as any).os.isSignedIn) { if ((this as any).os.isSignedIn) {
this.connection.send({ this.connection.send({
@ -214,6 +220,7 @@ export default Vue.extend({
if (withHandler) this.connection.on('note-updated', this.onStreamNoteUpdated); if (withHandler) this.connection.on('note-updated', this.onStreamNoteUpdated);
} }
}, },
decapture(withHandler = false) { decapture(withHandler = false) {
if ((this as any).os.isSignedIn) { if ((this as any).os.isSignedIn) {
this.connection.send({ this.connection.send({
@ -223,9 +230,11 @@ export default Vue.extend({
if (withHandler) this.connection.off('note-updated', this.onStreamNoteUpdated); if (withHandler) this.connection.off('note-updated', this.onStreamNoteUpdated);
} }
}, },
onStreamConnected() { onStreamConnected() {
this.capture(); this.capture();
}, },
onStreamNoteUpdated(data) { onStreamNoteUpdated(data) {
const note = data.note; const note = data.note;
if (note.id == this.note.id) { if (note.id == this.note.id) {
@ -234,28 +243,33 @@ export default Vue.extend({
this.note.renote = note; this.note.renote = note;
} }
}, },
reply() { reply() {
(this as any).os.new(MkPostFormWindow, { (this as any).os.new(MkPostFormWindow, {
reply: this.p reply: this.p
}); });
}, },
renote() { renote() {
(this as any).os.new(MkRenoteFormWindow, { (this as any).os.new(MkRenoteFormWindow, {
note: this.p note: this.p
}); });
}, },
react() { react() {
(this as any).os.new(MkReactionPicker, { (this as any).os.new(MkReactionPicker, {
source: this.$refs.reactButton, source: this.$refs.reactButton,
note: this.p note: this.p
}); });
}, },
menu() { menu() {
(this as any).os.new(MkNoteMenu, { (this as any).os.new(MkNoteMenu, {
source: this.$refs.menuButton, source: this.$refs.menuButton,
note: this.p note: this.p
}); });
}, },
onKeydown(e) { onKeydown(e) {
let shouldBeCancel = true; let shouldBeCancel = true;

View file

@ -41,7 +41,7 @@
<div class="text"> <div class="text">
<span v-if="p.isHidden" style="opacity: 0.5">(この投稿は非公開です)</span> <span v-if="p.isHidden" style="opacity: 0.5">(この投稿は非公開です)</span>
<a class="reply" v-if="p.reply">%fa:reply%</a> <a class="reply" v-if="p.reply">%fa:reply%</a>
<mk-note-html v-if="p.text" :text="p.text" :i="os.i" :class="$style.text"/> <mk-note-html v-if="p.text && !canHideText(p)" :text="p.text" :i="os.i" :class="$style.text"/>
<a class="rp" v-if="p.renote != null">RP:</a> <a class="rp" v-if="p.renote != null">RP:</a>
</div> </div>
<div class="media" v-if="p.media.length > 0"> <div class="media" v-if="p.media.length > 0">
@ -85,6 +85,7 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import parse from '../../../../../text/parse'; import parse from '../../../../../text/parse';
import canHideText from '../../../common/scripts/can-hide-text';
import MkNoteMenu from '../../../common/views/components/note-menu.vue'; import MkNoteMenu from '../../../common/views/components/note-menu.vue';
import MkReactionPicker from '../../../common/views/components/reaction-picker.vue'; import MkReactionPicker from '../../../common/views/components/reaction-picker.vue';
@ -112,9 +113,11 @@ export default Vue.extend({
this.note.mediaIds.length == 0 && this.note.mediaIds.length == 0 &&
this.note.poll == null); this.note.poll == null);
}, },
p(): any { p(): any {
return this.isRenote ? this.note.renote : this.note; return this.isRenote ? this.note.renote : this.note;
}, },
reactionsCount(): number { reactionsCount(): number {
return this.p.reactionCounts return this.p.reactionCounts
? Object.keys(this.p.reactionCounts) ? Object.keys(this.p.reactionCounts)
@ -122,6 +125,7 @@ export default Vue.extend({
.reduce((a, b) => a + b) .reduce((a, b) => a + b)
: 0; : 0;
}, },
urls(): string[] { urls(): string[] {
if (this.p.text) { if (this.p.text) {
const ast = parse(this.p.text); const ast = parse(this.p.text);
@ -177,6 +181,8 @@ export default Vue.extend({
}, },
methods: { methods: {
canHideText,
capture(withHandler = false) { capture(withHandler = false) {
if ((this as any).os.isSignedIn) { if ((this as any).os.isSignedIn) {
this.connection.send({ this.connection.send({
@ -186,6 +192,7 @@ export default Vue.extend({
if (withHandler) this.connection.on('note-updated', this.onStreamNoteUpdated); if (withHandler) this.connection.on('note-updated', this.onStreamNoteUpdated);
} }
}, },
decapture(withHandler = false) { decapture(withHandler = false) {
if ((this as any).os.isSignedIn) { if ((this as any).os.isSignedIn) {
this.connection.send({ this.connection.send({
@ -195,9 +202,11 @@ export default Vue.extend({
if (withHandler) this.connection.off('note-updated', this.onStreamNoteUpdated); if (withHandler) this.connection.off('note-updated', this.onStreamNoteUpdated);
} }
}, },
onStreamConnected() { onStreamConnected() {
this.capture(); this.capture();
}, },
onStreamNoteUpdated(data) { onStreamNoteUpdated(data) {
const note = data.note; const note = data.note;
if (note.id == this.note.id) { if (note.id == this.note.id) {
@ -206,16 +215,19 @@ export default Vue.extend({
this.note.renote = note; this.note.renote = note;
} }
}, },
reply() { reply() {
(this as any).apis.post({ (this as any).apis.post({
reply: this.p reply: this.p
}); });
}, },
renote() { renote() {
(this as any).apis.post({ (this as any).apis.post({
renote: this.p renote: this.p
}); });
}, },
react() { react() {
(this as any).os.new(MkReactionPicker, { (this as any).os.new(MkReactionPicker, {
source: this.$refs.reactButton, source: this.$refs.reactButton,
@ -223,6 +235,7 @@ export default Vue.extend({
compact: true compact: true
}); });
}, },
menu() { menu() {
(this as any).os.new(MkNoteMenu, { (this as any).os.new(MkNoteMenu, {
source: this.$refs.menuButton, source: this.$refs.menuButton,

View file

@ -154,6 +154,7 @@ export const pack = (
_target = Object.assign(_target, _file.metadata); _target = Object.assign(_target, _file.metadata);
_target.src = _file.metadata.url;
_target.url = `${config.drive_url}/${_target.id}/${encodeURIComponent(_target.name)}`; _target.url = `${config.drive_url}/${_target.id}/${encodeURIComponent(_target.name)}`;
if (_target.properties == null) _target.properties = {}; if (_target.properties == null) _target.properties = {};