summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-25 13:48:02 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-25 13:48:02 +0900
commit4c9b4cb80d221bf2316cf0c7133813c30ffb377b (patch)
treee06e0f0f85c20b510a80fd767ee245dd255f6bd2 /src
parentwip (diff)
downloadmisskey-4c9b4cb80d221bf2316cf0c7133813c30ffb377b.tar.gz
misskey-4c9b4cb80d221bf2316cf0c7133813c30ffb377b.tar.bz2
misskey-4c9b4cb80d221bf2316cf0c7133813c30ffb377b.zip
wip
Diffstat (limited to 'src')
-rw-r--r--src/client/app/common/scripts/streaming/user-list.ts17
-rw-r--r--src/client/app/desktop/views/components/list-timeline.vue15
-rw-r--r--src/client/app/desktop/views/components/notes.vue31
-rw-r--r--src/client/app/desktop/views/components/timeline.core.vue25
4 files changed, 53 insertions, 35 deletions
diff --git a/src/client/app/common/scripts/streaming/user-list.ts b/src/client/app/common/scripts/streaming/user-list.ts
new file mode 100644
index 0000000000..30a52b98dd
--- /dev/null
+++ b/src/client/app/common/scripts/streaming/user-list.ts
@@ -0,0 +1,17 @@
+import Stream from './stream';
+import MiOS from '../../mios';
+
+export class UserListStream extends Stream {
+ constructor(os: MiOS, me, listId) {
+ super(os, 'user-list', {
+ i: me.token,
+ listId
+ });
+
+ (this as any).on('_connected_', () => {
+ this.send({
+ i: me.token
+ });
+ });
+ }
+}
diff --git a/src/client/app/desktop/views/components/list-timeline.vue b/src/client/app/desktop/views/components/list-timeline.vue
index 61300f6f8f..e946453f40 100644
--- a/src/client/app/desktop/views/components/list-timeline.vue
+++ b/src/client/app/desktop/views/components/list-timeline.vue
@@ -4,6 +4,7 @@
<script lang="ts">
import Vue from 'vue';
+import { UserListStream } from '../../../common/scripts/streaming/user-list';
const fetchLimit = 10;
@@ -21,21 +22,19 @@ export default Vue.extend({
$route: 'fetch'
},
mounted() {
- this.connection = new UserListStream((this as any).os, (this as any).os.i, this.list.id);
- this.connection.on('note', this.onNote);
- this.connection.on('userAdded', this.onUserAdded);
- this.connection.on('userRemoved', this.onUserRemoved);
-
this.fetch();
},
beforeDestroy() {
- this.connection.off('note', this.onNote);
- this.connection.off('userAdded', this.onUserAdded);
- this.connection.off('userRemoved', this.onUserRemoved);
this.connection.close();
},
methods: {
fetch() {
+ if (this.connection) this.connection.close();
+ this.connection = new UserListStream((this as any).os, (this as any).os.i, this.list.id);
+ this.connection.on('note', this.onNote);
+ this.connection.on('userAdded', this.onUserAdded);
+ this.connection.on('userRemoved', this.onUserRemoved);
+
this.fetching = true;
(this as any).api('notes/list-timeline', {
diff --git a/src/client/app/desktop/views/components/notes.vue b/src/client/app/desktop/views/components/notes.vue
index 2822cb8c0f..6965a18eda 100644
--- a/src/client/app/desktop/views/components/notes.vue
+++ b/src/client/app/desktop/views/components/notes.vue
@@ -20,6 +20,8 @@
<script lang="ts">
import Vue from 'vue';
+import { url } from '../../../config';
+
import XNote from './notes.note.vue';
const displayLimit = 30;
@@ -83,10 +85,35 @@ export default Vue.extend({
this.notes = notes;
},
- prepend(note) {
+ prepend(note, silent = false) {
+ //#region 弾く
+ const isMyNote = note.userId == (this as any).os.i.id;
+ const isPureRenote = note.renoteId != null && note.text == null && note.mediaIds.length == 0 && note.poll == null;
+
+ if ((this as any).os.i.clientSettings.showMyRenotes === false) {
+ if (isMyNote && isPureRenote) {
+ return;
+ }
+ }
+
+ if ((this as any).os.i.clientSettings.showRenotedMyNotes === false) {
+ if (isPureRenote && (note.renote.userId == (this as any).os.i.id)) {
+ return;
+ }
+ }
+ //#endregion
+
if (this.isScrollTop()) {
+ // Prepend the note
this.notes.unshift(note);
+ // サウンドを再生する
+ if ((this as any).os.isEnableSounds && !silent) {
+ const sound = new Audio(`${url}/assets/post.mp3`);
+ sound.volume = localStorage.getItem('soundVolume') ? parseInt(localStorage.getItem('soundVolume'), 10) / 100 : 0.5;
+ sound.play();
+ }
+
// オーバーフローしたら古い投稿は捨てる
if (this.notes.length >= displayLimit) {
this.notes = this.notes.slice(0, displayLimit);
@@ -105,7 +132,7 @@ export default Vue.extend({
},
releaseQueue() {
- this.queue.forEach(n => this.prepend(n));
+ this.queue.forEach(n => this.prepend(n, true));
this.queue = [];
},
diff --git a/src/client/app/desktop/views/components/timeline.core.vue b/src/client/app/desktop/views/components/timeline.core.vue
index 11c7adf158..93cc59b556 100644
--- a/src/client/app/desktop/views/components/timeline.core.vue
+++ b/src/client/app/desktop/views/components/timeline.core.vue
@@ -14,7 +14,6 @@
<script lang="ts">
import Vue from 'vue';
-import { url } from '../../../config';
const fetchLimit = 10;
@@ -136,30 +135,6 @@ export default Vue.extend({
},
onNote(note) {
- //#region 弾く
- const isMyNote = note.userId == (this as any).os.i.id;
- const isPureRenote = note.renoteId != null && note.text == null && note.mediaIds.length == 0 && note.poll == null;
-
- if ((this as any).os.i.clientSettings.showMyRenotes === false) {
- if (isMyNote && isPureRenote) {
- return;
- }
- }
-
- if ((this as any).os.i.clientSettings.showRenotedMyNotes === false) {
- if (isPureRenote && (note.renote.userId == (this as any).os.i.id)) {
- return;
- }
- }
- //#endregion
-
- // サウンドを再生する
- if ((this as any).os.isEnableSounds) {
- const sound = new Audio(`${url}/assets/post.mp3`);
- sound.volume = localStorage.getItem('soundVolume') ? parseInt(localStorage.getItem('soundVolume'), 10) / 100 : 0.5;
- sound.play();
- }
-
// Prepend a note
(this.$refs.timeline as any).prepend(note);
},