mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-05 15:55:56 +02:00
@@ -64,7 +64,7 @@ import Vue from 'vue';
|
||||
import * as XDraggable from 'vuedraggable';
|
||||
import * as uuid from 'uuid';
|
||||
import Progress from '../../../common/scripts/loading';
|
||||
import getPostSummary from '../../../../../renderers/get-post-summary';
|
||||
import getNoteSummary from '../../../../../renderers/get-note-summary';
|
||||
|
||||
export default Vue.extend({
|
||||
components: {
|
||||
@@ -124,14 +124,14 @@ export default Vue.extend({
|
||||
this.connection = (this as any).os.stream.getConnection();
|
||||
this.connectionId = (this as any).os.stream.use();
|
||||
|
||||
this.connection.on('post', this.onStreamPost);
|
||||
this.connection.on('note', this.onStreamNote);
|
||||
this.connection.on('mobile_home_updated', this.onHomeUpdated);
|
||||
document.addEventListener('visibilitychange', this.onVisibilitychange, false);
|
||||
|
||||
Progress.start();
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.connection.off('post', this.onStreamPost);
|
||||
this.connection.off('note', this.onStreamNote);
|
||||
this.connection.off('mobile_home_updated', this.onHomeUpdated);
|
||||
(this as any).os.stream.dispose(this.connectionId);
|
||||
document.removeEventListener('visibilitychange', this.onVisibilitychange);
|
||||
@@ -143,10 +143,10 @@ export default Vue.extend({
|
||||
onLoaded() {
|
||||
Progress.done();
|
||||
},
|
||||
onStreamPost(post) {
|
||||
if (document.hidden && post.userId !== (this as any).os.i.id) {
|
||||
onStreamNote(note) {
|
||||
if (document.hidden && note.userId !== (this as any).os.i.id) {
|
||||
this.unreadCount++;
|
||||
document.title = `(${this.unreadCount}) ${getPostSummary(post)}`;
|
||||
document.title = `(${this.unreadCount}) ${getNoteSummary(note)}`;
|
||||
}
|
||||
},
|
||||
onVisibilitychange() {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<template>
|
||||
<mk-ui>
|
||||
<span slot="header">%fa:R sticky-note%%i18n:mobile.tags.mk-post-page.title%</span>
|
||||
<span slot="header">%fa:R sticky-note%%i18n:mobile.tags.mk-note-page.title%</span>
|
||||
<main v-if="!fetching">
|
||||
<a v-if="post.next" :href="post.next">%fa:angle-up%%i18n:mobile.tags.mk-post-page.next%</a>
|
||||
<a v-if="note.next" :href="note.next">%fa:angle-up%%i18n:mobile.tags.mk-note-page.next%</a>
|
||||
<div>
|
||||
<mk-post-detail :post="post"/>
|
||||
<mk-note-detail :note="note"/>
|
||||
</div>
|
||||
<a v-if="post.prev" :href="post.prev">%fa:angle-down%%i18n:mobile.tags.mk-post-page.prev%</a>
|
||||
<a v-if="note.prev" :href="note.prev">%fa:angle-down%%i18n:mobile.tags.mk-note-page.prev%</a>
|
||||
</main>
|
||||
</mk-ui>
|
||||
</template>
|
||||
@@ -19,7 +19,7 @@ export default Vue.extend({
|
||||
data() {
|
||||
return {
|
||||
fetching: true,
|
||||
post: null
|
||||
note: null
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
@@ -37,10 +37,10 @@ export default Vue.extend({
|
||||
Progress.start();
|
||||
this.fetching = true;
|
||||
|
||||
(this as any).api('posts/show', {
|
||||
postId: this.$route.params.post
|
||||
}).then(post => {
|
||||
this.post = post;
|
||||
(this as any).api('notes/show', {
|
||||
noteId: this.$route.params.note
|
||||
}).then(note => {
|
||||
this.note = note;
|
||||
this.fetching = false;
|
||||
|
||||
Progress.done();
|
||||
@@ -2,13 +2,13 @@
|
||||
<mk-ui>
|
||||
<span slot="header">%fa:search% {{ q }}</span>
|
||||
<main v-if="!fetching">
|
||||
<mk-posts :class="$style.posts" :posts="posts">
|
||||
<span v-if="posts.length == 0">{{ '%i18n:mobile.tags.mk-search-posts.empty%'.replace('{}', q) }}</span>
|
||||
<mk-notes :class="$style.notes" :notes="notes">
|
||||
<span v-if="notes.length == 0">{{ '%i18n:mobile.tags.mk-search-notes.empty%'.replace('{}', q) }}</span>
|
||||
<button v-if="existMore" @click="more" :disabled="fetching" slot="tail">
|
||||
<span v-if="!fetching">%i18n:mobile.tags.mk-timeline.load-more%</span>
|
||||
<span v-if="fetching">%i18n:common.loading%<mk-ellipsis/></span>
|
||||
</button>
|
||||
</mk-posts>
|
||||
</mk-notes>
|
||||
</main>
|
||||
</mk-ui>
|
||||
</template>
|
||||
@@ -25,7 +25,7 @@ export default Vue.extend({
|
||||
return {
|
||||
fetching: true,
|
||||
existMore: false,
|
||||
posts: [],
|
||||
notes: [],
|
||||
offset: 0
|
||||
};
|
||||
},
|
||||
@@ -48,30 +48,30 @@ export default Vue.extend({
|
||||
this.fetching = true;
|
||||
Progress.start();
|
||||
|
||||
(this as any).api('posts/search', Object.assign({
|
||||
(this as any).api('notes/search', Object.assign({
|
||||
limit: limit + 1
|
||||
}, parse(this.q))).then(posts => {
|
||||
if (posts.length == limit + 1) {
|
||||
posts.pop();
|
||||
}, parse(this.q))).then(notes => {
|
||||
if (notes.length == limit + 1) {
|
||||
notes.pop();
|
||||
this.existMore = true;
|
||||
}
|
||||
this.posts = posts;
|
||||
this.notes = notes;
|
||||
this.fetching = false;
|
||||
Progress.done();
|
||||
});
|
||||
},
|
||||
more() {
|
||||
this.offset += limit;
|
||||
(this as any).api('posts/search', Object.assign({
|
||||
(this as any).api('notes/search', Object.assign({
|
||||
limit: limit + 1,
|
||||
offset: this.offset
|
||||
}, parse(this.q))).then(posts => {
|
||||
if (posts.length == limit + 1) {
|
||||
posts.pop();
|
||||
}, parse(this.q))).then(notes => {
|
||||
if (notes.length == limit + 1) {
|
||||
notes.pop();
|
||||
} else {
|
||||
this.existMore = false;
|
||||
}
|
||||
this.posts = this.posts.concat(posts);
|
||||
this.notes = this.notes.concat(notes);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ export default Vue.extend({
|
||||
</script>
|
||||
|
||||
<style lang="stylus" module>
|
||||
.posts
|
||||
.notes
|
||||
margin 8px auto
|
||||
max-width 500px
|
||||
width calc(100% - 16px)
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
</div>
|
||||
<div class="status">
|
||||
<a>
|
||||
<b>{{ user.postsCount | number }}</b>
|
||||
<i>%i18n:mobile.tags.mk-user.posts%</i>
|
||||
<b>{{ user.notesCount | number }}</b>
|
||||
<i>%i18n:mobile.tags.mk-user.notes%</i>
|
||||
</a>
|
||||
<a :href="`@${acct}/following`">
|
||||
<b>{{ user.followingCount | number }}</b>
|
||||
@@ -44,13 +44,13 @@
|
||||
<nav>
|
||||
<div class="nav-container">
|
||||
<a :data-is-active=" page == 'home' " @click="page = 'home'">%i18n:mobile.tags.mk-user.overview%</a>
|
||||
<a :data-is-active=" page == 'posts' " @click="page = 'posts'">%i18n:mobile.tags.mk-user.timeline%</a>
|
||||
<a :data-is-active=" page == 'notes' " @click="page = 'notes'">%i18n:mobile.tags.mk-user.timeline%</a>
|
||||
<a :data-is-active=" page == 'media' " @click="page = 'media'">%i18n:mobile.tags.mk-user.media%</a>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="body">
|
||||
<x-home v-if="page == 'home'" :user="user"/>
|
||||
<mk-user-timeline v-if="page == 'posts'" :user="user"/>
|
||||
<mk-user-timeline v-if="page == 'notes'" :user="user"/>
|
||||
<mk-user-timeline v-if="page == 'media'" :user="user" with-media/>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<div class="root posts">
|
||||
<p class="fetching" v-if="fetching">%fa:spinner .pulse .fw%%i18n:mobile.tags.mk-user-overview-posts.loading%<mk-ellipsis/></p>
|
||||
<div v-if="!fetching && posts.length > 0">
|
||||
<mk-post-card v-for="post in posts" :key="post.id" :post="post"/>
|
||||
<div class="root notes">
|
||||
<p class="fetching" v-if="fetching">%fa:spinner .pulse .fw%%i18n:mobile.tags.mk-user-overview-notes.loading%<mk-ellipsis/></p>
|
||||
<div v-if="!fetching && notes.length > 0">
|
||||
<mk-note-card v-for="note in notes" :key="note.id" :note="note"/>
|
||||
</div>
|
||||
<p class="empty" v-if="!fetching && posts.length == 0">%i18n:mobile.tags.mk-user-overview-posts.no-posts%</p>
|
||||
<p class="empty" v-if="!fetching && notes.length == 0">%i18n:mobile.tags.mk-user-overview-notes.no-notes%</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -15,14 +15,14 @@ export default Vue.extend({
|
||||
data() {
|
||||
return {
|
||||
fetching: true,
|
||||
posts: []
|
||||
notes: []
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
(this as any).api('users/posts', {
|
||||
(this as any).api('users/notes', {
|
||||
userId: this.user.id
|
||||
}).then(posts => {
|
||||
this.posts = posts;
|
||||
}).then(notes => {
|
||||
this.notes = notes;
|
||||
this.fetching = false;
|
||||
});
|
||||
}
|
||||
@@ -30,7 +30,7 @@ export default Vue.extend({
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
.root.posts
|
||||
.root.notes
|
||||
|
||||
> div
|
||||
overflow-x scroll
|
||||
@@ -5,7 +5,7 @@
|
||||
<a v-for="image in images"
|
||||
class="img"
|
||||
:style="`background-image: url(${image.media.url}?thumbnail&size=256)`"
|
||||
:href="`/@${getAcct(image.post.user)}/${image.post.id}`"
|
||||
:href="`/@${getAcct(image.note.user)}/${image.note.id}`"
|
||||
></a>
|
||||
</div>
|
||||
<p class="empty" v-if="!fetching && images.length == 0">%i18n:mobile.tags.mk-user-overview-photos.no-photos%</p>
|
||||
@@ -28,15 +28,15 @@ export default Vue.extend({
|
||||
getAcct
|
||||
},
|
||||
mounted() {
|
||||
(this as any).api('users/posts', {
|
||||
(this as any).api('users/notes', {
|
||||
userId: this.user.id,
|
||||
withMedia: true,
|
||||
limit: 6
|
||||
}).then(posts => {
|
||||
posts.forEach(post => {
|
||||
post.media.forEach(media => {
|
||||
}).then(notes => {
|
||||
notes.forEach(note => {
|
||||
note.media.forEach(media => {
|
||||
if (this.images.length < 9) this.images.push({
|
||||
post,
|
||||
note,
|
||||
media
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<div class="root home">
|
||||
<mk-post-detail v-if="user.pinnedPost" :post="user.pinnedPost" :compact="true"/>
|
||||
<section class="recent-posts">
|
||||
<h2>%fa:R comments%%i18n:mobile.tags.mk-user-overview.recent-posts%</h2>
|
||||
<mk-note-detail v-if="user.pinnedNote" :note="user.pinnedNote" :compact="true"/>
|
||||
<section class="recent-notes">
|
||||
<h2>%fa:R comments%%i18n:mobile.tags.mk-user-overview.recent-notes%</h2>
|
||||
<div>
|
||||
<x-posts :user="user"/>
|
||||
<x-notes :user="user"/>
|
||||
</div>
|
||||
</section>
|
||||
<section class="images">
|
||||
@@ -37,14 +37,14 @@
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import XPosts from './home.posts.vue';
|
||||
import XNotes from './home.notes.vue';
|
||||
import XPhotos from './home.photos.vue';
|
||||
import XFriends from './home.friends.vue';
|
||||
import XFollowersYouKnow from './home.followers-you-know.vue';
|
||||
|
||||
export default Vue.extend({
|
||||
components: {
|
||||
XPosts,
|
||||
XNotes,
|
||||
XPhotos,
|
||||
XFriends,
|
||||
XFollowersYouKnow
|
||||
@@ -58,7 +58,7 @@ export default Vue.extend({
|
||||
max-width 600px
|
||||
margin 0 auto
|
||||
|
||||
> .mk-post-detail
|
||||
> .mk-note-detail
|
||||
margin 0 0 8px 0
|
||||
|
||||
> section
|
||||
|
||||
Reference in New Issue
Block a user