This commit is contained in:
syuilo 2017-02-20 10:04:11 +09:00
parent 204ad535c0
commit 3c3040783f
17 changed files with 60 additions and 59 deletions

View File

@ -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>

View File

@ -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>

View File

@ -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

View File

@ -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?

View File

@ -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

View File

@ -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?

View File

@ -54,11 +54,11 @@
e.prevent-default!
e.stop-propagation!
@I.data.no_donation = true
@I.update!
this.I.data.no_donation = true
this.I.update!
this.api 'i/appdata/set' do
data: JSON.stringify do
no_donation: @I.data.no_donation
no_donation: this.I.data.no_donation
this.unmount();

View File

@ -81,15 +81,15 @@
set-avatar() {
this.refs.ctx.close!
@update-avatar @I, null, @file
@update-avatar this.I, null, @file
set-banner() {
this.refs.ctx.close!
@update-banner @I, null, @file
@update-banner this.I, null, @file
set-wallpaper() {
this.refs.ctx.close!
@update-wallpaper @I, null, @file
@update-wallpaper this.I, null, @file
add-app() {
@NotImplementedException!

View File

@ -47,9 +47,9 @@
this.mixin('update-banner');
set-avatar() {
@update-avatar @I
@update-avatar this.I
set-banner() {
@update-banner @I
@update-banner this.I
</script>
</mk-profile-home-widget>

View File

@ -39,7 +39,7 @@
this.is-loading = true
this.is-empty = false
this.more-loading = false
this.no-following = @I.following_count == 0
this.no-following = this.I.following_count == 0
this.on('mount', () => {
@stream.on 'post' this.on-stream-post

View File

@ -70,7 +70,7 @@
this.refs.tl.on('loaded', () => {
this.trigger('loaded');
@I.data.home.for-each (widget) =>
this.I.data.home.for-each (widget) =>
try
el = document.createElement 'mk-' + widget.name + '-home-widget'
switch widget.place

View File

@ -35,7 +35,7 @@
document.remove-event-listener 'visibilitychange' @window-on-visibilitychange
on-stream-post(post) {
if document.hidden and post.user_id !== @I.id
if document.hidden and post.user_id !== this.I.id
@unread-count++
document.title = '(' + @unread-count + ') ' + @get-post-summary post

View File

@ -35,7 +35,7 @@
this.mixin('update-avatar');
set() {
@update-avatar @I
@update-avatar this.I
close(e) {
e.prevent-default!

View File

@ -35,7 +35,7 @@
this.mixin('update-banner');
set() {
@update-banner @I
@update-banner this.I
close(e) {
e.prevent-default!

View File

@ -209,7 +209,7 @@
this.page = page
avatar() {
@update-avatar @I
@update-avatar this.I
update-account() {
this.api 'i/update' do
@ -223,21 +223,21 @@
console.error err
update-cache() {
@I.data.cache = !@I.data.cache
this.I.data.cache = !this.I.data.cache
this.api 'i/appdata/set' do
data: JSON.stringify do
cache: @I.data.cache
cache: this.I.data.cache
update-debug() {
@I.data.debug = !@I.data.debug
this.I.data.debug = !this.I.data.debug
this.api 'i/appdata/set' do
data: JSON.stringify do
debug: @I.data.debug
debug: this.I.data.debug
update-nya() {
@I.data.nya = !@I.data.nya
this.I.data.nya = !this.I.data.nya
this.api 'i/appdata/set' do
data: JSON.stringify do
nya: @I.data.nya
nya: this.I.data.nya
</script>
</mk-settings>

View File

@ -132,10 +132,10 @@
this.refs.banner.style.filter = 'blur(' + blur + 'px)'
on-update-banner() {
if not @SIGNIN or @I.id != @user.id
if not @SIGNIN or this.I.id != @user.id
return
@update-banner @I, (i) =>
@update-banner this.I, (i) =>
@user.banner_url = i.banner_url
this.update();
</script>

View File

@ -33,7 +33,7 @@
document.remove-event-listener 'visibilitychange' @window-on-visibilitychange
on-stream-post(post) {
if document.hidden and post.user_id !== @I.id
if document.hidden and post.user_id !== this.I.id
@unread-count++
document.title = '(' + @unread-count + ') ' + @get-post-summary post