wip
This commit is contained in:
@@ -62,7 +62,7 @@ export default Vue.extend({
|
||||
|
||||
send() {
|
||||
this.sending = true;
|
||||
this.$root.$data.os.api('messaging/messages/create', {
|
||||
(this as any).api('messaging/messages/create', {
|
||||
user_id: this.user.id,
|
||||
text: this.text
|
||||
}).then(message => {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<p class="read" v-if="message.is_me && message.is_read">%i18n:common.tags.mk-messaging-message.is-read%</p>
|
||||
<button class="delete-button" v-if="message.is_me" title="%i18n:common.delete%"><img src="/assets/desktop/messaging/delete.png" alt="Delete"/></button>
|
||||
<div class="content" v-if="!message.is_deleted">
|
||||
<mk-post-html v-if="message.ast" :ast="message.ast" :i="$root.$data.os.i"/>
|
||||
<mk-post-html v-if="message.ast" :ast="message.ast" :i="os.i"/>
|
||||
<mk-url-preview v-for="url in urls" :url="url" :key="url"/>
|
||||
<div class="image" v-if="message.file"><img src={ message.file.url } alt="image" title={ message.file.name }/></div>
|
||||
</div>
|
||||
@@ -30,7 +30,7 @@ export default Vue.extend({
|
||||
props: ['message'],
|
||||
computed: {
|
||||
isMe(): boolean {
|
||||
return this.message.user_id == this.$root.$data.os.i.id;
|
||||
return this.message.user_id == (this as any).os.i.id;
|
||||
},
|
||||
urls(): string[] {
|
||||
if (this.message.ast) {
|
||||
|
||||
@@ -48,7 +48,7 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.connection = new MessagingStreamConnection(this.$root.$data.os.i, this.user.id);
|
||||
this.connection = new MessagingStreamConnection((this as any).os.i, this.user.id);
|
||||
|
||||
this.connection.on('message', this.onMessage);
|
||||
this.connection.on('read', this.onRead);
|
||||
@@ -72,7 +72,7 @@ export default Vue.extend({
|
||||
return new Promise((resolve, reject) => {
|
||||
const max = this.existMoreMessages ? 20 : 10;
|
||||
|
||||
this.$root.$data.os.api('messaging/messages', {
|
||||
(this as any).api('messaging/messages', {
|
||||
user_id: this.user.id,
|
||||
limit: max + 1,
|
||||
until_id: this.existMoreMessages ? this.messages[0].id : undefined
|
||||
@@ -99,7 +99,7 @@ export default Vue.extend({
|
||||
const isBottom = this.isBottom();
|
||||
|
||||
this.messages.push(message);
|
||||
if (message.user_id != this.$root.$data.os.i.id && !document.hidden) {
|
||||
if (message.user_id != (this as any).os.i.id && !document.hidden) {
|
||||
this.connection.send({
|
||||
type: 'read',
|
||||
id: message.id
|
||||
@@ -109,7 +109,7 @@ export default Vue.extend({
|
||||
if (isBottom) {
|
||||
// Scroll to bottom
|
||||
this.scrollToBottom();
|
||||
} else if (message.user_id != this.$root.$data.os.i.id) {
|
||||
} else if (message.user_id != (this as any).os.i.id) {
|
||||
// Notify
|
||||
this.notify('%i18n:common.tags.mk-messaging-room.new-message%');
|
||||
}
|
||||
@@ -157,7 +157,7 @@ export default Vue.extend({
|
||||
onVisibilitychange() {
|
||||
if (document.hidden) return;
|
||||
this.messages.forEach(message => {
|
||||
if (message.user_id !== this.$root.$data.os.i.id && !message.is_read) {
|
||||
if (message.user_id !== (this as any).os.i.id && !message.is_read) {
|
||||
this.connection.send({
|
||||
type: 'read',
|
||||
id: message.id
|
||||
|
||||
@@ -71,13 +71,13 @@ export default Vue.extend({
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.connection = this.$root.$data.os.streams.messagingIndexStream.getConnection();
|
||||
this.connectionId = this.$root.$data.os.streams.messagingIndexStream.use();
|
||||
this.connection = (this as any).os.streams.messagingIndexStream.getConnection();
|
||||
this.connectionId = (this as any).os.streams.messagingIndexStream.use();
|
||||
|
||||
this.connection.on('message', this.onMessage);
|
||||
this.connection.on('read', this.onRead);
|
||||
|
||||
this.$root.$data.os.api('messaging/history').then(messages => {
|
||||
(this as any).api('messaging/history').then(messages => {
|
||||
this.fetching = false;
|
||||
this.messages = messages;
|
||||
});
|
||||
@@ -85,11 +85,11 @@ export default Vue.extend({
|
||||
beforeDestroy() {
|
||||
this.connection.off('message', this.onMessage);
|
||||
this.connection.off('read', this.onRead);
|
||||
this.$root.$data.os.stream.dispose(this.connectionId);
|
||||
(this as any).os.stream.dispose(this.connectionId);
|
||||
},
|
||||
methods: {
|
||||
isMe(message) {
|
||||
return message.user_id == this.$root.$data.os.i.id;
|
||||
return message.user_id == (this as any).os.i.id;
|
||||
},
|
||||
onMessage(message) {
|
||||
this.messages = this.messages.filter(m => !(
|
||||
@@ -109,7 +109,7 @@ export default Vue.extend({
|
||||
this.result = [];
|
||||
return;
|
||||
}
|
||||
this.$root.$data.os.api('users/search', {
|
||||
(this as any).api('users/search', {
|
||||
query: this.q,
|
||||
max: 5
|
||||
}).then(users => {
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
},
|
||||
vote(id) {
|
||||
if (this.poll.choices.some(c => c.is_voted)) return;
|
||||
this.$root.$data.os.api('posts/polls/vote', {
|
||||
(this as any).api('posts/polls/vote', {
|
||||
post_id: this.post.id,
|
||||
choice: id
|
||||
}).then(() => {
|
||||
|
||||
@@ -48,7 +48,7 @@ export default Vue.extend({
|
||||
},
|
||||
methods: {
|
||||
pin() {
|
||||
this.$root.$data.os.api('i/pin', {
|
||||
(this as any).api('i/pin', {
|
||||
post_id: this.post.id
|
||||
}).then(() => {
|
||||
this.$destroy();
|
||||
|
||||
@@ -68,7 +68,7 @@ export default Vue.extend({
|
||||
},
|
||||
methods: {
|
||||
react(reaction) {
|
||||
this.$root.$data.os.api('posts/reactions/create', {
|
||||
(this as any).api('posts/reactions/create', {
|
||||
post_id: this.post.id,
|
||||
reaction: reaction
|
||||
}).then(() => {
|
||||
|
||||
@@ -28,7 +28,7 @@ export default Vue.extend({
|
||||
},
|
||||
methods: {
|
||||
onUsernameChange() {
|
||||
this.$root.$data.os.api('users/show', {
|
||||
(this as any).api('users/show', {
|
||||
username: this.username
|
||||
}).then(user => {
|
||||
this.user = user;
|
||||
@@ -37,7 +37,7 @@ export default Vue.extend({
|
||||
onSubmit() {
|
||||
this.signing = true;
|
||||
|
||||
this.$root.$data.os.api('signin', {
|
||||
(this as any).api('signin', {
|
||||
username: this.username,
|
||||
password: this.password,
|
||||
token: this.user && this.user.two_factor_enabled ? this.token : undefined
|
||||
|
||||
@@ -88,7 +88,7 @@ export default Vue.extend({
|
||||
|
||||
this.usernameState = 'wait';
|
||||
|
||||
this.$root.$data.os.api('username/available', {
|
||||
(this as any).api('username/available', {
|
||||
username: this.username
|
||||
}).then(result => {
|
||||
this.usernameState = result.available ? 'ok' : 'unavailable';
|
||||
@@ -115,12 +115,12 @@ export default Vue.extend({
|
||||
this.passwordRetypeState = this.password == this.retypedPassword ? 'match' : 'not-match';
|
||||
},
|
||||
onSubmit() {
|
||||
this.$root.$data.os.api('signup', {
|
||||
(this as any).api('signup', {
|
||||
username: this.username,
|
||||
password: this.password,
|
||||
'g-recaptcha-response': (window as any).grecaptcha.getResponse()
|
||||
}).then(() => {
|
||||
this.$root.$data.os.api('signin', {
|
||||
(this as any).api('signin', {
|
||||
username: this.username,
|
||||
password: this.password
|
||||
}).then(() => {
|
||||
|
||||
@@ -26,10 +26,10 @@ export default Vue.extend({
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.stream = this.$root.$data.os.stream.borrow();
|
||||
this.stream = (this as any).os.stream.borrow();
|
||||
|
||||
this.$root.$data.os.stream.on('connected', this.onConnected);
|
||||
this.$root.$data.os.stream.on('disconnected', this.onDisconnected);
|
||||
(this as any).os.stream.on('connected', this.onConnected);
|
||||
(this as any).os.stream.on('disconnected', this.onDisconnected);
|
||||
|
||||
this.$nextTick(() => {
|
||||
if (this.stream.state == 'connected') {
|
||||
@@ -38,12 +38,12 @@ export default Vue.extend({
|
||||
});
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$root.$data.os.stream.off('connected', this.onConnected);
|
||||
this.$root.$data.os.stream.off('disconnected', this.onDisconnected);
|
||||
(this as any).os.stream.off('connected', this.onConnected);
|
||||
(this as any).os.stream.off('disconnected', this.onDisconnected);
|
||||
},
|
||||
methods: {
|
||||
onConnected() {
|
||||
this.stream = this.$root.$data.os.stream.borrow();
|
||||
this.stream = (this as any).os.stream.borrow();
|
||||
|
||||
setTimeout(() => {
|
||||
anime({
|
||||
|
||||
@@ -50,7 +50,7 @@ export default Vue.extend({
|
||||
reader.readAsDataURL(file);
|
||||
|
||||
const data = new FormData();
|
||||
data.append('i', this.$root.$data.os.i.token);
|
||||
data.append('i', (this as any).os.i.token);
|
||||
data.append('file', file);
|
||||
|
||||
if (folder) data.append('folder_id', folder);
|
||||
|
||||
@@ -26,12 +26,12 @@ export default define({
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.connection = this.$root.$data.os.stream.getConnection();
|
||||
this.connectionId = this.$root.$data.os.stream.use();
|
||||
this.connection = (this as any).os.stream.getConnection();
|
||||
this.connectionId = (this as any).os.stream.use();
|
||||
|
||||
this.connection.on('drive_file_created', this.onDriveFileCreated);
|
||||
|
||||
this.$root.$data.os.api('drive/stream', {
|
||||
(this as any).api('drive/stream', {
|
||||
type: 'image/*',
|
||||
limit: 9
|
||||
}).then(images => {
|
||||
@@ -41,7 +41,7 @@ export default define({
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.connection.off('drive_file_created', this.onDriveFileCreated);
|
||||
this.$root.$data.os.stream.dispose(this.connectionId);
|
||||
(this as any).os.stream.dispose(this.connectionId);
|
||||
},
|
||||
methods: {
|
||||
onDriveFileCreated(file) {
|
||||
|
||||
@@ -89,7 +89,7 @@ export default define({
|
||||
fetch() {
|
||||
this.fetching = true;
|
||||
|
||||
this.$root.$data.os.api('drive/files', {
|
||||
(this as any).api('drive/files', {
|
||||
folder_id: this.props.folder,
|
||||
type: 'image/*',
|
||||
limit: 100
|
||||
@@ -102,7 +102,7 @@ export default define({
|
||||
});
|
||||
},
|
||||
choose() {
|
||||
this.$root.$data.api.chooseDriveFolder().then(folder => {
|
||||
(this as any).apis.chooseDriveFolder().then(folder => {
|
||||
this.props.folder = folder ? folder.id : null;
|
||||
this.fetch();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user