Refactor & Clean up
This commit is contained in:
@@ -54,7 +54,7 @@ export default Vue.extend({
|
||||
title: this.$t('enter-password'),
|
||||
type: 'password'
|
||||
}).then(password => {
|
||||
(this as any).api('i/regenerate_token', {
|
||||
this.$root.api('i/regenerate_token', {
|
||||
password: password
|
||||
});
|
||||
});
|
||||
@@ -62,7 +62,7 @@ export default Vue.extend({
|
||||
|
||||
send() {
|
||||
this.sending = true;
|
||||
(this as any).api(this.endpoint, JSON5.parse(this.body)).then(res => {
|
||||
this.$root.api(this.endpoint, JSON5.parse(this.body)).then(res => {
|
||||
this.sending = false;
|
||||
this.res = JSON5.stringify(res, null, 2);
|
||||
}, err => {
|
||||
|
@@ -114,7 +114,7 @@ export default Vue.extend({
|
||||
|
||||
mounted() {
|
||||
//#region Construct Emoji DB
|
||||
const customEmojis = (this.os.getMetaSync() || { emojis: [] }).emojis || [];
|
||||
const customEmojis = (this.$root.getMetaSync() || { emojis: [] }).emojis || [];
|
||||
const emojiDefinitions: EmojiDef[] = [];
|
||||
|
||||
customEmojis.forEach(x => {
|
||||
@@ -185,7 +185,7 @@ export default Vue.extend({
|
||||
this.users = users;
|
||||
this.fetching = false;
|
||||
} else {
|
||||
(this as any).api('users/search', {
|
||||
this.$root.api('users/search', {
|
||||
query: this.q,
|
||||
limit: 30
|
||||
}).then(users => {
|
||||
@@ -208,7 +208,7 @@ export default Vue.extend({
|
||||
this.hashtags = hashtags;
|
||||
this.fetching = false;
|
||||
} else {
|
||||
(this as any).api('hashtags/search', {
|
||||
this.$root.api('hashtags/search', {
|
||||
query: this.q,
|
||||
limit: 30
|
||||
}).then(hashtags => {
|
||||
|
@@ -44,7 +44,7 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
mounted() {
|
||||
(this as any).api('drive').then(info => {
|
||||
this.$root.api('drive').then(info => {
|
||||
this.capacity = info.capacity;
|
||||
this.usage = info.usage;
|
||||
this.fetching = false;
|
||||
@@ -57,7 +57,7 @@ export default Vue.extend({
|
||||
|
||||
methods: {
|
||||
renderChart() {
|
||||
(this as any).api('charts/user/drive', {
|
||||
this.$root.api('charts/user/drive', {
|
||||
userId: this.$store.state.i.id,
|
||||
span: 'day',
|
||||
limit: 21
|
||||
|
@@ -291,7 +291,7 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
surrender() {
|
||||
(this as any).api('games/reversi/games/surrender', {
|
||||
this.$root.api('games/reversi/games/surrender', {
|
||||
gameId: this.game.id
|
||||
});
|
||||
},
|
||||
|
@@ -35,7 +35,7 @@ export default Vue.extend({
|
||||
},
|
||||
created() {
|
||||
this.g = this.game;
|
||||
this.connection = (this as any).os.stream.connectToChannel('gamesReversiGame', {
|
||||
this.connection = this.$root.stream.connectToChannel('gamesReversiGame', {
|
||||
gameId: this.game.id
|
||||
});
|
||||
this.connection.on('started', this.onStarted);
|
||||
|
@@ -67,22 +67,22 @@ export default Vue.extend({
|
||||
|
||||
mounted() {
|
||||
if (this.$store.getters.isSignedIn) {
|
||||
this.connection = (this as any).os.stream.useSharedConnection('gamesReversi');
|
||||
this.connection = this.$root.stream.useSharedConnection('gamesReversi');
|
||||
|
||||
this.connection.on('invited', this.onInvited);
|
||||
|
||||
(this as any).api('games/reversi/games', {
|
||||
this.$root.api('games/reversi/games', {
|
||||
my: true
|
||||
}).then(games => {
|
||||
this.myGames = games;
|
||||
});
|
||||
|
||||
(this as any).api('games/reversi/invitations').then(invitations => {
|
||||
this.$root.api('games/reversi/invitations').then(invitations => {
|
||||
this.invitations = this.invitations.concat(invitations);
|
||||
});
|
||||
}
|
||||
|
||||
(this as any).api('games/reversi/games').then(games => {
|
||||
this.$root.api('games/reversi/games').then(games => {
|
||||
this.games = games;
|
||||
this.gamesFetching = false;
|
||||
});
|
||||
@@ -103,10 +103,10 @@ export default Vue.extend({
|
||||
(this as any).apis.input({
|
||||
title: this.$t('enter-username')
|
||||
}).then(username => {
|
||||
(this as any).api('users/show', {
|
||||
this.$root.api('users/show', {
|
||||
username
|
||||
}).then(user => {
|
||||
(this as any).api('games/reversi/match', {
|
||||
this.$root.api('games/reversi/match', {
|
||||
userId: user.id
|
||||
}).then(res => {
|
||||
if (res == null) {
|
||||
@@ -120,7 +120,7 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
accept(invitation) {
|
||||
(this as any).api('games/reversi/match', {
|
||||
this.$root.api('games/reversi/match', {
|
||||
userId: invitation.parent.id
|
||||
}).then(game => {
|
||||
if (game) {
|
||||
|
@@ -67,7 +67,7 @@ export default Vue.extend({
|
||||
this.fetch();
|
||||
|
||||
if (this.$store.getters.isSignedIn) {
|
||||
this.connection = (this as any).os.stream.useSharedConnection('gamesReversi');
|
||||
this.connection = this.$root.stream.useSharedConnection('gamesReversi');
|
||||
|
||||
this.connection.on('matched', this.onMatched);
|
||||
|
||||
@@ -94,7 +94,7 @@ export default Vue.extend({
|
||||
this.game = null;
|
||||
} else {
|
||||
Progress.start();
|
||||
(this as any).api('games/reversi/games/show', {
|
||||
this.$root.api('games/reversi/games/show', {
|
||||
gameId: this.gameId
|
||||
}).then(game => {
|
||||
this.game = game;
|
||||
@@ -107,7 +107,7 @@ export default Vue.extend({
|
||||
if (this.selfNav) {
|
||||
// 受け取ったゲーム情報が省略されたものなら完全な情報を取得する
|
||||
if (game != null && (game.settings == null || game.settings.map == null)) {
|
||||
game = await (this as any).api('games/reversi/games/show', {
|
||||
game = await this.$root.api('games/reversi/games/show', {
|
||||
gameId: game.id
|
||||
});
|
||||
}
|
||||
@@ -124,11 +124,11 @@ export default Vue.extend({
|
||||
|
||||
cancel() {
|
||||
this.matching = null;
|
||||
(this as any).api('games/reversi/match/cancel');
|
||||
this.$root.api('games/reversi/match/cancel');
|
||||
},
|
||||
|
||||
accept(invitation) {
|
||||
(this as any).api('games/reversi/match', {
|
||||
this.$root.api('games/reversi/match', {
|
||||
userId: invitation.parent.id
|
||||
}).then(game => {
|
||||
if (game) {
|
||||
|
@@ -20,7 +20,7 @@ export default Vue.extend({
|
||||
}
|
||||
},
|
||||
created() {
|
||||
(this as any).os.getMeta().then(meta => {
|
||||
this.$root.getMeta().then(meta => {
|
||||
this.meta = meta;
|
||||
});
|
||||
}
|
||||
|
@@ -152,7 +152,7 @@ export default Vue.extend({
|
||||
|
||||
send() {
|
||||
this.sending = true;
|
||||
(this as any).api('messaging/messages/create', {
|
||||
this.$root.api('messaging/messages/create', {
|
||||
userId: this.user.id,
|
||||
text: this.text ? this.text : undefined,
|
||||
fileId: this.file ? this.file.id : undefined
|
||||
|
@@ -73,7 +73,7 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.connection = (this as any).os.stream.connectToChannel('messaging', { otherparty: this.user.id });
|
||||
this.connection = this.$root.stream.connectToChannel('messaging', { otherparty: this.user.id });
|
||||
|
||||
this.connection.on('message', this.onMessage);
|
||||
this.connection.on('read', this.onRead);
|
||||
@@ -139,7 +139,7 @@ export default Vue.extend({
|
||||
return new Promise((resolve, reject) => {
|
||||
const max = this.existMoreMessages ? 20 : 10;
|
||||
|
||||
(this as any).api('messaging/messages', {
|
||||
this.$root.api('messaging/messages', {
|
||||
userId: this.user.id,
|
||||
limit: max + 1,
|
||||
untilId: this.existMoreMessages ? this.messages[0].id : undefined
|
||||
|
@@ -77,12 +77,12 @@ export default Vue.extend({
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.connection = (this as any).os.stream.useSharedConnection('messagingIndex');
|
||||
this.connection = this.$root.stream.useSharedConnection('messagingIndex');
|
||||
|
||||
this.connection.on('message', this.onMessage);
|
||||
this.connection.on('read', this.onRead);
|
||||
|
||||
(this as any).api('messaging/history').then(messages => {
|
||||
this.$root.api('messaging/history').then(messages => {
|
||||
this.messages = messages;
|
||||
this.fetching = false;
|
||||
});
|
||||
@@ -113,7 +113,7 @@ export default Vue.extend({
|
||||
this.result = [];
|
||||
return;
|
||||
}
|
||||
(this as any).api('users/search', {
|
||||
this.$root.api('users/search', {
|
||||
query: this.q,
|
||||
max: 5
|
||||
}).then(users => {
|
||||
|
@@ -187,7 +187,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||
}
|
||||
|
||||
case 'emoji': {
|
||||
const customEmojis = (this.os.getMetaSync() || { emojis: [] }).emojis || [];
|
||||
const customEmojis = (this.$root.getMetaSync() || { emojis: [] }).emojis || [];
|
||||
return [createElement('mk-emoji', {
|
||||
attrs: {
|
||||
emoji: token.emoji,
|
||||
|
@@ -40,12 +40,12 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
mounted() {
|
||||
(this as any).api('mute/list').then(mute => {
|
||||
this.$root.api('mute/list').then(mute => {
|
||||
this.mute = mute.map(x => x.mutee);
|
||||
this.muteFetching = false;
|
||||
});
|
||||
|
||||
(this as any).api('blocking/list').then(blocking => {
|
||||
this.$root.api('blocking/list').then(blocking => {
|
||||
this.block = blocking.map(x => x.blockee);
|
||||
this.blockFetching = false;
|
||||
});
|
||||
|
@@ -25,7 +25,7 @@ export default Vue.extend({
|
||||
}
|
||||
},
|
||||
created() {
|
||||
(this as any).os.getMeta().then(meta => {
|
||||
this.$root.getMeta().then(meta => {
|
||||
if (meta.maintainer.repository_url) this.repositoryUrl = meta.maintainer.repository_url;
|
||||
if (meta.maintainer.feedback_url) this.feedbackUrl = meta.maintainer.feedback_url;
|
||||
});
|
||||
|
@@ -91,16 +91,16 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
pin() {
|
||||
(this as any).api('i/pin', {
|
||||
this.$root.api('i/pin', {
|
||||
noteId: this.note.id
|
||||
}).then(() => {
|
||||
(this as any).os.new(Ok);
|
||||
this.$root.new(Ok);
|
||||
this.destroyDom();
|
||||
});
|
||||
},
|
||||
|
||||
unpin() {
|
||||
(this as any).api('i/unpin', {
|
||||
this.$root.api('i/unpin', {
|
||||
noteId: this.note.id
|
||||
}).then(() => {
|
||||
this.destroyDom();
|
||||
@@ -109,7 +109,7 @@ export default Vue.extend({
|
||||
|
||||
del() {
|
||||
if (!window.confirm(this.$t('delete-confirm'))) return;
|
||||
(this as any).api('notes/delete', {
|
||||
this.$root.api('notes/delete', {
|
||||
noteId: this.note.id
|
||||
}).then(() => {
|
||||
this.destroyDom();
|
||||
@@ -117,19 +117,19 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
favorite() {
|
||||
(this as any).api('notes/favorites/create', {
|
||||
this.$root.api('notes/favorites/create', {
|
||||
noteId: this.note.id
|
||||
}).then(() => {
|
||||
(this as any).os.new(Ok);
|
||||
this.$root.new(Ok);
|
||||
this.destroyDom();
|
||||
});
|
||||
},
|
||||
|
||||
unfavorite() {
|
||||
(this as any).api('notes/favorites/delete', {
|
||||
this.$root.api('notes/favorites/delete', {
|
||||
noteId: this.note.id
|
||||
}).then(() => {
|
||||
(this as any).os.new(Ok);
|
||||
this.$root.new(Ok);
|
||||
this.destroyDom();
|
||||
});
|
||||
},
|
||||
|
@@ -34,7 +34,7 @@ export default Vue.extend({
|
||||
});
|
||||
return;
|
||||
}
|
||||
(this as any).api('i/change_password', {
|
||||
this.$root.api('i/change_password', {
|
||||
currentPasword: currentPassword,
|
||||
newPassword: newPassword
|
||||
}).then(() => {
|
||||
|
@@ -51,7 +51,7 @@ export default Vue.extend({
|
||||
},
|
||||
vote(id) {
|
||||
if (this.poll.choices.some(c => c.isVoted)) return;
|
||||
(this as any).api('notes/polls/vote', {
|
||||
this.$root.api('notes/polls/vote', {
|
||||
noteId: this.note.id,
|
||||
choice: id
|
||||
}).then(() => {
|
||||
|
@@ -95,7 +95,7 @@ export default Vue.extend({
|
||||
computed: {
|
||||
alwaysMarkNsfw: {
|
||||
get() { return this.$store.state.i.settings.alwaysMarkNsfw; },
|
||||
set(value) { (this as any).api('i/update', { alwaysMarkNsfw: value }); }
|
||||
set(value) { this.$root.api('i/update', { alwaysMarkNsfw: value }); }
|
||||
},
|
||||
},
|
||||
|
||||
@@ -161,7 +161,7 @@ export default Vue.extend({
|
||||
save(notify) {
|
||||
this.saving = true;
|
||||
|
||||
(this as any).api('i/update', {
|
||||
this.$root.api('i/update', {
|
||||
name: this.name || null,
|
||||
location: this.location || null,
|
||||
description: this.description || null,
|
||||
|
@@ -145,7 +145,7 @@ export default Vue.extend({
|
||||
|
||||
methods: {
|
||||
react(reaction) {
|
||||
(this as any).api('notes/reactions/create', {
|
||||
this.$root.api('notes/reactions/create', {
|
||||
noteId: this.note.id,
|
||||
reaction: reaction
|
||||
}).then(() => {
|
||||
|
@@ -27,7 +27,7 @@ export default Vue.extend({
|
||||
},
|
||||
methods: {
|
||||
react(reaction: string) {
|
||||
(this as any).api('notes/reactions/create', {
|
||||
this.$root.api('notes/reactions/create', {
|
||||
noteId: this.note.id,
|
||||
reaction: reaction
|
||||
});
|
||||
|
@@ -44,7 +44,7 @@ export default Vue.extend({
|
||||
},
|
||||
methods: {
|
||||
onUsernameChange() {
|
||||
(this as any).api('users/show', {
|
||||
this.$root.api('users/show', {
|
||||
username: this.username
|
||||
}).then(user => {
|
||||
this.user = user;
|
||||
@@ -55,7 +55,7 @@ export default Vue.extend({
|
||||
onSubmit() {
|
||||
this.signing = true;
|
||||
|
||||
(this as any).api('signin', {
|
||||
this.$root.api('signin', {
|
||||
username: this.username,
|
||||
password: this.password,
|
||||
token: this.user && this.user.twoFactorEnabled ? this.token : undefined
|
||||
|
@@ -72,7 +72,7 @@ export default Vue.extend({
|
||||
}
|
||||
},
|
||||
created() {
|
||||
(this as any).os.getMeta().then(meta => {
|
||||
this.$root.getMeta().then(meta => {
|
||||
this.meta = meta;
|
||||
});
|
||||
},
|
||||
@@ -102,7 +102,7 @@ export default Vue.extend({
|
||||
|
||||
this.usernameState = 'wait';
|
||||
|
||||
(this as any).api('username/available', {
|
||||
this.$root.api('username/available', {
|
||||
username: this.username
|
||||
}).then(result => {
|
||||
this.usernameState = result.available ? 'ok' : 'unavailable';
|
||||
@@ -128,13 +128,13 @@ export default Vue.extend({
|
||||
this.passwordRetypeState = this.password == this.retypedPassword ? 'match' : 'not-match';
|
||||
},
|
||||
onSubmit() {
|
||||
(this as any).api('signup', {
|
||||
this.$root.api('signup', {
|
||||
username: this.username,
|
||||
password: this.password,
|
||||
invitationCode: this.invitationCode,
|
||||
'g-recaptcha-response': this.meta.enableRecaptcha ? (window as any).grecaptcha.getResponse() : null
|
||||
}, true).then(() => {
|
||||
(this as any).api('signin', {
|
||||
this.$root.api('signin', {
|
||||
username: this.username,
|
||||
password: this.password
|
||||
}, true).then(() => {
|
||||
|
@@ -24,12 +24,12 @@ export default Vue.extend({
|
||||
i18n: i18n('common/views/components/stream-indicator.vue'),
|
||||
computed: {
|
||||
stream() {
|
||||
return (this as any).os.stream;
|
||||
return this.$root.stream;
|
||||
}
|
||||
},
|
||||
created() {
|
||||
(this as any).os.stream.on('_connected_', this.onConnected);
|
||||
(this as any).os.stream.on('_disconnected_', this.onDisconnected);
|
||||
this.$root.stream.on('_connected_', this.onConnected);
|
||||
this.$root.stream.on('_disconnected_', this.onDisconnected);
|
||||
|
||||
this.$nextTick(() => {
|
||||
if (this.stream.state == 'connected') {
|
||||
@@ -38,8 +38,8 @@ export default Vue.extend({
|
||||
});
|
||||
},
|
||||
beforeDestroy() {
|
||||
(this as any).os.stream.off('_connected_', this.onConnected);
|
||||
(this as any).os.stream.off('_disconnected_', this.onDisconnected);
|
||||
this.$root.stream.off('_connected_', this.onConnected);
|
||||
this.$root.stream.off('_disconnected_', this.onDisconnected);
|
||||
},
|
||||
methods: {
|
||||
onConnected() {
|
||||
|
@@ -43,7 +43,7 @@ export default Vue.extend({
|
||||
},
|
||||
methods: {
|
||||
fetch() {
|
||||
(this as any).api('aggregation/hashtags').then(tags => {
|
||||
this.$root.api('aggregation/hashtags').then(tags => {
|
||||
this.tags = tags;
|
||||
this.fetching = false;
|
||||
});
|
||||
|
@@ -41,7 +41,7 @@ export default Vue.extend({
|
||||
},
|
||||
methods: {
|
||||
fetch() {
|
||||
(this as any).api('hashtags/trend').then(stats => {
|
||||
this.$root.api('hashtags/trend').then(stats => {
|
||||
this.stats = stats;
|
||||
this.fetching = false;
|
||||
});
|
||||
|
@@ -36,7 +36,7 @@ export default Vue.extend({
|
||||
const data = new FormData();
|
||||
data.append('md5', getMD5(fileData));
|
||||
|
||||
(this as any).api('drive/files/check_existence', {
|
||||
this.$root.api('drive/files/check_existence', {
|
||||
md5: getMD5(fileData)
|
||||
}).then(resp => {
|
||||
resolve(resp.file);
|
||||
|
@@ -45,7 +45,7 @@ export default Vue.extend({
|
||||
mounted() {
|
||||
this.fetch();
|
||||
|
||||
this.connection = (this as any).os.stream.useSharedConnection('localTimeline');
|
||||
this.connection = this.$root.stream.useSharedConnection('localTimeline');
|
||||
|
||||
this.connection.on('note', this.onNote);
|
||||
},
|
||||
@@ -57,7 +57,7 @@ export default Vue.extend({
|
||||
methods: {
|
||||
fetch(cb?) {
|
||||
this.fetching = true;
|
||||
(this as any).api('notes', {
|
||||
this.$root.api('notes', {
|
||||
limit: this.max,
|
||||
local: true,
|
||||
reply: false,
|
||||
|
Reference in New Issue
Block a user