wip
This commit is contained in:
@@ -5,6 +5,6 @@
|
||||
display inline
|
||||
</style>
|
||||
<script>
|
||||
this.kind = this.opts.type.split '/' .0
|
||||
this.kind = this.opts.type.split('/')[0];
|
||||
</script>
|
||||
</mk-file-type-icon>
|
||||
|
||||
@@ -150,23 +150,26 @@
|
||||
event.one('selected', files => {
|
||||
files.forEach(this.addFile);
|
||||
});
|
||||
}
|
||||
|
||||
send() {
|
||||
this.sending = true
|
||||
this.api 'messaging/messages/create' do
|
||||
user_id: this.opts.user.id
|
||||
this.sending = true;
|
||||
this.api('messaging/messages/create', {
|
||||
user_id: this.opts.user.id,
|
||||
text: this.refs.text.value
|
||||
.then (message) =>
|
||||
@clear!
|
||||
.catch (err) =>
|
||||
console.error err
|
||||
.then =>
|
||||
this.sending = false
|
||||
}).then(message => {
|
||||
this.clear();
|
||||
}).catch(err => {
|
||||
console.error(err);
|
||||
}).then(() => {
|
||||
this.sending = false;
|
||||
this.update();
|
||||
});
|
||||
|
||||
clear() {
|
||||
this.refs.text.value = ''
|
||||
this.files = []
|
||||
this.refs.text.value = '';
|
||||
this.files = [];
|
||||
this.update();
|
||||
}
|
||||
</script>
|
||||
</mk-messaging-form>
|
||||
|
||||
@@ -289,29 +289,27 @@
|
||||
this.mixin('i');
|
||||
this.mixin('api');
|
||||
|
||||
this.search-result = []
|
||||
this.searchResult = [];
|
||||
|
||||
this.on('mount', () => {
|
||||
this.api 'messaging/history'
|
||||
.then (history) =>
|
||||
this.is-loading = false
|
||||
history.for-each (message) =>
|
||||
message.is_me = message.user_id == @I.id
|
||||
message._click = =>
|
||||
if message.is_me
|
||||
this.trigger 'navigate-user' message.recipient
|
||||
else
|
||||
this.trigger 'navigate-user' message.user
|
||||
this.history = history
|
||||
this.api('messaging/history').then(history => {
|
||||
this.isLoading = false;
|
||||
history.forEach(message => {
|
||||
message.is_me = message.user_id == this.I.id
|
||||
message._click = () => {
|
||||
this.trigger('navigate-user', message.is_me ? message.recipient : message.user);
|
||||
};
|
||||
});
|
||||
this.history = history;
|
||||
this.update();
|
||||
.catch (err) =>
|
||||
console.error err
|
||||
});
|
||||
}
|
||||
|
||||
search() {
|
||||
q = this.refs.search.value
|
||||
if q == ''
|
||||
this.search-result = []
|
||||
else
|
||||
const q = this.refs.search.value;
|
||||
if (q == '') {
|
||||
this.searchResult = [];
|
||||
} else {
|
||||
this.api 'users/search' do
|
||||
query: q
|
||||
max: 5
|
||||
|
||||
@@ -207,7 +207,7 @@
|
||||
this.mixin('text');
|
||||
|
||||
this.message = this.opts.message
|
||||
@message.is_me = @message.user.id == @I.id
|
||||
@message.is_me = @message.user.id == this.I.id
|
||||
|
||||
this.on('mount', () => {
|
||||
if @message.text?
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
this.sending = false
|
||||
this.messages = []
|
||||
|
||||
this.connection = new @MessagingStreamConnection @I, @user.id
|
||||
this.connection = new @MessagingStreamConnection this.I, @user.id
|
||||
|
||||
this.on('mount', () => {
|
||||
@connection.event.on 'message' this.on-message
|
||||
@@ -169,7 +169,7 @@
|
||||
is-bottom = @is-bottom!
|
||||
|
||||
@messages.push message
|
||||
if message.user_id != @I.id and not document.hidden
|
||||
if message.user_id != this.I.id and not document.hidden
|
||||
@connection.socket.send JSON.stringify do
|
||||
type: 'read'
|
||||
id: message.id
|
||||
@@ -178,7 +178,7 @@
|
||||
if is-bottom
|
||||
// Scroll to bottom
|
||||
@scroll-to-bottom!
|
||||
else if message.user_id != @I.id
|
||||
else if message.user_id != this.I.id
|
||||
// Notify
|
||||
@notify '新しいメッセージがあります'
|
||||
|
||||
@@ -216,7 +216,7 @@
|
||||
on-visibilitychange() {
|
||||
if document.hidden then return
|
||||
@messages.for-each (message) =>
|
||||
if message.user_id != @I.id and not message.is_read
|
||||
if message.user_id != this.I.id and not message.is_read
|
||||
@connection.socket.send JSON.stringify do
|
||||
type: 'read'
|
||||
id: message.id
|
||||
|
||||
@@ -164,7 +164,7 @@
|
||||
reader.read-as-data-URL file
|
||||
|
||||
data = new FormData!
|
||||
data.append 'i' @I.token
|
||||
data.append 'i' this.I.token
|
||||
data.append 'file' file
|
||||
|
||||
if folder?
|
||||
|
||||
Reference in New Issue
Block a user