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 display inline
</style> </style>
<script> <script>
this.kind = this.opts.type.split '/' .0 this.kind = this.opts.type.split('/')[0];
</script> </script>
</mk-file-type-icon> </mk-file-type-icon>

View file

@ -150,23 +150,26 @@
event.one('selected', files => { event.one('selected', files => {
files.forEach(this.addFile); files.forEach(this.addFile);
}); });
}
send() { send() {
this.sending = true this.sending = true;
this.api 'messaging/messages/create' do this.api('messaging/messages/create', {
user_id: this.opts.user.id user_id: this.opts.user.id,
text: this.refs.text.value text: this.refs.text.value
.then (message) => }).then(message => {
@clear! this.clear();
.catch (err) => }).catch(err => {
console.error err console.error(err);
.then => }).then(() => {
this.sending = false this.sending = false;
this.update(); this.update();
});
clear() { clear() {
this.refs.text.value = '' this.refs.text.value = '';
this.files = [] this.files = [];
this.update(); this.update();
}
</script> </script>
</mk-messaging-form> </mk-messaging-form>

View file

@ -289,29 +289,27 @@
this.mixin('i'); this.mixin('i');
this.mixin('api'); this.mixin('api');
this.search-result = [] this.searchResult = [];
this.on('mount', () => { this.on('mount', () => {
this.api 'messaging/history' this.api('messaging/history').then(history => {
.then (history) => this.isLoading = false;
this.is-loading = false history.forEach(message => {
history.for-each (message) => message.is_me = message.user_id == this.I.id
message.is_me = message.user_id == @I.id message._click = () => {
message._click = => this.trigger('navigate-user', message.is_me ? message.recipient : message.user);
if message.is_me };
this.trigger 'navigate-user' message.recipient });
else this.history = history;
this.trigger 'navigate-user' message.user
this.history = history
this.update(); this.update();
.catch (err) => });
console.error err }
search() { search() {
q = this.refs.search.value const q = this.refs.search.value;
if q == '' if (q == '') {
this.search-result = [] this.searchResult = [];
else } else {
this.api 'users/search' do this.api 'users/search' do
query: q query: q
max: 5 max: 5

View file

@ -207,7 +207,7 @@
this.mixin('text'); this.mixin('text');
this.message = this.opts.message 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', () => { this.on('mount', () => {
if @message.text? if @message.text?

View file

@ -133,7 +133,7 @@
this.sending = false this.sending = false
this.messages = [] this.messages = []
this.connection = new @MessagingStreamConnection @I, @user.id this.connection = new @MessagingStreamConnection this.I, @user.id
this.on('mount', () => { this.on('mount', () => {
@connection.event.on 'message' this.on-message @connection.event.on 'message' this.on-message
@ -169,7 +169,7 @@
is-bottom = @is-bottom! is-bottom = @is-bottom!
@messages.push message @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 @connection.socket.send JSON.stringify do
type: 'read' type: 'read'
id: message.id id: message.id
@ -178,7 +178,7 @@
if is-bottom if is-bottom
// Scroll to bottom // Scroll to bottom
@scroll-to-bottom! @scroll-to-bottom!
else if message.user_id != @I.id else if message.user_id != this.I.id
// Notify // Notify
@notify '新しいメッセージがあります' @notify '新しいメッセージがあります'
@ -216,7 +216,7 @@
on-visibilitychange() { on-visibilitychange() {
if document.hidden then return if document.hidden then return
@messages.for-each (message) => @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 @connection.socket.send JSON.stringify do
type: 'read' type: 'read'
id: message.id id: message.id

View file

@ -164,7 +164,7 @@
reader.read-as-data-URL file reader.read-as-data-URL file
data = new FormData! data = new FormData!
data.append 'i' @I.token data.append 'i' this.I.token
data.append 'file' file data.append 'file' file
if folder? if folder?

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -35,7 +35,7 @@
document.remove-event-listener 'visibilitychange' @window-on-visibilitychange document.remove-event-listener 'visibilitychange' @window-on-visibilitychange
on-stream-post(post) { 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++ @unread-count++
document.title = '(' + @unread-count + ') ' + @get-post-summary post document.title = '(' + @unread-count + ') ' + @get-post-summary post

View file

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

View file

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

View file

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

View file

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

View file

@ -33,7 +33,7 @@
document.remove-event-listener 'visibilitychange' @window-on-visibilitychange document.remove-event-listener 'visibilitychange' @window-on-visibilitychange
on-stream-post(post) { 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++ @unread-count++
document.title = '(' + @unread-count + ') ' + @get-post-summary post document.title = '(' + @unread-count + ') ' + @get-post-summary post