summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-03-20 14:35:00 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-03-20 14:35:00 +0900
commitde5dc87cec2c171ecd890731a3b6978d33249e21 (patch)
tree456da3e42b771b2dae7f544b16b17f5768266f78 /src
parent[Client] Fix bugs (diff)
downloadsharkey-de5dc87cec2c171ecd890731a3b6978d33249e21.tar.gz
sharkey-de5dc87cec2c171ecd890731a3b6978d33249e21.tar.bz2
sharkey-de5dc87cec2c171ecd890731a3b6978d33249e21.zip
[Client] Fix bug, some refactorings
Diffstat (limited to 'src')
-rw-r--r--src/web/app/common/scripts/stream.js2
-rw-r--r--src/web/app/desktop/tags/timeline-post.tag22
-rw-r--r--src/web/app/mobile/tags/timeline-post.tag22
3 files changed, 30 insertions, 16 deletions
diff --git a/src/web/app/common/scripts/stream.js b/src/web/app/common/scripts/stream.js
index cbdde8d2f2..5296abfde8 100644
--- a/src/web/app/common/scripts/stream.js
+++ b/src/web/app/common/scripts/stream.js
@@ -45,6 +45,8 @@ class Connection {
}
send(message) {
+ // TODO: バッファリングしてつぎ接続した時に送信する
+ if (this.state != 'connected') return;
this.socket.send(JSON.stringify(message));
}
diff --git a/src/web/app/desktop/tags/timeline-post.tag b/src/web/app/desktop/tags/timeline-post.tag
index 07cc665674..220b8441b8 100644
--- a/src/web/app/desktop/tags/timeline-post.tag
+++ b/src/web/app/desktop/tags/timeline-post.tag
@@ -364,13 +364,24 @@
}
};
- this.on('mount', () => {
+ this.capture = () => {
this.stream.send({
type: 'capture',
id: this.p.id
});
-
this.stream.event.on('post-updated', this.onStreamPostUpdated);
+ };
+
+ this.decapture = () => {
+ this.stream.send({
+ type: 'decapture',
+ id: this.p.id
+ });
+ this.stream.event.off('post-updated', this.onStreamPostUpdated);
+ };
+
+ this.on('mount', () => {
+ this.capture();
if (this.p.text) {
const tokens = this.p.ast;
@@ -393,12 +404,7 @@
});
this.on('unmount', () => {
- this.stream.send({
- type: 'decapture',
- id: this.p.id
- });
-
- this.stream.event.off('post-updated', this.onStreamPostUpdated);
+ this.decapture();
});
this.reply = () => {
diff --git a/src/web/app/mobile/tags/timeline-post.tag b/src/web/app/mobile/tags/timeline-post.tag
index e0cffb62de..7f02dd4872 100644
--- a/src/web/app/mobile/tags/timeline-post.tag
+++ b/src/web/app/mobile/tags/timeline-post.tag
@@ -340,13 +340,24 @@
}
};
- this.on('mount', () => {
+ this.capture = () => {
this.stream.send({
type: 'capture',
id: this.p.id
});
-
this.stream.event.on('post-updated', this.onStreamPostUpdated);
+ };
+
+ this.decapture = () => {
+ this.stream.send({
+ type: 'decapture',
+ id: this.p.id
+ });
+ this.stream.event.off('post-updated', this.onStreamPostUpdated);
+ };
+
+ this.on('mount', () => {
+ this.capture();
if (this.p.text) {
const tokens = this.p.ast;
@@ -369,12 +380,7 @@
});
this.on('unmount', () => {
- this.stream.send({
- type: 'decapture',
- id: this.p.id
- });
-
- this.stream.event.off('post-updated', this.onStreamPostUpdated);
+ this.decapture();
});
this.reply = () => {