1
1
import Controller , { inject as controller } from '@ember/controller' ;
2
+ import { alias } from '@ember/object/computed' ;
2
3
import { inject as service } from '@ember/service' ;
3
4
import { isPresent } from '@ember/utils' ;
4
5
import Message from 'hyperchannel/models/message' ;
@@ -11,11 +12,13 @@ export default Controller.extend({
11
12
coms : service ( ) ,
12
13
storage : service ( 'remotestorage' ) ,
13
14
15
+ currentSpace : alias ( 'space.model' ) ,
16
+
14
17
createMessage ( message , type ) {
15
18
return Message . create ( {
16
19
type : type ,
17
20
date : new Date ( ) ,
18
- nickname : this . get ( 'space.model .server.nickname' ) ,
21
+ nickname : this . get ( 'currentSpace .server.nickname' ) ,
19
22
content : message
20
23
} ) ;
21
24
} ,
@@ -41,7 +44,7 @@ export default Controller.extend({
41
44
let message = this . createMessage ( newMessage , 'message-chat' ) ;
42
45
43
46
this . coms . transferMessage (
44
- this . get ( 'space.model ' ) ,
47
+ this . get ( 'currentSpace ' ) ,
45
48
this . model ,
46
49
message . get ( 'content' )
47
50
) ;
@@ -74,14 +77,14 @@ export default Controller.extend({
74
77
} ,
75
78
76
79
joinCommand : function ( args ) {
77
- let space = this . get ( 'space.model ' ) ;
80
+ let space = this . get ( 'currentSpace ' ) ;
78
81
let channel = this . coms . createChannel ( space , args [ 0 ] ) ;
79
82
this . storage . saveSpace ( space ) ;
80
83
this . transitionToRoute ( 'space.channel' , space , channel ) ;
81
84
} ,
82
85
83
86
partCommand : function ( ) {
84
- let space = this . get ( 'space.model ' ) ;
87
+ let space = this . get ( 'currentSpace ' ) ;
85
88
let channelName = this . get ( 'model.name' ) ;
86
89
this . coms . removeChannel ( space , channelName ) ;
87
90
let lastChannel = space . get ( 'channels.lastObject' ) ;
@@ -105,7 +108,7 @@ export default Controller.extend({
105
108
let message = this . createMessage ( newMessage , 'message-chat-me' ) ;
106
109
107
110
this . coms . transferMeMessage (
108
- this . get ( 'space.model ' ) ,
111
+ this . get ( 'currentSpace ' ) ,
109
112
this . get ( 'model.sockethubChannelId' ) ,
110
113
message . get ( 'content' )
111
114
) ;
@@ -115,17 +118,17 @@ export default Controller.extend({
115
118
116
119
msgCommand : function ( args ) {
117
120
let username = args . shift ( ) ;
118
- this . coms . createUserChannel ( this . get ( 'space.model ' ) , username ) ;
121
+ this . coms . createUserChannel ( this . get ( 'currentSpace ' ) , username ) ;
119
122
// TODO fix this, sockethub sends a failure event with error
120
123
// "TypeError: Cannot read property 'indexOf' of undefined"
121
- // this.get('coms').transferMessage(this.get('space.model '), username, args.join(' '));
124
+ // this.get('coms').transferMessage(this.get('currentSpace '), username, args.join(' '));
122
125
} ,
123
126
124
127
topicCommand : function ( args ) {
125
128
let channel = this . model ;
126
129
let topic = args . join ( ' ' ) ;
127
130
128
- this . coms . changeTopic ( this . get ( 'space.model ' ) , channel , topic ) ;
131
+ this . coms . changeTopic ( this . get ( 'currentSpace ' ) , channel , topic ) ;
129
132
}
130
133
}
131
134
0 commit comments