From 60ef3e3563c95008bde52818a7d638d1d8ff9b19 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 9 Nov 2018 08:13:34 +0900 Subject: [PATCH] Refactor & Clean up --- locales/ja-JP.yml | 8 --- src/client/app/admin/views/announcements.vue | 4 +- src/client/app/admin/views/ap-log.vue | 2 +- src/client/app/admin/views/charts.vue | 20 +++---- src/client/app/admin/views/cpu-memory.vue | 2 +- src/client/app/admin/views/dashboard.vue | 6 +- src/client/app/admin/views/emoji.vue | 8 +-- src/client/app/admin/views/hashtags.vue | 8 +-- src/client/app/admin/views/instance.vue | 6 +- src/client/app/admin/views/users.vue | 32 +++++----- src/client/app/app.styl | 7 --- src/client/app/auth/views/form.vue | 4 +- src/client/app/auth/views/index.vue | 4 +- src/client/app/common/scripts/note-mixin.ts | 12 ++-- .../app/common/scripts/note-subscriber.ts | 2 +- .../common/views/components/api-settings.vue | 4 +- .../common/views/components/autocomplete.vue | 6 +- .../views/components/drive-settings.vue | 4 +- .../components/games/reversi/reversi.game.vue | 2 +- .../games/reversi/reversi.gameroom.vue | 2 +- .../games/reversi/reversi.index.vue | 14 ++--- .../components/games/reversi/reversi.vue | 10 ++-- .../app/common/views/components/instance.vue | 2 +- .../views/components/messaging-room.form.vue | 2 +- .../views/components/messaging-room.vue | 4 +- .../app/common/views/components/messaging.vue | 6 +- .../components/misskey-flavored-markdown.ts | 2 +- .../views/components/mute-and-block.vue | 4 +- .../app/common/views/components/nav.vue | 2 +- .../app/common/views/components/note-menu.vue | 16 ++--- .../views/components/password-settings.vue | 2 +- .../app/common/views/components/poll.vue | 2 +- .../views/components/profile-editor.vue | 4 +- .../views/components/reaction-picker.vue | 2 +- .../views/components/reactions-viewer.vue | 2 +- .../app/common/views/components/signin.vue | 4 +- .../app/common/views/components/signup.vue | 8 +-- .../views/components/stream-indicator.vue | 10 ++-- .../app/common/views/components/tag-cloud.vue | 2 +- .../app/common/views/components/trends.vue | 2 +- .../app/common/views/components/uploader.vue | 2 +- .../views/components/welcome-timeline.vue | 4 +- src/client/app/common/views/pages/follow.vue | 10 ++-- .../app/common/views/widgets/broadcast.vue | 2 +- .../app/common/views/widgets/donation.vue | 2 +- .../app/common/views/widgets/photo-stream.vue | 4 +- .../common/views/widgets/posts-monitor.vue | 2 +- .../app/common/views/widgets/server.vue | 4 +- .../app/common/views/widgets/slideshow.vue | 2 +- .../app/desktop/views/components/activity.vue | 2 +- .../desktop/views/components/drive-window.vue | 2 +- .../desktop/views/components/drive.file.vue | 6 +- .../desktop/views/components/drive.folder.vue | 8 +-- .../views/components/drive.nav-folder.vue | 4 +- .../app/desktop/views/components/drive.vue | 20 +++---- .../views/components/follow-button.vue | 10 ++-- .../views/components/friends-maker.vue | 2 +- .../app/desktop/views/components/home.vue | 6 +- .../desktop/views/components/media-image.vue | 2 +- .../desktop/views/components/media-video.vue | 2 +- .../views/components/messaging-window.vue | 2 +- .../desktop/views/components/note-detail.vue | 14 ++--- .../app/desktop/views/components/note.vue | 4 +- .../views/components/notifications.vue | 8 +-- .../desktop/views/components/post-form.vue | 10 ++-- .../received-follow-requests-window.vue | 6 +- .../desktop/views/components/renote-form.vue | 2 +- .../desktop/views/components/settings.2fa.vue | 6 +- .../views/components/settings.apps.vue | 2 +- .../views/components/settings.signins.vue | 4 +- .../app/desktop/views/components/settings.vue | 10 ++-- .../views/components/timeline.core.vue | 18 +++--- .../app/desktop/views/components/timeline.vue | 12 ++-- .../views/components/ui.header.account.vue | 10 ++-- .../views/components/ui.header.nav.vue | 6 +- .../desktop/views/components/ui.sidebar.vue | 16 ++--- .../views/components/user-list-timeline.vue | 6 +- .../views/components/user-lists-window.vue | 4 +- .../desktop/views/components/user-preview.vue | 2 +- .../app/desktop/views/components/window.vue | 6 +- .../desktop/views/pages/deck/deck.column.vue | 2 +- .../desktop/views/pages/deck/deck.direct.vue | 6 +- .../views/pages/deck/deck.hashtag-column.vue | 2 +- .../views/pages/deck/deck.hashtag-tl.vue | 6 +- .../desktop/views/pages/deck/deck.list-tl.vue | 6 +- .../views/pages/deck/deck.mentions.vue | 6 +- .../views/pages/deck/deck.note-column.vue | 2 +- .../views/pages/deck/deck.notifications.vue | 8 +-- .../app/desktop/views/pages/deck/deck.tl.vue | 12 ++-- .../views/pages/deck/deck.user-column.vue | 18 +++--- .../app/desktop/views/pages/deck/deck.vue | 6 +- .../app/desktop/views/pages/favorites.vue | 4 +- src/client/app/desktop/views/pages/home.vue | 2 +- .../desktop/views/pages/messaging-room.vue | 2 +- src/client/app/desktop/views/pages/note.vue | 2 +- src/client/app/desktop/views/pages/search.vue | 4 +- src/client/app/desktop/views/pages/share.vue | 2 +- src/client/app/desktop/views/pages/tag.vue | 4 +- .../pages/user-following-or-followers.vue | 6 +- .../pages/user/user.followers-you-know.vue | 2 +- .../desktop/views/pages/user/user.friends.vue | 2 +- .../desktop/views/pages/user/user.photos.vue | 2 +- .../desktop/views/pages/user/user.profile.vue | 16 ++--- .../views/pages/user/user.timeline.vue | 4 +- .../app/desktop/views/pages/user/user.vue | 2 +- .../app/desktop/views/pages/welcome.vue | 6 +- .../app/desktop/views/widgets/messaging.vue | 4 +- .../app/desktop/views/widgets/polls.vue | 2 +- .../app/desktop/views/widgets/post-form.vue | 2 +- .../app/desktop/views/widgets/trends.vue | 2 +- .../app/desktop/views/widgets/users.vue | 2 +- src/client/app/dev/views/app.vue | 2 +- src/client/app/dev/views/apps.vue | 2 +- src/client/app/dev/views/new-app.vue | 2 +- src/client/app/init.ts | 60 +++++-------------- .../app/mobile/views/components/activity.vue | 2 +- .../views/components/drive.file-detail.vue | 8 +-- .../app/mobile/views/components/drive.vue | 22 +++---- .../mobile/views/components/follow-button.vue | 10 ++-- .../mobile/views/components/friends-maker.vue | 2 +- .../mobile/views/components/media-image.vue | 2 +- .../mobile/views/components/note-detail.vue | 10 ++-- .../mobile/views/components/notifications.vue | 8 +-- .../app/mobile/views/components/post-form.vue | 10 ++-- .../app/mobile/views/components/ui.header.vue | 2 +- .../app/mobile/views/components/ui.nav.vue | 4 +- src/client/app/mobile/views/components/ui.vue | 6 +- .../views/components/user-list-timeline.vue | 6 +- .../mobile/views/components/user-timeline.vue | 4 +- src/client/app/mobile/views/pages/drive.vue | 8 +-- .../app/mobile/views/pages/favorites.vue | 6 +- .../app/mobile/views/pages/followers.vue | 6 +- .../app/mobile/views/pages/following.vue | 6 +- .../app/mobile/views/pages/games/reversi.vue | 2 +- .../app/mobile/views/pages/home.timeline.vue | 18 +++--- src/client/app/mobile/views/pages/home.vue | 6 +- .../app/mobile/views/pages/messaging-room.vue | 4 +- .../app/mobile/views/pages/messaging.vue | 2 +- src/client/app/mobile/views/pages/note.vue | 4 +- .../app/mobile/views/pages/notifications.vue | 2 +- .../views/pages/received-follow-requests.vue | 6 +- src/client/app/mobile/views/pages/search.vue | 6 +- .../app/mobile/views/pages/settings.vue | 2 +- src/client/app/mobile/views/pages/share.vue | 2 +- src/client/app/mobile/views/pages/tag.vue | 4 +- .../app/mobile/views/pages/user-list.vue | 4 +- .../app/mobile/views/pages/user-lists.vue | 4 +- src/client/app/mobile/views/pages/user.vue | 14 ++--- .../pages/user/home.followers-you-know.vue | 2 +- .../mobile/views/pages/user/home.friends.vue | 2 +- .../mobile/views/pages/user/home.notes.vue | 2 +- .../mobile/views/pages/user/home.photos.vue | 2 +- src/client/app/mobile/views/pages/welcome.vue | 6 +- src/client/app/mobile/views/pages/widgets.vue | 4 +- 154 files changed, 438 insertions(+), 481 deletions(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 284342f005..88850e16a0 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -26,14 +26,6 @@ common: close: "閉じる" do-not-copy-paste: "ここにコードを入力したり張り付けたりしないでください。アカウントが不正利用される可能性があります。" load-more: "もっと読み込む" - BSoD: - fatal-error: ":( 致命的な問題が発生しました。" - update-browser-os: "お使いのブラウザ(またはOS)のバージョンを更新すると解決する可能性があります。" - error-code: "エラーコード" - browser-version: "ブラウザ バージョン" - client-version: "クライアント バージョン" - email-support: "問題が解決しない場合は、上記の情報をお書き添えの上 syuilotan@yahoo.co.jp までご連絡ください。" - thanks: "Thank you for using Misskey." got-it: "わかった" customization-tips: diff --git a/src/client/app/admin/views/announcements.vue b/src/client/app/admin/views/announcements.vue index 0c0c6e57cf..75e316bcf0 100644 --- a/src/client/app/admin/views/announcements.vue +++ b/src/client/app/admin/views/announcements.vue @@ -34,7 +34,7 @@ export default Vue.extend({ }, created() { - (this as any).os.getMeta().then(meta => { + this.$root.getMeta().then(meta => { this.announcements = meta.broadcasts; }); }, @@ -64,7 +64,7 @@ export default Vue.extend({ }, save(silent) { - (this as any).api('admin/update-meta', { + this.$root.api('admin/update-meta', { broadcasts: this.announcements }).then(() => { if (!silent) { diff --git a/src/client/app/admin/views/ap-log.vue b/src/client/app/admin/views/ap-log.vue index 1038e0a46a..a27bc1b04e 100644 --- a/src/client/app/admin/views/ap-log.vue +++ b/src/client/app/admin/views/ap-log.vue @@ -33,7 +33,7 @@ export default Vue.extend({ }, mounted() { - this.connection = (this as any).os.stream.useSharedConnection('apLog'); + this.connection = this.$root.stream.useSharedConnection('apLog'); this.connection.on('log', this.onLog); this.connection.on('logs', this.onLogs); this.connection.send('requestLog', { diff --git a/src/client/app/admin/views/charts.vue b/src/client/app/admin/views/charts.vue index fbd52eebea..2c42aa438d 100644 --- a/src/client/app/admin/views/charts.vue +++ b/src/client/app/admin/views/charts.vue @@ -105,17 +105,17 @@ export default Vue.extend({ this.now = new Date(); const [perHour, perDay] = await Promise.all([Promise.all([ - (this as any).api('charts/federation', { limit: limit, span: 'hour' }), - (this as any).api('charts/users', { limit: limit, span: 'hour' }), - (this as any).api('charts/notes', { limit: limit, span: 'hour' }), - (this as any).api('charts/drive', { limit: limit, span: 'hour' }), - (this as any).api('charts/network', { limit: limit, span: 'hour' }) + this.$root.api('charts/federation', { limit: limit, span: 'hour' }), + this.$root.api('charts/users', { limit: limit, span: 'hour' }), + this.$root.api('charts/notes', { limit: limit, span: 'hour' }), + this.$root.api('charts/drive', { limit: limit, span: 'hour' }), + this.$root.api('charts/network', { limit: limit, span: 'hour' }) ]), Promise.all([ - (this as any).api('charts/federation', { limit: limit, span: 'day' }), - (this as any).api('charts/users', { limit: limit, span: 'day' }), - (this as any).api('charts/notes', { limit: limit, span: 'day' }), - (this as any).api('charts/drive', { limit: limit, span: 'day' }), - (this as any).api('charts/network', { limit: limit, span: 'day' }) + this.$root.api('charts/federation', { limit: limit, span: 'day' }), + this.$root.api('charts/users', { limit: limit, span: 'day' }), + this.$root.api('charts/notes', { limit: limit, span: 'day' }), + this.$root.api('charts/drive', { limit: limit, span: 'day' }), + this.$root.api('charts/network', { limit: limit, span: 'day' }) ])]); const chart = { diff --git a/src/client/app/admin/views/cpu-memory.vue b/src/client/app/admin/views/cpu-memory.vue index 999908fd22..3200c660e6 100644 --- a/src/client/app/admin/views/cpu-memory.vue +++ b/src/client/app/admin/views/cpu-memory.vue @@ -47,7 +47,7 @@ export default Vue.extend({ }, mounted() { - (this as any).os.getMeta().then(meta => { + this.$root.getMeta().then(meta => { this.meta = meta; }); diff --git a/src/client/app/admin/views/dashboard.vue b/src/client/app/admin/views/dashboard.vue index d62feecbd2..e774473728 100644 --- a/src/client/app/admin/views/dashboard.vue +++ b/src/client/app/admin/views/dashboard.vue @@ -101,13 +101,13 @@ export default Vue.extend({ }, created() { - this.connection = (this as any).os.stream.useSharedConnection('serverStats'); + this.connection = this.$root.stream.useSharedConnection('serverStats'); - (this as any).os.getMeta().then(meta => { + this.$root.getMeta().then(meta => { this.meta = meta; }); - (this as any).api('stats').then(stats => { + this.$root.api('stats').then(stats => { this.stats = stats; }); }, diff --git a/src/client/app/admin/views/emoji.vue b/src/client/app/admin/views/emoji.vue index fb6e871bb9..bf5b9e5b5a 100644 --- a/src/client/app/admin/views/emoji.vue +++ b/src/client/app/admin/views/emoji.vue @@ -68,7 +68,7 @@ export default Vue.extend({ methods: { add() { - (this as any).api('admin/emoji/add', { + this.$root.api('admin/emoji/add', { name: this.name, url: this.url, aliases: this.aliases.split(' ').filter(x => x.length > 0) @@ -87,7 +87,7 @@ export default Vue.extend({ }, fetchEmojis() { - (this as any).api('admin/emoji/list').then(emojis => { + this.$root.api('admin/emoji/list').then(emojis => { emojis.reverse(); emojis.forEach(e => e.aliases = (e.aliases || []).join(' ')); this.emojis = emojis; @@ -95,7 +95,7 @@ export default Vue.extend({ }, updateEmoji(emoji) { - (this as any).api('admin/emoji/update', { + this.$root.api('admin/emoji/update', { id: emoji.id, name: emoji.name, url: emoji.url, @@ -121,7 +121,7 @@ export default Vue.extend({ }).then(res => { if (!res.value) return; - (this as any).api('admin/emoji/remove', { + this.$root.api('admin/emoji/remove', { id: emoji.id }).then(() => { this.$swal({ diff --git a/src/client/app/admin/views/hashtags.vue b/src/client/app/admin/views/hashtags.vue index 9ddb378a8d..739118fa6c 100644 --- a/src/client/app/admin/views/hashtags.vue +++ b/src/client/app/admin/views/hashtags.vue @@ -22,18 +22,18 @@ export default Vue.extend({ }; }, created() { - (this as any).os.getMeta().then(meta => { + this.$root.getMeta().then(meta => { this.hidedTags = meta.hidedTags.join('\n'); }); }, methods: { save() { - (this as any).api('admin/update-meta', { + this.$root.api('admin/update-meta', { hidedTags: this.hidedTags.split('\n') }).then(() => { - //(this as any).os.apis.dialog({ text: `Saved` }); + //this.$root.os.apis.dialog({ text: `Saved` }); }).catch(e => { - //(this as any).os.apis.dialog({ text: `Failed ${e}` }); + //this.$root.os.apis.dialog({ text: `Failed ${e}` }); }); } } diff --git a/src/client/app/admin/views/instance.vue b/src/client/app/admin/views/instance.vue index f5a29e5b52..7c53a5eb94 100644 --- a/src/client/app/admin/views/instance.vue +++ b/src/client/app/admin/views/instance.vue @@ -113,7 +113,7 @@ export default Vue.extend({ }, created() { - (this as any).os.getMeta().then(meta => { + this.$root.getMeta().then(meta => { this.maintainerName = meta.maintainer.name; this.maintainerEmail = meta.maintainer.email; this.bannerUrl = meta.bannerUrl; @@ -139,7 +139,7 @@ export default Vue.extend({ methods: { invite() { - (this as any).api('admin/invite').then(x => { + this.$root.api('admin/invite').then(x => { this.inviteCode = x.code; }).catch(e => { this.$swal({ @@ -150,7 +150,7 @@ export default Vue.extend({ }, updateMeta() { - (this as any).api('admin/update-meta', { + this.$root.api('admin/update-meta', { maintainerName: this.maintainerName, maintainerEmail: this.maintainerEmail, disableRegistration: this.disableRegistration, diff --git a/src/client/app/admin/views/users.vue b/src/client/app/admin/views/users.vue index 6cc0a420e9..e2a6d123c4 100644 --- a/src/client/app/admin/views/users.vue +++ b/src/client/app/admin/views/users.vue @@ -67,13 +67,13 @@ export default Vue.extend({ this.verifying = true; const process = async () => { - const user = await (this as any).os.api('users/show', parseAcct(this.verifyUsername)); - await (this as any).os.api('admin/verify-user', { userId: user.id }); - //(this as any).os.apis.dialog({ text: this.$t('verified') }); + const user = await this.$root.os.api('users/show', parseAcct(this.verifyUsername)); + await this.$root.os.api('admin/verify-user', { userId: user.id }); + //this.$root.os.apis.dialog({ text: this.$t('verified') }); }; await process().catch(e => { - //(this as any).os.apis.dialog({ text: `Failed: ${e}` }); + //this.$root.os.apis.dialog({ text: `Failed: ${e}` }); }); this.verifying = false; @@ -83,13 +83,13 @@ export default Vue.extend({ this.unverifying = true; const process = async () => { - const user = await (this as any).os.api('users/show', parseAcct(this.unverifyUsername)); - await (this as any).os.api('admin/unverify-user', { userId: user.id }); - //(this as any).os.apis.dialog({ text: this.$t('unverified') }); + const user = await this.$root.os.api('users/show', parseAcct(this.unverifyUsername)); + await this.$root.os.api('admin/unverify-user', { userId: user.id }); + //this.$root.os.apis.dialog({ text: this.$t('unverified') }); }; await process().catch(e => { - //(this as any).os.apis.dialog({ text: `Failed: ${e}` }); + //this.$root.os.apis.dialog({ text: `Failed: ${e}` }); }); this.unverifying = false; @@ -99,13 +99,13 @@ export default Vue.extend({ this.suspending = true; const process = async () => { - const user = await (this as any).os.api('users/show', parseAcct(this.suspendUsername)); - await (this as any).os.api('admin/suspend-user', { userId: user.id }); - //(this as any).os.apis.dialog({ text: this.$t('suspended') }); + const user = await this.$root.os.api('users/show', parseAcct(this.suspendUsername)); + await this.$root.os.api('admin/suspend-user', { userId: user.id }); + //this.$root.os.apis.dialog({ text: this.$t('suspended') }); }; await process().catch(e => { - //(this as any).os.apis.dialog({ text: `Failed: ${e}` }); + //this.$root.os.apis.dialog({ text: `Failed: ${e}` }); }); this.suspending = false; @@ -115,13 +115,13 @@ export default Vue.extend({ this.unsuspending = true; const process = async () => { - const user = await (this as any).os.api('users/show', parseAcct(this.unsuspendUsername)); - await (this as any).os.api('admin/unsuspend-user', { userId: user.id }); - //(this as any).os.apis.dialog({ text: this.$t('unsuspended') }); + const user = await this.$root.os.api('users/show', parseAcct(this.unsuspendUsername)); + await this.$root.os.api('admin/unsuspend-user', { userId: user.id }); + //this.$root.os.apis.dialog({ text: this.$t('unsuspended') }); }; await process().catch(e => { - //(this as any).os.apis.dialog({ text: `Failed: ${e}` }); + //this.$root.os.apis.dialog({ text: `Failed: ${e}` }); }); this.unsuspending = false; diff --git a/src/client/app/app.styl b/src/client/app/app.styl index ff8380401d..3d8218dbda 100644 --- a/src/client/app/app.styl +++ b/src/client/app/app.styl @@ -13,13 +13,6 @@ html body overflow-wrap break-word -#error - padding 32px - color #fff - - hr - border solid 1px #fff - #nprogress pointer-events none diff --git a/src/client/app/auth/views/form.vue b/src/client/app/auth/views/form.vue index 6bd0acb359..7b01220c2b 100644 --- a/src/client/app/auth/views/form.vue +++ b/src/client/app/auth/views/form.vue @@ -48,7 +48,7 @@ export default Vue.extend({ }, methods: { cancel() { - (this as any).api('auth/deny', { + this.$root.api('auth/deny', { token: this.session.token }).then(() => { this.$emit('denied'); @@ -56,7 +56,7 @@ export default Vue.extend({ }, accept() { - (this as any).api('auth/accept', { + this.$root.api('auth/accept', { token: this.session.token }).then(() => { this.$emit('accepted'); diff --git a/src/client/app/auth/views/index.vue b/src/client/app/auth/views/index.vue index 9158ade721..9bf2acba72 100644 --- a/src/client/app/auth/views/index.vue +++ b/src/client/app/auth/views/index.vue @@ -57,7 +57,7 @@ export default Vue.extend({ if (!this.$store.getters.isSignedIn) return; // Fetch session - (this as any).api('auth/session/show', { + this.$root.api('auth/session/show', { token: this.token }).then(session => { this.session = session; @@ -65,7 +65,7 @@ export default Vue.extend({ // 既に連携していた場合 if (this.session.app.isAuthorized) { - (this as any).api('auth/accept', { + this.$root.api('auth/accept', { token: this.session.token }).then(() => { this.accepted(); diff --git a/src/client/app/common/scripts/note-mixin.ts b/src/client/app/common/scripts/note-mixin.ts index cd3d3ae760..93debf81e8 100644 --- a/src/client/app/common/scripts/note-mixin.ts +++ b/src/client/app/common/scripts/note-mixin.ts @@ -115,7 +115,7 @@ export default (opts: Opts = {}) => ({ react(viaKeyboard = false) { this.blur(); - (this as any).os.new(MkReactionPicker, { + this.$root.new(MkReactionPicker, { source: this.$refs.reactButton, note: this.appearNote, showFocus: viaKeyboard, @@ -126,28 +126,28 @@ export default (opts: Opts = {}) => ({ }, reactDirectly(reaction) { - (this as any).api('notes/reactions/create', { + (this.$root.api('notes/reactions/create', { noteId: this.appearNote.id, reaction: reaction }); }, favorite() { - (this as any).api('notes/favorites/create', { + this.$root.api('notes/favorites/create', { noteId: this.appearNote.id }).then(() => { - (this as any).os.new(Ok); + this.$root.new(Ok); }); }, del() { - (this as any).api('notes/delete', { + this.$root.api('notes/delete', { noteId: this.appearNote.id }); }, menu(viaKeyboard = false) { - (this as any).os.new(MkNoteMenu, { + this.$root.new(MkNoteMenu, { source: this.$refs.menuButton, note: this.appearNote, animation: !viaKeyboard, diff --git a/src/client/app/common/scripts/note-subscriber.ts b/src/client/app/common/scripts/note-subscriber.ts index 1a82dd3918..bc434c4360 100644 --- a/src/client/app/common/scripts/note-subscriber.ts +++ b/src/client/app/common/scripts/note-subscriber.ts @@ -26,7 +26,7 @@ export default prop => ({ created() { if (this.$store.getters.isSignedIn) { - this.connection = (this as any).os.stream; + this.connection = this.$root.stream; } }, diff --git a/src/client/app/common/views/components/api-settings.vue b/src/client/app/common/views/components/api-settings.vue index 52750ad5c6..139aa44077 100644 --- a/src/client/app/common/views/components/api-settings.vue +++ b/src/client/app/common/views/components/api-settings.vue @@ -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 => { diff --git a/src/client/app/common/views/components/autocomplete.vue b/src/client/app/common/views/components/autocomplete.vue index f3f565e632..01461c7280 100644 --- a/src/client/app/common/views/components/autocomplete.vue +++ b/src/client/app/common/views/components/autocomplete.vue @@ -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 => { diff --git a/src/client/app/common/views/components/drive-settings.vue b/src/client/app/common/views/components/drive-settings.vue index fbf70f71f1..8374472543 100644 --- a/src/client/app/common/views/components/drive-settings.vue +++ b/src/client/app/common/views/components/drive-settings.vue @@ -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 diff --git a/src/client/app/common/views/components/games/reversi/reversi.game.vue b/src/client/app/common/views/components/games/reversi/reversi.game.vue index 08c69f3076..14c0c0891c 100644 --- a/src/client/app/common/views/components/games/reversi/reversi.game.vue +++ b/src/client/app/common/views/components/games/reversi/reversi.game.vue @@ -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 }); }, diff --git a/src/client/app/common/views/components/games/reversi/reversi.gameroom.vue b/src/client/app/common/views/components/games/reversi/reversi.gameroom.vue index 471decc240..4099389502 100644 --- a/src/client/app/common/views/components/games/reversi/reversi.gameroom.vue +++ b/src/client/app/common/views/components/games/reversi/reversi.gameroom.vue @@ -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); diff --git a/src/client/app/common/views/components/games/reversi/reversi.index.vue b/src/client/app/common/views/components/games/reversi/reversi.index.vue index 5711f0cf2b..eb657365ab 100644 --- a/src/client/app/common/views/components/games/reversi/reversi.index.vue +++ b/src/client/app/common/views/components/games/reversi/reversi.index.vue @@ -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) { diff --git a/src/client/app/common/views/components/games/reversi/reversi.vue b/src/client/app/common/views/components/games/reversi/reversi.vue index ab47acbfe3..8c555a6c4f 100644 --- a/src/client/app/common/views/components/games/reversi/reversi.vue +++ b/src/client/app/common/views/components/games/reversi/reversi.vue @@ -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) { diff --git a/src/client/app/common/views/components/instance.vue b/src/client/app/common/views/components/instance.vue index 0dd1510e08..7b8d4f8e0b 100644 --- a/src/client/app/common/views/components/instance.vue +++ b/src/client/app/common/views/components/instance.vue @@ -20,7 +20,7 @@ export default Vue.extend({ } }, created() { - (this as any).os.getMeta().then(meta => { + this.$root.getMeta().then(meta => { this.meta = meta; }); } diff --git a/src/client/app/common/views/components/messaging-room.form.vue b/src/client/app/common/views/components/messaging-room.form.vue index ef160424eb..32cceb0c06 100644 --- a/src/client/app/common/views/components/messaging-room.form.vue +++ b/src/client/app/common/views/components/messaging-room.form.vue @@ -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 diff --git a/src/client/app/common/views/components/messaging-room.vue b/src/client/app/common/views/components/messaging-room.vue index 5b5de4058a..dc70f45969 100644 --- a/src/client/app/common/views/components/messaging-room.vue +++ b/src/client/app/common/views/components/messaging-room.vue @@ -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 diff --git a/src/client/app/common/views/components/messaging.vue b/src/client/app/common/views/components/messaging.vue index b818f599a2..046ac1cfdd 100644 --- a/src/client/app/common/views/components/messaging.vue +++ b/src/client/app/common/views/components/messaging.vue @@ -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 => { diff --git a/src/client/app/common/views/components/misskey-flavored-markdown.ts b/src/client/app/common/views/components/misskey-flavored-markdown.ts index 1f82fb8f45..a985a80ecf 100644 --- a/src/client/app/common/views/components/misskey-flavored-markdown.ts +++ b/src/client/app/common/views/components/misskey-flavored-markdown.ts @@ -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, diff --git a/src/client/app/common/views/components/mute-and-block.vue b/src/client/app/common/views/components/mute-and-block.vue index f8e7183e24..3ed02e644c 100644 --- a/src/client/app/common/views/components/mute-and-block.vue +++ b/src/client/app/common/views/components/mute-and-block.vue @@ -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; }); diff --git a/src/client/app/common/views/components/nav.vue b/src/client/app/common/views/components/nav.vue index c3daf9a88b..bf76898136 100644 --- a/src/client/app/common/views/components/nav.vue +++ b/src/client/app/common/views/components/nav.vue @@ -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; }); diff --git a/src/client/app/common/views/components/note-menu.vue b/src/client/app/common/views/components/note-menu.vue index f17f038696..1b4ae8e125 100644 --- a/src/client/app/common/views/components/note-menu.vue +++ b/src/client/app/common/views/components/note-menu.vue @@ -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(); }); }, diff --git a/src/client/app/common/views/components/password-settings.vue b/src/client/app/common/views/components/password-settings.vue index da95a6e768..01396bf32b 100644 --- a/src/client/app/common/views/components/password-settings.vue +++ b/src/client/app/common/views/components/password-settings.vue @@ -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(() => { diff --git a/src/client/app/common/views/components/poll.vue b/src/client/app/common/views/components/poll.vue index 23245985c7..8a31ec83d7 100644 --- a/src/client/app/common/views/components/poll.vue +++ b/src/client/app/common/views/components/poll.vue @@ -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(() => { diff --git a/src/client/app/common/views/components/profile-editor.vue b/src/client/app/common/views/components/profile-editor.vue index 0d2b3e9c0d..44f1d95673 100644 --- a/src/client/app/common/views/components/profile-editor.vue +++ b/src/client/app/common/views/components/profile-editor.vue @@ -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, diff --git a/src/client/app/common/views/components/reaction-picker.vue b/src/client/app/common/views/components/reaction-picker.vue index a38089409c..62f4930edb 100644 --- a/src/client/app/common/views/components/reaction-picker.vue +++ b/src/client/app/common/views/components/reaction-picker.vue @@ -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(() => { diff --git a/src/client/app/common/views/components/reactions-viewer.vue b/src/client/app/common/views/components/reactions-viewer.vue index 674ea5c6f5..7f17d16a71 100644 --- a/src/client/app/common/views/components/reactions-viewer.vue +++ b/src/client/app/common/views/components/reactions-viewer.vue @@ -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 }); diff --git a/src/client/app/common/views/components/signin.vue b/src/client/app/common/views/components/signin.vue index 04bffb4967..21ff45ab5a 100644 --- a/src/client/app/common/views/components/signin.vue +++ b/src/client/app/common/views/components/signin.vue @@ -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 diff --git a/src/client/app/common/views/components/signup.vue b/src/client/app/common/views/components/signup.vue index 26f7da19de..00580ef32e 100644 --- a/src/client/app/common/views/components/signup.vue +++ b/src/client/app/common/views/components/signup.vue @@ -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(() => { diff --git a/src/client/app/common/views/components/stream-indicator.vue b/src/client/app/common/views/components/stream-indicator.vue index 3955c2711d..c21272995e 100644 --- a/src/client/app/common/views/components/stream-indicator.vue +++ b/src/client/app/common/views/components/stream-indicator.vue @@ -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() { diff --git a/src/client/app/common/views/components/tag-cloud.vue b/src/client/app/common/views/components/tag-cloud.vue index 8bca98bf75..c4fb27865e 100644 --- a/src/client/app/common/views/components/tag-cloud.vue +++ b/src/client/app/common/views/components/tag-cloud.vue @@ -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; }); diff --git a/src/client/app/common/views/components/trends.vue b/src/client/app/common/views/components/trends.vue index b39f711b9f..2e16967076 100644 --- a/src/client/app/common/views/components/trends.vue +++ b/src/client/app/common/views/components/trends.vue @@ -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; }); diff --git a/src/client/app/common/views/components/uploader.vue b/src/client/app/common/views/components/uploader.vue index d516227ad3..6e0dab3814 100644 --- a/src/client/app/common/views/components/uploader.vue +++ b/src/client/app/common/views/components/uploader.vue @@ -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); diff --git a/src/client/app/common/views/components/welcome-timeline.vue b/src/client/app/common/views/components/welcome-timeline.vue index a1b788bd42..cad09a11a6 100644 --- a/src/client/app/common/views/components/welcome-timeline.vue +++ b/src/client/app/common/views/components/welcome-timeline.vue @@ -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, diff --git a/src/client/app/common/views/pages/follow.vue b/src/client/app/common/views/pages/follow.vue index 7b396fa38f..344fce9fb1 100644 --- a/src/client/app/common/views/pages/follow.vue +++ b/src/client/app/common/views/pages/follow.vue @@ -69,7 +69,7 @@ export default Vue.extend({ const acct = new URL(location.href).searchParams.get('acct'); this.fetching = true; Progress.start(); - (this as any).api('users/show', parseAcct(acct)).then(user => { + this.$root.api('users/show', parseAcct(acct)).then(user => { this.user = user; this.fetching = false; Progress.done(); @@ -81,20 +81,20 @@ export default Vue.extend({ try { if (this.user.isFollowing) { - this.user = await (this as any).api('following/delete', { + this.user = await this.$root.api('following/delete', { userId: this.user.id }); } else { if (this.user.hasPendingFollowRequestFromYou) { - this.user = await (this as any).api('following/requests/cancel', { + this.user = await this.$root.api('following/requests/cancel', { userId: this.user.id }); } else if (this.user.isLocked) { - this.user = await (this as any).api('following/create', { + this.user = await this.$root.api('following/create', { userId: this.user.id }); } else { - this.user = await (this as any).api('following/create', { + this.user = await this.$root.api('following/create', { userId: this.user.id }); } diff --git a/src/client/app/common/views/widgets/broadcast.vue b/src/client/app/common/views/widgets/broadcast.vue index f5486936bf..7bb8ee70b5 100644 --- a/src/client/app/common/views/widgets/broadcast.vue +++ b/src/client/app/common/views/widgets/broadcast.vue @@ -46,7 +46,7 @@ export default define({ }; }, mounted() { - (this as any).os.getMeta().then(meta => { + this.$root.getMeta().then(meta => { this.announcements = meta.broadcasts; this.fetching = false; }); diff --git a/src/client/app/common/views/widgets/donation.vue b/src/client/app/common/views/widgets/donation.vue index 785c9bb391..057813891c 100644 --- a/src/client/app/common/views/widgets/donation.vue +++ b/src/client/app/common/views/widgets/donation.vue @@ -27,7 +27,7 @@ export default define({ }; }, created() { - (this as any).os.getMeta().then(meta => { + this.$root.getMeta().then(meta => { this.meta = meta; }); } diff --git a/src/client/app/common/views/widgets/photo-stream.vue b/src/client/app/common/views/widgets/photo-stream.vue index 812ef3417b..72658707c2 100644 --- a/src/client/app/common/views/widgets/photo-stream.vue +++ b/src/client/app/common/views/widgets/photo-stream.vue @@ -32,11 +32,11 @@ export default define({ }; }, mounted() { - this.connection = (this as any).os.stream.useSharedConnection('main'); + this.connection = this.$root.stream.useSharedConnection('main'); this.connection.on('driveFileCreated', this.onDriveFileCreated); - (this as any).api('drive/stream', { + this.$root.api('drive/stream', { type: 'image/*', limit: 9 }).then(images => { diff --git a/src/client/app/common/views/widgets/posts-monitor.vue b/src/client/app/common/views/widgets/posts-monitor.vue index 75d1c95b24..9b2cc5a6cd 100644 --- a/src/client/app/common/views/widgets/posts-monitor.vue +++ b/src/client/app/common/views/widgets/posts-monitor.vue @@ -112,7 +112,7 @@ export default define({ } }, mounted() { - this.connection = (this as any).os.stream.useSharedConnection('notesStats'); + this.connection = this.$root.stream.useSharedConnection('notesStats'); this.connection.on('stats', this.onStats); this.connection.on('statsLog', this.onStatsLog); diff --git a/src/client/app/common/views/widgets/server.vue b/src/client/app/common/views/widgets/server.vue index 50cc1e4967..8ba7cf31c3 100644 --- a/src/client/app/common/views/widgets/server.vue +++ b/src/client/app/common/views/widgets/server.vue @@ -52,12 +52,12 @@ export default define({ }; }, mounted() { - (this as any).os.getMeta().then(meta => { + this.$root.getMeta().then(meta => { this.meta = meta; this.fetching = false; }); - this.connection = (this as any).os.stream.useSharedConnection('serverStats'); + this.connection = this.$root.stream.useSharedConnection('serverStats'); }, beforeDestroy() { this.connection.dispose(); diff --git a/src/client/app/common/views/widgets/slideshow.vue b/src/client/app/common/views/widgets/slideshow.vue index abe56cd6f3..6890481724 100644 --- a/src/client/app/common/views/widgets/slideshow.vue +++ b/src/client/app/common/views/widgets/slideshow.vue @@ -101,7 +101,7 @@ export default define({ fetch() { this.fetching = true; - (this as any).api('drive/files', { + this.$root.api('drive/files', { folderId: this.props.folder, type: 'image/*', limit: 100 diff --git a/src/client/app/desktop/views/components/activity.vue b/src/client/app/desktop/views/components/activity.vue index 56dfaa8f2f..c9ee45ab0e 100644 --- a/src/client/app/desktop/views/components/activity.vue +++ b/src/client/app/desktop/views/components/activity.vue @@ -45,7 +45,7 @@ export default Vue.extend({ }; }, mounted() { - (this as any).api('charts/user/notes', { + this.$root.api('charts/user/notes', { userId: this.user.id, span: 'day', limit: 7 * 20 diff --git a/src/client/app/desktop/views/components/drive-window.vue b/src/client/app/desktop/views/components/drive-window.vue index 0ac18bd344..1318762cbe 100644 --- a/src/client/app/desktop/views/components/drive-window.vue +++ b/src/client/app/desktop/views/components/drive-window.vue @@ -22,7 +22,7 @@ export default Vue.extend({ }; }, mounted() { - (this as any).api('drive').then(info => { + this.$root.api('drive').then(info => { this.usage = info.usage / info.capacity * 100; }); }, diff --git a/src/client/app/desktop/views/components/drive.file.vue b/src/client/app/desktop/views/components/drive.file.vue index 376b2e32dc..779856006d 100644 --- a/src/client/app/desktop/views/components/drive.file.vue +++ b/src/client/app/desktop/views/components/drive.file.vue @@ -155,7 +155,7 @@ export default Vue.extend({ default: this.file.name, allowEmpty: false }).then(name => { - (this as any).api('drive/files/update', { + this.$root.api('drive/files/update', { fileId: this.file.id, name: name }); @@ -163,7 +163,7 @@ export default Vue.extend({ }, toggleSensitive() { - (this as any).api('drive/files/update', { + this.$root.api('drive/files/update', { fileId: this.file.id, isSensitive: !this.file.isSensitive }); @@ -193,7 +193,7 @@ export default Vue.extend({ }, deleteFile() { - (this as any).api('drive/files/delete', { + this.$root.api('drive/files/delete', { fileId: this.file.id }); } diff --git a/src/client/app/desktop/views/components/drive.folder.vue b/src/client/app/desktop/views/components/drive.folder.vue index ff87a12692..7ce9f74018 100644 --- a/src/client/app/desktop/views/components/drive.folder.vue +++ b/src/client/app/desktop/views/components/drive.folder.vue @@ -132,7 +132,7 @@ export default Vue.extend({ if (driveFile != null && driveFile != '') { const file = JSON.parse(driveFile); this.browser.removeFile(file.id); - (this as any).api('drive/files/update', { + this.$root.api('drive/files/update', { fileId: file.id, folderId: this.folder.id }); @@ -148,7 +148,7 @@ export default Vue.extend({ if (folder.id == this.folder.id) return; this.browser.removeFolder(folder.id); - (this as any).api('drive/folders/update', { + this.$root.api('drive/folders/update', { folderId: folder.id, parentId: this.folder.id }).then(() => { @@ -201,7 +201,7 @@ export default Vue.extend({ placeholder: this.$t('contextmenu.input-new-folder-name'), default: this.folder.name }).then(name => { - (this as any).api('drive/folders/update', { + this.$root.api('drive/folders/update', { folderId: this.folder.id, name: name }); @@ -209,7 +209,7 @@ export default Vue.extend({ }, deleteFolder() { - (this as any).api('drive/folders/delete', { + this.$root.api('drive/folders/delete', { folderId: this.folder.id }); } diff --git a/src/client/app/desktop/views/components/drive.nav-folder.vue b/src/client/app/desktop/views/components/drive.nav-folder.vue index fb46d8ede2..813c44ab42 100644 --- a/src/client/app/desktop/views/components/drive.nav-folder.vue +++ b/src/client/app/desktop/views/components/drive.nav-folder.vue @@ -79,7 +79,7 @@ export default Vue.extend({ if (driveFile != null && driveFile != '') { const file = JSON.parse(driveFile); this.browser.removeFile(file.id); - (this as any).api('drive/files/update', { + this.$root.api('drive/files/update', { fileId: file.id, folderId: this.folder ? this.folder.id : null }); @@ -93,7 +93,7 @@ export default Vue.extend({ // 移動先が自分自身ならreject if (this.folder && folder.id == this.folder.id) return; this.browser.removeFolder(folder.id); - (this as any).api('drive/folders/update', { + this.$root.api('drive/folders/update', { folderId: folder.id, parentId: this.folder ? this.folder.id : null }); diff --git a/src/client/app/desktop/views/components/drive.vue b/src/client/app/desktop/views/components/drive.vue index 5c5b898e39..8c004af875 100644 --- a/src/client/app/desktop/views/components/drive.vue +++ b/src/client/app/desktop/views/components/drive.vue @@ -117,7 +117,7 @@ export default Vue.extend({ }; }, mounted() { - this.connection = (this as any).os.stream.useSharedConnection('drive'); + this.connection = this.$root.stream.useSharedConnection('drive'); this.connection.on('fileCreated', this.onStreamDriveFileCreated); this.connection.on('fileUpdated', this.onStreamDriveFileUpdated); @@ -290,7 +290,7 @@ export default Vue.extend({ const file = JSON.parse(driveFile); if (this.files.some(f => f.id == file.id)) return; this.removeFile(file.id); - (this as any).api('drive/files/update', { + this.$root.api('drive/files/update', { fileId: file.id, folderId: this.folder ? this.folder.id : null }); @@ -306,7 +306,7 @@ export default Vue.extend({ if (this.folder && folder.id == this.folder.id) return false; if (this.folders.some(f => f.id == folder.id)) return false; this.removeFolder(folder.id); - (this as any).api('drive/folders/update', { + this.$root.api('drive/folders/update', { folderId: folder.id, parentId: this.folder ? this.folder.id : null }).then(() => { @@ -339,7 +339,7 @@ export default Vue.extend({ title: this.$t('url-upload'), placeholder: this.$t('url-of-file') }).then(url => { - (this as any).api('drive/files/upload_from_url', { + this.$root.api('drive/files/upload_from_url', { url: url, folderId: this.folder ? this.folder.id : undefined }); @@ -359,7 +359,7 @@ export default Vue.extend({ title: this.$t('create-folder'), placeholder: this.$t('folder-name') }).then(name => { - (this as any).api('drive/folders/create', { + this.$root.api('drive/folders/create', { name: name, parentId: this.folder ? this.folder.id : undefined }).then(folder => { @@ -400,7 +400,7 @@ export default Vue.extend({ newWindow(folder) { if (document.body.clientWidth > 800) { - (this as any).os.new(MkDriveWindow, { + this.$root.new(MkDriveWindow, { folder: folder }); } else { @@ -420,7 +420,7 @@ export default Vue.extend({ this.fetching = true; - (this as any).api('drive/folders/show', { + this.$root.api('drive/folders/show', { folderId: target }).then(folder => { this.folder = folder; @@ -522,7 +522,7 @@ export default Vue.extend({ const filesMax = 30; // フォルダ一覧取得 - (this as any).api('drive/folders', { + this.$root.api('drive/folders', { folderId: this.folder ? this.folder.id : null, limit: foldersMax + 1 }).then(folders => { @@ -535,7 +535,7 @@ export default Vue.extend({ }); // ファイル一覧取得 - (this as any).api('drive/files', { + this.$root.api('drive/files', { folderId: this.folder ? this.folder.id : null, limit: filesMax + 1 }).then(files => { @@ -565,7 +565,7 @@ export default Vue.extend({ const max = 30; // ファイル一覧取得 - (this as any).api('drive/files', { + this.$root.api('drive/files', { folderId: this.folder ? this.folder.id : null, untilId: this.files[this.files.length - 1].id, limit: max + 1 diff --git a/src/client/app/desktop/views/components/follow-button.vue b/src/client/app/desktop/views/components/follow-button.vue index caaa6df7f9..70711d1d8c 100644 --- a/src/client/app/desktop/views/components/follow-button.vue +++ b/src/client/app/desktop/views/components/follow-button.vue @@ -41,7 +41,7 @@ export default Vue.extend({ }, mounted() { - this.connection = (this as any).os.stream.useSharedConnection('main'); + this.connection = this.$root.stream.useSharedConnection('main'); this.connection.on('follow', this.onFollowChange); this.connection.on('unfollow', this.onFollowChange); }, @@ -64,20 +64,20 @@ export default Vue.extend({ try { if (this.u.isFollowing) { - this.u = await (this as any).api('following/delete', { + this.u = await this.$root.api('following/delete', { userId: this.u.id }); } else { if (this.u.hasPendingFollowRequestFromYou) { - this.u = await (this as any).api('following/requests/cancel', { + this.u = await this.$root.api('following/requests/cancel', { userId: this.u.id }); } else if (this.u.isLocked) { - this.u = await (this as any).api('following/create', { + this.u = await this.$root.api('following/create', { userId: this.u.id }); } else { - this.u = await (this as any).api('following/create', { + this.u = await this.$root.api('following/create', { userId: this.user.id }); } diff --git a/src/client/app/desktop/views/components/friends-maker.vue b/src/client/app/desktop/views/components/friends-maker.vue index ffd6cf421b..8ba3324e51 100644 --- a/src/client/app/desktop/views/components/friends-maker.vue +++ b/src/client/app/desktop/views/components/friends-maker.vue @@ -39,7 +39,7 @@ export default Vue.extend({ this.fetching = true; this.users = []; - (this as any).api('users/recommendation', { + this.$root.api('users/recommendation', { limit: this.limit, offset: this.limit * this.page }).then(users => { diff --git a/src/client/app/desktop/views/components/home.vue b/src/client/app/desktop/views/components/home.vue index cf09d73ffc..315171e3a7 100644 --- a/src/client/app/desktop/views/components/home.vue +++ b/src/client/app/desktop/views/components/home.vue @@ -168,7 +168,7 @@ export default Vue.extend({ created() { if (this.$store.state.settings.home == null) { - this.api('i/update_home', { + this.$root.api('i/update_home', { home: _defaultDesktopHomeWidgets }).then(() => { this.$store.commit('settings/setHome', _defaultDesktopHomeWidgets); @@ -177,7 +177,7 @@ export default Vue.extend({ }, mounted() { - this.connection = (this as any).os.stream.useSharedConnection('main'); + this.connection = this.$root.stream.useSharedConnection('main'); }, beforeDestroy() { @@ -227,7 +227,7 @@ export default Vue.extend({ this.$store.commit('settings/setHome', left.concat(right)); left.forEach(w => w.place = 'left'); right.forEach(w => w.place = 'right'); - (this as any).api('i/update_home', { + this.$root.api('i/update_home', { home: this.home }); }, diff --git a/src/client/app/desktop/views/components/media-image.vue b/src/client/app/desktop/views/components/media-image.vue index f420266aea..e4594dc217 100644 --- a/src/client/app/desktop/views/components/media-image.vue +++ b/src/client/app/desktop/views/components/media-image.vue @@ -60,7 +60,7 @@ export default Vue.extend({ }, onClick() { - (this as any).os.new(ImageViewer, { + this.$root.new(ImageViewer, { image: this.image }); } diff --git a/src/client/app/desktop/views/components/media-video.vue b/src/client/app/desktop/views/components/media-video.vue index 560fe9bc5a..727af8ade2 100644 --- a/src/client/app/desktop/views/components/media-video.vue +++ b/src/client/app/desktop/views/components/media-video.vue @@ -53,7 +53,7 @@ export default Vue.extend({ start = videoTag.currentTime videoTag.pause() } - (this as any).os.new(MkMediaVideoDialog, { + this.$root.new(MkMediaVideoDialog, { video: this.video, start, }) diff --git a/src/client/app/desktop/views/components/messaging-window.vue b/src/client/app/desktop/views/components/messaging-window.vue index ddfaf6f817..68a04c772a 100644 --- a/src/client/app/desktop/views/components/messaging-window.vue +++ b/src/client/app/desktop/views/components/messaging-window.vue @@ -14,7 +14,7 @@ export default Vue.extend({ i18n: i18n('desktop/views/components/messaging-window.vue'), methods: { navigate(user) { - (this as any).os.new(MkMessagingRoomWindow, { + this.$root.new(MkMessagingRoomWindow, { user: user }); } diff --git a/src/client/app/desktop/views/components/note-detail.vue b/src/client/app/desktop/views/components/note-detail.vue index a442f83586..aa7b0072c6 100644 --- a/src/client/app/desktop/views/components/note-detail.vue +++ b/src/client/app/desktop/views/components/note-detail.vue @@ -161,7 +161,7 @@ export default Vue.extend({ mounted() { // Get replies if (!this.compact) { - (this as any).api('notes/replies', { + this.$root.api('notes/replies', { noteId: this.p.id, limit: 8 }).then(replies => { @@ -173,7 +173,7 @@ export default Vue.extend({ if (this.p.geo) { const shouldShowMap = this.$store.getters.isSignedIn ? this.$store.state.settings.showMaps : true; if (shouldShowMap) { - (this as any).os.getGoogleMaps().then(maps => { + this.$root.os.getGoogleMaps().then(maps => { const uluru = new maps.LatLng(this.p.geo.coordinates[1], this.p.geo.coordinates[0]); const map = new maps.Map(this.$refs.map, { center: uluru, @@ -193,7 +193,7 @@ export default Vue.extend({ this.conversationFetching = true; // Fetch conversation - (this as any).api('notes/conversation', { + this.$root.api('notes/conversation', { noteId: this.p.replyId }).then(conversation => { this.conversationFetching = false; @@ -202,26 +202,26 @@ export default Vue.extend({ }, reply() { - (this as any).os.new(MkPostFormWindow, { + this.$root.new(MkPostFormWindow, { reply: this.p }); }, renote() { - (this as any).os.new(MkRenoteFormWindow, { + this.$root.new(MkRenoteFormWindow, { note: this.p }); }, react() { - (this as any).os.new(MkReactionPicker, { + this.$root.new(MkReactionPicker, { source: this.$refs.reactButton, note: this.p }); }, menu() { - (this as any).os.new(MkNoteMenu, { + this.$root.new(MkNoteMenu, { source: this.$refs.menuButton, note: this.p }); diff --git a/src/client/app/desktop/views/components/note.vue b/src/client/app/desktop/views/components/note.vue index 8b237be8c5..499353524c 100644 --- a/src/client/app/desktop/views/components/note.vue +++ b/src/client/app/desktop/views/components/note.vue @@ -117,14 +117,14 @@ export default Vue.extend({ created() { if (this.detail) { - (this as any).api('notes/replies', { + this.$root.api('notes/replies', { noteId: this.appearNote.id, limit: 8 }).then(replies => { this.replies = replies; }); - (this as any).api('notes/conversation', { + this.$root.api('notes/conversation', { noteId: this.appearNote.replyId }).then(conversation => { this.conversation = conversation.reverse(); diff --git a/src/client/app/desktop/views/components/notifications.vue b/src/client/app/desktop/views/components/notifications.vue index 918cb821bb..45a050bcbb 100644 --- a/src/client/app/desktop/views/components/notifications.vue +++ b/src/client/app/desktop/views/components/notifications.vue @@ -142,13 +142,13 @@ export default Vue.extend({ }, mounted() { - this.connection = (this as any).os.stream.useSharedConnection('main'); + this.connection = this.$root.stream.useSharedConnection('main'); this.connection.on('notification', this.onNotification); const max = 10; - (this as any).api('i/notifications', { + this.$root.api('i/notifications', { limit: max + 1 }).then(notifications => { if (notifications.length == max + 1) { @@ -171,7 +171,7 @@ export default Vue.extend({ const max = 30; - (this as any).api('i/notifications', { + this.$root.api('i/notifications', { limit: max + 1, untilId: this.notifications[this.notifications.length - 1].id }).then(notifications => { @@ -188,7 +188,7 @@ export default Vue.extend({ onNotification(notification) { // TODO: ユーザーが画面を見てないと思われるとき(ブラウザやタブがアクティブじゃないなど)は送信しない - (this as any).os.stream.send('readNotification', { + this.$root.stream.send('readNotification', { id: notification.id }); diff --git a/src/client/app/desktop/views/components/post-form.vue b/src/client/app/desktop/views/components/post-form.vue index fb6d966b69..483908b7a0 100644 --- a/src/client/app/desktop/views/components/post-form.vue +++ b/src/client/app/desktop/views/components/post-form.vue @@ -115,7 +115,7 @@ export default Vue.extend({ }, created() { - (this as any).os.getMeta().then(meta => { + this.$root.getMeta().then(meta => { this.maxNoteTextLength = meta.maxNoteTextLength; }); }, @@ -195,7 +195,7 @@ export default Vue.extend({ // ダイレクトへのリプライはリプライ先ユーザーを初期設定 if (this.reply && this.reply.visibility === 'specified') { - (this as any).api('users/show', { userId: this.reply.userId }).then(user => { + this.$root.api('users/show', { userId: this.reply.userId }).then(user => { this.visibleUsers.push(user); }); } @@ -354,7 +354,7 @@ export default Vue.extend({ }, setVisibility() { - const w = (this as any).os.new(MkVisibilityChooser, { + const w = this.$root.new(MkVisibilityChooser, { source: this.$refs.visibilityButton }); w.$once('chosen', v => { @@ -367,7 +367,7 @@ export default Vue.extend({ title: this.$t('enter-username') }).then(acct => { if (acct.startsWith('@')) acct = acct.substr(1); - (this as any).api('users/show', parseAcct(acct)).then(user => { + this.$root.api('users/show', parseAcct(acct)).then(user => { this.visibleUsers.push(user); }); }); @@ -380,7 +380,7 @@ export default Vue.extend({ post() { this.posting = true; - (this as any).api('notes/create', { + this.$root.api('notes/create', { text: this.text == '' ? undefined : this.text, fileIds: this.files.length > 0 ? this.files.map(f => f.id) : undefined, replyId: this.reply ? this.reply.id : undefined, diff --git a/src/client/app/desktop/views/components/received-follow-requests-window.vue b/src/client/app/desktop/views/components/received-follow-requests-window.vue index c0acca4a40..cadf195d3f 100644 --- a/src/client/app/desktop/views/components/received-follow-requests-window.vue +++ b/src/client/app/desktop/views/components/received-follow-requests-window.vue @@ -26,19 +26,19 @@ export default Vue.extend({ }; }, mounted() { - (this as any).api('following/requests/list').then(requests => { + this.$root.api('following/requests/list').then(requests => { this.fetching = false; this.requests = requests; }); }, methods: { accept(user) { - (this as any).api('following/requests/accept', { userId: user.id }).then(() => { + this.$root.api('following/requests/accept', { userId: user.id }).then(() => { this.requests = this.requests.filter(r => r.follower.id != user.id); }); }, reject(user) { - (this as any).api('following/requests/reject', { userId: user.id }).then(() => { + this.$root.api('following/requests/reject', { userId: user.id }).then(() => { this.requests = this.requests.filter(r => r.follower.id != user.id); }); }, diff --git a/src/client/app/desktop/views/components/renote-form.vue b/src/client/app/desktop/views/components/renote-form.vue index 2877c222b9..79e21a28a3 100644 --- a/src/client/app/desktop/views/components/renote-form.vue +++ b/src/client/app/desktop/views/components/renote-form.vue @@ -30,7 +30,7 @@ export default Vue.extend({ methods: { ok() { this.wait = true; - (this as any).api('notes/create', { + this.$root.api('notes/create', { renoteId: this.note.id }).then(data => { this.$emit('posted'); diff --git a/src/client/app/desktop/views/components/settings.2fa.vue b/src/client/app/desktop/views/components/settings.2fa.vue index 9050f8c9b1..71d4eeb788 100644 --- a/src/client/app/desktop/views/components/settings.2fa.vue +++ b/src/client/app/desktop/views/components/settings.2fa.vue @@ -39,7 +39,7 @@ export default Vue.extend({ title: this.$t('enter-password'), type: 'password' }).then(password => { - (this as any).api('i/2fa/register', { + this.$root.api('i/2fa/register', { password: password }).then(data => { this.data = data; @@ -52,7 +52,7 @@ export default Vue.extend({ title: this.$t('enter-password'), type: 'password' }).then(password => { - (this as any).api('i/2fa/unregister', { + this.$root.api('i/2fa/unregister', { password: password }).then(() => { (this as any).apis.notify(this.$t('unregistered')); @@ -62,7 +62,7 @@ export default Vue.extend({ }, submit() { - (this as any).api('i/2fa/done', { + this.$root.api('i/2fa/done', { token: this.token }).then(() => { (this as any).apis.notify(this.$t('success')); diff --git a/src/client/app/desktop/views/components/settings.apps.vue b/src/client/app/desktop/views/components/settings.apps.vue index de88923262..2760a81466 100644 --- a/src/client/app/desktop/views/components/settings.apps.vue +++ b/src/client/app/desktop/views/components/settings.apps.vue @@ -22,7 +22,7 @@ export default Vue.extend({ }; }, mounted() { - (this as any).api('i/authorized_apps').then(apps => { + this.$root.api('i/authorized_apps').then(apps => { this.apps = apps; this.fetching = false; }); diff --git a/src/client/app/desktop/views/components/settings.signins.vue b/src/client/app/desktop/views/components/settings.signins.vue index 1bc3bd0ade..048fa2fc5b 100644 --- a/src/client/app/desktop/views/components/settings.signins.vue +++ b/src/client/app/desktop/views/components/settings.signins.vue @@ -28,12 +28,12 @@ export default Vue.extend({ }, mounted() { - (this as any).api('i/signin_history').then(signins => { + this.$root.api('i/signin_history').then(signins => { this.signins = signins; this.fetching = false; }); - this.connection = (this as any).os.stream.useSharedConnection('main'); + this.connection = this.$root.stream.useSharedConnection('main'); this.connection.on('signin', this.onSignin); }, diff --git a/src/client/app/desktop/views/components/settings.vue b/src/client/app/desktop/views/components/settings.vue index 65296b0768..81177b3f63 100644 --- a/src/client/app/desktop/views/components/settings.vue +++ b/src/client/app/desktop/views/components/settings.vue @@ -500,13 +500,13 @@ export default Vue.extend({ } }, created() { - (this as any).os.getMeta().then(meta => { + this.$root.getMeta().then(meta => { this.meta = meta; }); }, methods: { readAllUnreadNotes() { - (this as any).api('i/read_all_unread_notes'); + this.$root.api('i/read_all_unread_notes'); }, customizeHome() { this.$router.push('/i/customize-home'); @@ -516,18 +516,18 @@ export default Vue.extend({ (this as any).apis.chooseDriveFile({ multiple: false }).then(file => { - (this as any).api('i/update', { + this.$root.api('i/update', { wallpaperId: file.id }); }); }, deleteWallpaper() { - (this as any).api('i/update', { + this.$root.api('i/update', { wallpaperId: null }); }, onChangeAutoWatch(v) { - (this as any).api('i/update', { + this.$root.api('i/update', { autoWatch: v }); }, diff --git a/src/client/app/desktop/views/components/timeline.core.vue b/src/client/app/desktop/views/components/timeline.core.vue index 94126dcf17..f22ab49000 100644 --- a/src/client/app/desktop/views/components/timeline.core.vue +++ b/src/client/app/desktop/views/components/timeline.core.vue @@ -65,32 +65,32 @@ export default Vue.extend({ this.query = { query: this.tagTl.query }; - this.connection = (this as any).os.stream.connectToChannel('hashtag', { q: this.tagTl.query }); + this.connection = this.$root.stream.connectToChannel('hashtag', { q: this.tagTl.query }); this.connection.on('note', prepend); } else if (this.src == 'home') { this.endpoint = 'notes/timeline'; const onChangeFollowing = () => { this.fetch(); }; - this.connection = (this as any).os.stream.useSharedConnection('homeTimeline'); + this.connection = this.$root.stream.useSharedConnection('homeTimeline'); this.connection.on('note', prepend); this.connection.on('follow', onChangeFollowing); this.connection.on('unfollow', onChangeFollowing); } else if (this.src == 'local') { this.endpoint = 'notes/local-timeline'; - this.connection = (this as any).os.stream.useSharedConnection('localTimeline'); + this.connection = this.$root.stream.useSharedConnection('localTimeline'); this.connection.on('note', prepend); } else if (this.src == 'hybrid') { this.endpoint = 'notes/hybrid-timeline'; - this.connection = (this as any).os.stream.useSharedConnection('hybridTimeline'); + this.connection = this.$root.stream.useSharedConnection('hybridTimeline'); this.connection.on('note', prepend); } else if (this.src == 'global') { this.endpoint = 'notes/global-timeline'; - this.connection = (this as any).os.stream.useSharedConnection('globalTimeline'); + this.connection = this.$root.stream.useSharedConnection('globalTimeline'); this.connection.on('note', prepend); } else if (this.src == 'mentions') { this.endpoint = 'notes/mentions'; - this.connection = (this as any).os.stream.useSharedConnection('main'); + this.connection = this.$root.stream.useSharedConnection('main'); this.connection.on('mention', prepend); } else if (this.src == 'messages') { this.endpoint = 'notes/mentions'; @@ -102,7 +102,7 @@ export default Vue.extend({ prepend(note); } }; - this.connection = (this as any).os.stream.useSharedConnection('main'); + this.connection = this.$root.stream.useSharedConnection('main'); this.connection.on('mention', onNote); } @@ -118,7 +118,7 @@ export default Vue.extend({ this.fetching = true; (this.$refs.timeline as any).init(() => new Promise((res, rej) => { - (this as any).api(this.endpoint, Object.assign({ + this.$root.api(this.endpoint, Object.assign({ limit: fetchLimit + 1, untilDate: this.date ? this.date.getTime() : undefined }, this.baseQuery, this.query)).then(notes => { @@ -138,7 +138,7 @@ export default Vue.extend({ this.moreFetching = true; - const promise = (this as any).api(this.endpoint, Object.assign({ + const promise = this.$root.api(this.endpoint, Object.assign({ limit: fetchLimit + 1, untilId: (this.$refs.timeline as any).tail().id }, this.baseQuery, this.query)); diff --git a/src/client/app/desktop/views/components/timeline.vue b/src/client/app/desktop/views/components/timeline.vue index e6f4219b59..3629b19f3f 100644 --- a/src/client/app/desktop/views/components/timeline.vue +++ b/src/client/app/desktop/views/components/timeline.vue @@ -64,7 +64,7 @@ export default Vue.extend({ }, created() { - (this as any).os.getMeta().then(meta => { + this.$root.getMeta().then(meta => { this.enableLocalTimeline = !meta.disableLocalTimeline; }); @@ -103,7 +103,7 @@ export default Vue.extend({ }, async chooseList() { - const lists = await (this as any).api('users/lists/list'); + const lists = await this.$root.api('users/lists/list'); let menu = [{ icon: 'plus', @@ -112,7 +112,7 @@ export default Vue.extend({ (this as any).apis.input({ title: this.$t('list-name'), }).then(async title => { - const list = await (this as any).api('users/lists/create', { + const list = await this.$root.api('users/lists/create', { title }); @@ -135,7 +135,7 @@ export default Vue.extend({ } }))); - this.os.new(Menu, { + this.$root.new(Menu, { source: this.$refs.listButton, compact: false, items: menu @@ -147,7 +147,7 @@ export default Vue.extend({ icon: 'plus', text: this.$t('add-tag-timeline'), action: () => { - (this as any).os.new(MkSettingsWindow, { + this.$root.new(MkSettingsWindow, { initialPage: 'hashtags' }); } @@ -166,7 +166,7 @@ export default Vue.extend({ } }))); - this.os.new(Menu, { + this.$root.new(Menu, { source: this.$refs.tagButton, compact: false, items: menu diff --git a/src/client/app/desktop/views/components/ui.header.account.vue b/src/client/app/desktop/views/components/ui.header.account.vue index 2a0424b2a5..97496c6e18 100644 --- a/src/client/app/desktop/views/components/ui.header.account.vue +++ b/src/client/app/desktop/views/components/ui.header.account.vue @@ -137,25 +137,25 @@ export default Vue.extend({ }, drive() { this.close(); - (this as any).os.new(MkDriveWindow); + this.$root.new(MkDriveWindow); }, list() { this.close(); - const w = (this as any).os.new(MkUserListsWindow); + const w = this.$root.new(MkUserListsWindow); w.$once('choosen', list => { this.$router.push(`i/lists/${ list.id }`); }); }, followRequests() { this.close(); - (this as any).os.new(MkFollowRequestsWindow); + this.$root.new(MkFollowRequestsWindow); }, settings() { this.close(); - (this as any).os.new(MkSettingsWindow); + this.$root.new(MkSettingsWindow); }, signout() { - (this as any).os.signout(); + this.$root.os.signout(); }, dark() { this.$store.commit('device/set', { diff --git a/src/client/app/desktop/views/components/ui.header.nav.vue b/src/client/app/desktop/views/components/ui.header.nav.vue index 5f98d21bd5..aed0c89be0 100644 --- a/src/client/app/desktop/views/components/ui.header.nav.vue +++ b/src/client/app/desktop/views/components/ui.header.nav.vue @@ -58,7 +58,7 @@ export default Vue.extend({ }, mounted() { if (this.$store.getters.isSignedIn) { - this.connection = (this as any).os.stream.useSharedConnection('main'); + this.connection = this.$root.stream.useSharedConnection('main'); this.connection.on('reversiInvited', this.onReversiInvited); this.connection.on('reversi_no_invites', this.onReversiNoInvites); @@ -79,11 +79,11 @@ export default Vue.extend({ }, messaging() { - (this as any).os.new(MkMessagingWindow); + this.$root.new(MkMessagingWindow); }, game() { - (this as any).os.new(MkGameWindow); + this.$root.new(MkGameWindow); }, goToTop() { diff --git a/src/client/app/desktop/views/components/ui.sidebar.vue b/src/client/app/desktop/views/components/ui.sidebar.vue index 7834892271..f1396093bc 100644 --- a/src/client/app/desktop/views/components/ui.sidebar.vue +++ b/src/client/app/desktop/views/components/ui.sidebar.vue @@ -108,7 +108,7 @@ export default Vue.extend({ mounted() { if (this.$store.getters.isSignedIn) { - this.connection = (this as any).os.stream.useSharedConnection('main'); + this.connection = this.$root.stream.useSharedConnection('main'); this.connection.on('reversiInvited', this.onReversiInvited); this.connection.on('reversi_no_invites', this.onReversiNoInvites); @@ -131,11 +131,11 @@ export default Vue.extend({ }, messaging() { - (this as any).os.new(MkMessagingWindow); + this.$root.new(MkMessagingWindow); }, game() { - (this as any).os.new(MkGameWindow); + this.$root.new(MkGameWindow); }, post() { @@ -143,26 +143,26 @@ export default Vue.extend({ }, drive() { - (this as any).os.new(MkDriveWindow); + this.$root.new(MkDriveWindow); }, list() { - const w = (this as any).os.new(MkUserListsWindow); + const w = this.$root.new(MkUserListsWindow); w.$once('choosen', list => { this.$router.push(`i/lists/${ list.id }`); }); }, followRequests() { - (this as any).os.new(MkFollowRequestsWindow); + this.$root.new(MkFollowRequestsWindow); }, settings() { - (this as any).os.new(MkSettingsWindow); + this.$root.new(MkSettingsWindow); }, signout() { - (this as any).os.signout(); + this.$root.os.signout(); }, notifications() { diff --git a/src/client/app/desktop/views/components/user-list-timeline.vue b/src/client/app/desktop/views/components/user-list-timeline.vue index d370754fef..7bdc016c6c 100644 --- a/src/client/app/desktop/views/components/user-list-timeline.vue +++ b/src/client/app/desktop/views/components/user-list-timeline.vue @@ -31,7 +31,7 @@ export default Vue.extend({ methods: { init() { if (this.connection) this.connection.dispose(); - this.connection = (this as any).os.stream.connectToChannel('userList', { + this.connection = this.$root.stream.connectToChannel('userList', { listId: this.list.id }); this.connection.on('note', this.onNote); @@ -44,7 +44,7 @@ export default Vue.extend({ this.fetching = true; (this.$refs.timeline as any).init(() => new Promise((res, rej) => { - (this as any).api('notes/user-list-timeline', { + this.$root.api('notes/user-list-timeline', { listId: this.list.id, limit: fetchLimit + 1, includeMyRenotes: this.$store.state.settings.showMyRenotes, @@ -64,7 +64,7 @@ export default Vue.extend({ more() { this.moreFetching = true; - const promise = (this as any).api('notes/user-list-timeline', { + const promise = this.$root.api('notes/user-list-timeline', { listId: this.list.id, limit: fetchLimit + 1, untilId: (this.$refs.timeline as any).tail().id, diff --git a/src/client/app/desktop/views/components/user-lists-window.vue b/src/client/app/desktop/views/components/user-lists-window.vue index 6f7d07a5f4..c8d789deab 100644 --- a/src/client/app/desktop/views/components/user-lists-window.vue +++ b/src/client/app/desktop/views/components/user-lists-window.vue @@ -22,7 +22,7 @@ export default Vue.extend({ }; }, mounted() { - (this as any).api('users/lists/list').then(lists => { + this.$root.api('users/lists/list').then(lists => { this.fetching = false; this.lists = lists; }); @@ -32,7 +32,7 @@ export default Vue.extend({ (this as any).apis.input({ title: this.$t('list-name'), }).then(async title => { - const list = await (this as any).api('users/lists/create', { + const list = await this.$root.api('users/lists/create', { title }); diff --git a/src/client/app/desktop/views/components/user-preview.vue b/src/client/app/desktop/views/components/user-preview.vue index 1ce5a06f28..ad4f60be63 100644 --- a/src/client/app/desktop/views/components/user-preview.vue +++ b/src/client/app/desktop/views/components/user-preview.vue @@ -54,7 +54,7 @@ export default Vue.extend({ parseAcct(this.user.substr(1)) : { userId: this.user }; - (this as any).api('users/show', query).then(user => { + this.$root.api('users/show', query).then(user => { this.u = user; this.open(); }); diff --git a/src/client/app/desktop/views/components/window.vue b/src/client/app/desktop/views/components/window.vue index 75335f540b..3aaf2ba949 100644 --- a/src/client/app/desktop/views/components/window.vue +++ b/src/client/app/desktop/views/components/window.vue @@ -110,7 +110,7 @@ export default Vue.extend({ this.preventMount = true; } else { // ウィンドウをウィンドウシステムに登録 - (this as any).os.windows.add(this); + this.$root.os.windows.add(this); } }, @@ -133,7 +133,7 @@ export default Vue.extend({ destroyed() { // ウィンドウをウィンドウシステムから削除 - (this as any).os.windows.remove(this); + this.$root.os.windows.remove(this); window.removeEventListener('resize', this.onBrowserResize); }, @@ -234,7 +234,7 @@ export default Vue.extend({ top() { let z = 0; - (this as any).os.windows.getAll().forEach(w => { + this.$root.os.windows.getAll().forEach(w => { if (w == this) return; const m = w.$refs.main; const mz = Number(document.defaultView.getComputedStyle(m, null).zIndex); diff --git a/src/client/app/desktop/views/pages/deck/deck.column.vue b/src/client/app/desktop/views/pages/deck/deck.column.vue index 27a1f7e970..c23e32783e 100644 --- a/src/client/app/desktop/views/pages/deck/deck.column.vue +++ b/src/client/app/desktop/views/pages/deck/deck.column.vue @@ -234,7 +234,7 @@ export default Vue.extend({ }, showMenu() { - this.os.new(Menu, { + this.$root.new(Menu, { source: this.$refs.menu, compact: false, items: this.getMenu() diff --git a/src/client/app/desktop/views/pages/deck/deck.direct.vue b/src/client/app/desktop/views/pages/deck/deck.direct.vue index c85d9c1bb9..2ceb82ca17 100644 --- a/src/client/app/desktop/views/pages/deck/deck.direct.vue +++ b/src/client/app/desktop/views/pages/deck/deck.direct.vue @@ -26,7 +26,7 @@ export default Vue.extend({ }, mounted() { - this.connection = (this as any).os.stream.useSharedConnection('main'); + this.connection = this.$root.stream.useSharedConnection('main'); this.connection.on('mention', this.onNote); this.fetch(); @@ -41,7 +41,7 @@ export default Vue.extend({ this.fetching = true; (this.$refs.timeline as any).init(() => new Promise((res, rej) => { - (this as any).api('notes/mentions', { + this.$root.api('notes/mentions', { limit: fetchLimit + 1, includeMyRenotes: this.$store.state.settings.showMyRenotes, includeRenotedMyNotes: this.$store.state.settings.showRenotedMyNotes, @@ -62,7 +62,7 @@ export default Vue.extend({ more() { this.moreFetching = true; - const promise = (this as any).api('notes/mentions', { + const promise = this.$root.api('notes/mentions', { limit: fetchLimit + 1, untilId: (this.$refs.timeline as any).tail().id, includeMyRenotes: this.$store.state.settings.showMyRenotes, diff --git a/src/client/app/desktop/views/pages/deck/deck.hashtag-column.vue b/src/client/app/desktop/views/pages/deck/deck.hashtag-column.vue index a6d09e60c6..82b976860f 100644 --- a/src/client/app/desktop/views/pages/deck/deck.hashtag-column.vue +++ b/src/client/app/desktop/views/pages/deck/deck.hashtag-column.vue @@ -39,7 +39,7 @@ export default Vue.extend({ }, mounted() { - (this as any).api('charts/hashtag', { + this.$root.api('charts/hashtag', { tag: this.tag, span: 'hour', limit: 24 diff --git a/src/client/app/desktop/views/pages/deck/deck.hashtag-tl.vue b/src/client/app/desktop/views/pages/deck/deck.hashtag-tl.vue index a4fdc2ce72..611bcce4e6 100644 --- a/src/client/app/desktop/views/pages/deck/deck.hashtag-tl.vue +++ b/src/client/app/desktop/views/pages/deck/deck.hashtag-tl.vue @@ -47,7 +47,7 @@ export default Vue.extend({ mounted() { if (this.connection) this.connection.close(); - this.connection = (this as any).os.stream.connectToChannel('hashtag', { + this.connection = this.$root.stream.connectToChannel('hashtag', { q: this.tagTl.query }); this.connection.on('note', this.onNote); @@ -64,7 +64,7 @@ export default Vue.extend({ this.fetching = true; (this.$refs.timeline as any).init(() => new Promise((res, rej) => { - (this as any).api('notes/search_by_tag', { + this.$root.api('notes/search_by_tag', { limit: fetchLimit + 1, withFiles: this.mediaOnly, includeMyRenotes: this.$store.state.settings.showMyRenotes, @@ -86,7 +86,7 @@ export default Vue.extend({ more() { this.moreFetching = true; - const promise = (this as any).api('notes/search_by_tag', { + const promise = this.$root.api('notes/search_by_tag', { limit: fetchLimit + 1, untilId: (this.$refs.timeline as any).tail().id, withFiles: this.mediaOnly, diff --git a/src/client/app/desktop/views/pages/deck/deck.list-tl.vue b/src/client/app/desktop/views/pages/deck/deck.list-tl.vue index 714c267668..d65745f06f 100644 --- a/src/client/app/desktop/views/pages/deck/deck.list-tl.vue +++ b/src/client/app/desktop/views/pages/deck/deck.list-tl.vue @@ -47,7 +47,7 @@ export default Vue.extend({ mounted() { if (this.connection) this.connection.dispose(); - this.connection = (this as any).os.stream.connectToChannel('userList', { + this.connection = this.$root.stream.connectToChannel('userList', { listId: this.list.id }); this.connection.on('note', this.onNote); @@ -66,7 +66,7 @@ export default Vue.extend({ this.fetching = true; (this.$refs.timeline as any).init(() => new Promise((res, rej) => { - (this as any).api('notes/user-list-timeline', { + this.$root.api('notes/user-list-timeline', { listId: this.list.id, limit: fetchLimit + 1, withFiles: this.mediaOnly, @@ -88,7 +88,7 @@ export default Vue.extend({ more() { this.moreFetching = true; - const promise = (this as any).api('notes/user-list-timeline', { + const promise = this.$root.api('notes/user-list-timeline', { listId: this.list.id, limit: fetchLimit + 1, untilId: (this.$refs.timeline as any).tail().id, diff --git a/src/client/app/desktop/views/pages/deck/deck.mentions.vue b/src/client/app/desktop/views/pages/deck/deck.mentions.vue index 1935d26722..9921b3ca04 100644 --- a/src/client/app/desktop/views/pages/deck/deck.mentions.vue +++ b/src/client/app/desktop/views/pages/deck/deck.mentions.vue @@ -26,7 +26,7 @@ export default Vue.extend({ }, mounted() { - this.connection = (this as any).os.stream.useSharedConnection('main'); + this.connection = this.$root.stream.useSharedConnection('main'); this.connection.on('mention', this.onNote); this.fetch(); @@ -41,7 +41,7 @@ export default Vue.extend({ this.fetching = true; (this.$refs.timeline as any).init(() => new Promise((res, rej) => { - (this as any).api('notes/mentions', { + this.$root.api('notes/mentions', { limit: fetchLimit + 1, includeMyRenotes: this.$store.state.settings.showMyRenotes, includeRenotedMyNotes: this.$store.state.settings.showRenotedMyNotes, @@ -61,7 +61,7 @@ export default Vue.extend({ more() { this.moreFetching = true; - const promise = (this as any).api('notes/mentions', { + const promise = this.$root.api('notes/mentions', { limit: fetchLimit + 1, untilId: (this.$refs.timeline as any).tail().id, includeMyRenotes: this.$store.state.settings.showMyRenotes, diff --git a/src/client/app/desktop/views/pages/deck/deck.note-column.vue b/src/client/app/desktop/views/pages/deck/deck.note-column.vue index c90b5f61b7..43db32c854 100644 --- a/src/client/app/desktop/views/pages/deck/deck.note-column.vue +++ b/src/client/app/desktop/views/pages/deck/deck.note-column.vue @@ -52,7 +52,7 @@ export default Vue.extend({ }, created() { - (this as any).api('notes/show', { noteId: this.noteId }).then(note => { + this.$root.api('notes/show', { noteId: this.noteId }).then(note => { this.note = note; this.fetching = false; }); diff --git a/src/client/app/desktop/views/pages/deck/deck.notifications.vue b/src/client/app/desktop/views/pages/deck/deck.notifications.vue index 3071795706..cf6dcc571b 100644 --- a/src/client/app/desktop/views/pages/deck/deck.notifications.vue +++ b/src/client/app/desktop/views/pages/deck/deck.notifications.vue @@ -68,7 +68,7 @@ export default Vue.extend({ }, mounted() { - this.connection = (this as any).os.stream.useSharedConnection('main'); + this.connection = this.$root.stream.useSharedConnection('main'); this.connection.on('notification', this.onNotification); @@ -77,7 +77,7 @@ export default Vue.extend({ const max = 10; - (this as any).api('i/notifications', { + this.$root.api('i/notifications', { limit: max + 1 }).then(notifications => { if (notifications.length == max + 1) { @@ -103,7 +103,7 @@ export default Vue.extend({ const max = 20; - (this as any).api('i/notifications', { + this.$root.api('i/notifications', { limit: max + 1, untilId: this.notifications[this.notifications.length - 1].id }).then(notifications => { @@ -120,7 +120,7 @@ export default Vue.extend({ onNotification(notification) { // TODO: ユーザーが画面を見てないと思われるとき(ブラウザやタブがアクティブじゃないなど)は送信しない - (this as any).os.stream.send('readNotification', { + this.$root.stream.send('readNotification', { id: notification.id }); diff --git a/src/client/app/desktop/views/pages/deck/deck.tl.vue b/src/client/app/desktop/views/pages/deck/deck.tl.vue index e9507cdf29..3e87670827 100644 --- a/src/client/app/desktop/views/pages/deck/deck.tl.vue +++ b/src/client/app/desktop/views/pages/deck/deck.tl.vue @@ -43,10 +43,10 @@ export default Vue.extend({ computed: { stream(): any { switch (this.src) { - case 'home': return (this as any).os.stream.useSharedConnection('homeTimeline'); - case 'local': return (this as any).os.stream.useSharedConnection('localTimeline'); - case 'hybrid': return (this as any).os.stream.useSharedConnection('hybridTimeline'); - case 'global': return (this as any).os.stream.useSharedConnection('globalTimeline'); + case 'home': return this.$root.stream.useSharedConnection('homeTimeline'); + case 'local': return this.$root.stream.useSharedConnection('localTimeline'); + case 'hybrid': return this.$root.stream.useSharedConnection('hybridTimeline'); + case 'global': return this.$root.stream.useSharedConnection('globalTimeline'); } }, @@ -87,7 +87,7 @@ export default Vue.extend({ this.fetching = true; (this.$refs.timeline as any).init(() => new Promise((res, rej) => { - (this as any).api(this.endpoint, { + this.$root.api(this.endpoint, { limit: fetchLimit + 1, withFiles: this.mediaOnly, includeMyRenotes: this.$store.state.settings.showMyRenotes, @@ -108,7 +108,7 @@ export default Vue.extend({ more() { this.moreFetching = true; - const promise = (this as any).api(this.endpoint, { + const promise = this.$root.api(this.endpoint, { limit: fetchLimit + 1, withFiles: this.mediaOnly, untilId: (this.$refs.timeline as any).tail().id, diff --git a/src/client/app/desktop/views/pages/deck/deck.user-column.vue b/src/client/app/desktop/views/pages/deck/deck.user-column.vue index c4da00f3d3..3404280c81 100644 --- a/src/client/app/desktop/views/pages/deck/deck.user-column.vue +++ b/src/client/app/desktop/views/pages/deck/deck.user-column.vue @@ -138,7 +138,7 @@ export default Vue.extend({ }, created() { - (this as any).api('users/show', parseAcct(this.acct)).then(user => { + this.$root.api('users/show', parseAcct(this.acct)).then(user => { this.user = user; this.fetching = false; @@ -152,7 +152,7 @@ export default Vue.extend({ 'image/gif' ]; - (this as any).api('users/notes', { + this.$root.api('users/notes', { userId: this.user.id, fileType: image, limit: 9 @@ -166,7 +166,7 @@ export default Vue.extend({ this.images = files.filter(f => image.includes(f.type)).slice(0, 9); }); - (this as any).api('charts/user/notes', { + this.$root.api('charts/user/notes', { userId: this.user.id, span: 'day', limit: 21 @@ -251,7 +251,7 @@ export default Vue.extend({ methods: { initTl() { return new Promise((res, rej) => { - (this as any).api('users/notes', { + this.$root.api('users/notes', { userId: this.user.id, limit: fetchLimit + 1, withFiles: this.withFiles, @@ -271,7 +271,7 @@ export default Vue.extend({ fetchMoreNotes() { this.moreFetching = true; - const promise = (this as any).api('users/notes', { + const promise = this.$root.api('users/notes', { userId: this.user.id, limit: fetchLimit + 1, untilId: (this.$refs.timeline as any).tail().id, @@ -299,19 +299,19 @@ export default Vue.extend({ icon: 'list', text: this.$t('push-to-a-list'), action: () => { - const w = (this as any).os.new(MkUserListsWindow); + const w = this.$root.new(MkUserListsWindow); w.$once('choosen', async list => { w.close(); - await (this as any).api('users/lists/push', { + await this.$root.api('users/lists/push', { listId: list.id, userId: this.user.id }); - (this as any).os.new(Ok); + this.$root.new(Ok); }); } }]; - this.os.new(Menu, { + this.$root.new(Menu, { source: this.$refs.menu, compact: false, items: menu diff --git a/src/client/app/desktop/views/pages/deck/deck.vue b/src/client/app/desktop/views/pages/deck/deck.vue index 7badd2a9fe..8acc908ecc 100644 --- a/src/client/app/desktop/views/pages/deck/deck.vue +++ b/src/client/app/desktop/views/pages/deck/deck.vue @@ -131,7 +131,7 @@ export default Vue.extend({ }, mounted() { - document.title = (this as any).os.instanceName; + document.title = this.$root.os.instanceName; document.documentElement.style.overflow = 'hidden'; }, @@ -180,7 +180,7 @@ export default Vue.extend({ }, add() { - this.os.new(Menu, { + this.$root.new(Menu, { source: this.$refs.add, compact: true, items: [{ @@ -241,7 +241,7 @@ export default Vue.extend({ icon: 'list', text: this.$t('@deck.list'), action: () => { - const w = (this as any).os.new(MkUserListsWindow); + const w = this.$root.new(MkUserListsWindow); w.$once('choosen', list => { this.$store.dispatch('settings/addDeckColumn', { id: uuid(), diff --git a/src/client/app/desktop/views/pages/favorites.vue b/src/client/app/desktop/views/pages/favorites.vue index 1463dc2d6b..f96783a301 100644 --- a/src/client/app/desktop/views/pages/favorites.vue +++ b/src/client/app/desktop/views/pages/favorites.vue @@ -32,7 +32,7 @@ export default Vue.extend({ Progress.start(); this.fetching = true; - (this as any).api('i/favorites', { + this.$root.api('i/favorites', { limit: 11 }).then(favorites => { if (favorites.length == 11) { @@ -48,7 +48,7 @@ export default Vue.extend({ }, more() { this.moreFetching = true; - (this as any).api('i/favorites', { + this.$root.api('i/favorites', { limit: 11, untilId: this.favorites[this.favorites.length - 1].id }).then(favorites => { diff --git a/src/client/app/desktop/views/pages/home.vue b/src/client/app/desktop/views/pages/home.vue index e595ef4c36..3195f948aa 100644 --- a/src/client/app/desktop/views/pages/home.vue +++ b/src/client/app/desktop/views/pages/home.vue @@ -23,7 +23,7 @@ export default Vue.extend({ } }, mounted() { - document.title = (this as any).os.instanceName; + document.title = this.$root.os.instanceName; Progress.start(); }, diff --git a/src/client/app/desktop/views/pages/messaging-room.vue b/src/client/app/desktop/views/pages/messaging-room.vue index ad8bc290f6..8bb3976e5f 100644 --- a/src/client/app/desktop/views/pages/messaging-room.vue +++ b/src/client/app/desktop/views/pages/messaging-room.vue @@ -44,7 +44,7 @@ export default Vue.extend({ Progress.start(); this.fetching = true; - (this as any).api('users/show', parseAcct(this.$route.params.user)).then(user => { + this.$root.api('users/show', parseAcct(this.$route.params.user)).then(user => { this.user = user; this.fetching = false; diff --git a/src/client/app/desktop/views/pages/note.vue b/src/client/app/desktop/views/pages/note.vue index 8aed7839cd..46d39d0b4a 100644 --- a/src/client/app/desktop/views/pages/note.vue +++ b/src/client/app/desktop/views/pages/note.vue @@ -34,7 +34,7 @@ export default Vue.extend({ Progress.start(); this.fetching = true; - (this as any).api('notes/show', { + this.$root.api('notes/show', { noteId: this.$route.params.note }).then(note => { this.note = note; diff --git a/src/client/app/desktop/views/pages/search.vue b/src/client/app/desktop/views/pages/search.vue index 5af103c04e..ff644a62dc 100644 --- a/src/client/app/desktop/views/pages/search.vue +++ b/src/client/app/desktop/views/pages/search.vue @@ -59,7 +59,7 @@ export default Vue.extend({ Progress.start(); (this.$refs.timeline as any).init(() => new Promise((res, rej) => { - (this as any).api('notes/search', { + this.$root.api('notes/search', { limit: limit + 1, offset: this.offset, query: this.q @@ -82,7 +82,7 @@ export default Vue.extend({ more() { this.offset += limit; - const promise = (this as any).api('notes/search', { + const promise = this.$root.api('notes/search', { limit: limit + 1, offset: this.offset, query: this.q diff --git a/src/client/app/desktop/views/pages/share.vue b/src/client/app/desktop/views/pages/share.vue index b5429067f9..c4ec356d9d 100644 --- a/src/client/app/desktop/views/pages/share.vue +++ b/src/client/app/desktop/views/pages/share.vue @@ -29,7 +29,7 @@ export default Vue.extend({ } }, mounted() { - (this as any).os.getMeta().then(meta => { + this.$root.getMeta().then(meta => { this.name = meta.name; }); } diff --git a/src/client/app/desktop/views/pages/tag.vue b/src/client/app/desktop/views/pages/tag.vue index c46186d782..9245f69c99 100644 --- a/src/client/app/desktop/views/pages/tag.vue +++ b/src/client/app/desktop/views/pages/tag.vue @@ -52,7 +52,7 @@ export default Vue.extend({ Progress.start(); (this.$refs.timeline as any).init(() => new Promise((res, rej) => { - (this as any).api('notes/search_by_tag', { + this.$root.api('notes/search_by_tag', { limit: limit + 1, offset: this.offset, tag: this.$route.params.tag @@ -71,7 +71,7 @@ export default Vue.extend({ more() { this.offset += limit; - const promise = (this as any).api('notes/search_by_tag', { + const promise = this.$root.api('notes/search_by_tag', { limit: limit + 1, offset: this.offset, tag: this.$route.params.tag diff --git a/src/client/app/desktop/views/pages/user-following-or-followers.vue b/src/client/app/desktop/views/pages/user-following-or-followers.vue index c48e35837a..83ba4c7a93 100644 --- a/src/client/app/desktop/views/pages/user-following-or-followers.vue +++ b/src/client/app/desktop/views/pages/user-following-or-followers.vue @@ -54,9 +54,9 @@ export default Vue.extend({ fetch() { this.fetching = true; Progress.start(); - (this as any).api('users/show', parseAcct(this.$route.params.user)).then(user => { + this.$root.api('users/show', parseAcct(this.$route.params.user)).then(user => { this.user = user; - (this as any).api(this.endpoint, { + this.$root.api(this.endpoint, { userId: this.user.id, iknow: false, limit: limit @@ -70,7 +70,7 @@ export default Vue.extend({ }, fetchMore() { - (this as any).api(this.endpoint, { + this.$root.api(this.endpoint, { userId: this.user.id, iknow: false, limit: limit, diff --git a/src/client/app/desktop/views/pages/user/user.followers-you-know.vue b/src/client/app/desktop/views/pages/user/user.followers-you-know.vue index 8e0be39ac3..78d6044c02 100644 --- a/src/client/app/desktop/views/pages/user/user.followers-you-know.vue +++ b/src/client/app/desktop/views/pages/user/user.followers-you-know.vue @@ -25,7 +25,7 @@ export default Vue.extend({ }; }, mounted() { - (this as any).api('users/followers', { + this.$root.api('users/followers', { userId: this.user.id, iknow: true, limit: 16 diff --git a/src/client/app/desktop/views/pages/user/user.friends.vue b/src/client/app/desktop/views/pages/user/user.friends.vue index 103fd97aa4..ed0fcd03c4 100644 --- a/src/client/app/desktop/views/pages/user/user.friends.vue +++ b/src/client/app/desktop/views/pages/user/user.friends.vue @@ -30,7 +30,7 @@ export default Vue.extend({ }; }, mounted() { - (this as any).api('users/get_frequently_replied_users', { + this.$root.api('users/get_frequently_replied_users', { userId: this.user.id, limit: 4 }).then(docs => { diff --git a/src/client/app/desktop/views/pages/user/user.photos.vue b/src/client/app/desktop/views/pages/user/user.photos.vue index 9b56156f45..4c7589a11b 100644 --- a/src/client/app/desktop/views/pages/user/user.photos.vue +++ b/src/client/app/desktop/views/pages/user/user.photos.vue @@ -24,7 +24,7 @@ export default Vue.extend({ }; }, mounted() { - (this as any).api('users/notes', { + this.$root.api('users/notes', { userId: this.user.id, withFiles: true, limit: 9 diff --git a/src/client/app/desktop/views/pages/user/user.profile.vue b/src/client/app/desktop/views/pages/user/user.profile.vue index d0585bfab4..c40be90799 100644 --- a/src/client/app/desktop/views/pages/user/user.profile.vue +++ b/src/client/app/desktop/views/pages/user/user.profile.vue @@ -33,7 +33,7 @@ export default Vue.extend({ methods: { stalk() { - (this as any).api('following/stalk', { + this.$root.api('following/stalk', { userId: this.user.id }).then(() => { this.user.isStalking = true; @@ -43,7 +43,7 @@ export default Vue.extend({ }, unstalk() { - (this as any).api('following/unstalk', { + this.$root.api('following/unstalk', { userId: this.user.id }).then(() => { this.user.isStalking = false; @@ -53,7 +53,7 @@ export default Vue.extend({ }, mute() { - (this as any).api('mute/create', { + this.$root.api('mute/create', { userId: this.user.id }).then(() => { this.user.isMuted = true; @@ -63,7 +63,7 @@ export default Vue.extend({ }, unmute() { - (this as any).api('mute/delete', { + this.$root.api('mute/delete', { userId: this.user.id }).then(() => { this.user.isMuted = false; @@ -74,7 +74,7 @@ export default Vue.extend({ block() { if (!window.confirm(this.$t('block-confirm'))) return; - (this as any).api('blocking/create', { + this.$root.api('blocking/create', { userId: this.user.id }).then(() => { this.user.isBlocking = true; @@ -84,7 +84,7 @@ export default Vue.extend({ }, unblock() { - (this as any).api('blocking/delete', { + this.$root.api('blocking/delete', { userId: this.user.id }).then(() => { this.user.isBlocking = false; @@ -94,10 +94,10 @@ export default Vue.extend({ }, list() { - const w = (this as any).os.new(MkUserListsWindow); + const w = this.$root.new(MkUserListsWindow); w.$once('choosen', async list => { w.close(); - await (this as any).api('users/lists/push', { + await this.$root.api('users/lists/push', { listId: list.id, userId: this.user.id }); diff --git a/src/client/app/desktop/views/pages/user/user.timeline.vue b/src/client/app/desktop/views/pages/user/user.timeline.vue index 84624bc9e7..affa1f11f4 100644 --- a/src/client/app/desktop/views/pages/user/user.timeline.vue +++ b/src/client/app/desktop/views/pages/user/user.timeline.vue @@ -60,7 +60,7 @@ export default Vue.extend({ fetch(cb?) { this.fetching = true; (this.$refs.timeline as any).init(() => new Promise((res, rej) => { - (this as any).api('users/notes', { + this.$root.api('users/notes', { userId: this.user.id, limit: fetchLimit + 1, untilDate: this.date ? this.date.getTime() : undefined, @@ -81,7 +81,7 @@ export default Vue.extend({ more() { this.moreFetching = true; - const promise = (this as any).api('users/notes', { + const promise = this.$root.api('users/notes', { userId: this.user.id, limit: fetchLimit + 1, includeReplies: this.mode == 'with-replies', diff --git a/src/client/app/desktop/views/pages/user/user.vue b/src/client/app/desktop/views/pages/user/user.vue index 7c430cbcbd..758a98137b 100644 --- a/src/client/app/desktop/views/pages/user/user.vue +++ b/src/client/app/desktop/views/pages/user/user.vue @@ -68,7 +68,7 @@ export default Vue.extend({ fetch() { this.fetching = true; Progress.start(); - (this as any).api('users/show', parseAcct(this.$route.params.user)).then(user => { + this.$root.api('users/show', parseAcct(this.$route.params.user)).then(user => { this.user = user; this.fetching = false; Progress.done(); diff --git a/src/client/app/desktop/views/pages/welcome.vue b/src/client/app/desktop/views/pages/welcome.vue index 7285647405..c12689fdcc 100644 --- a/src/client/app/desktop/views/pages/welcome.vue +++ b/src/client/app/desktop/views/pages/welcome.vue @@ -169,7 +169,7 @@ export default Vue.extend({ }, created() { - (this as any).os.getMeta().then(meta => { + this.$root.getMeta().then(meta => { this.meta = meta; this.name = meta.name; this.description = meta.description; @@ -177,7 +177,7 @@ export default Vue.extend({ this.banner = meta.bannerUrl; }); - (this as any).api('stats').then(stats => { + this.$root.api('stats').then(stats => { this.stats = stats; }); @@ -187,7 +187,7 @@ export default Vue.extend({ 'image/gif' ]; - (this as any).api('notes/local-timeline', { + this.$root.api('notes/local-timeline', { fileType: image, excludeNsfw: true, limit: 6 diff --git a/src/client/app/desktop/views/widgets/messaging.vue b/src/client/app/desktop/views/widgets/messaging.vue index 35e15d1b33..887240be85 100644 --- a/src/client/app/desktop/views/widgets/messaging.vue +++ b/src/client/app/desktop/views/widgets/messaging.vue @@ -24,12 +24,12 @@ export default define({ i18n: i18n('desktop/views/widgets/messaging.vue'), methods: { navigate(user) { - (this as any).os.new(MkMessagingRoomWindow, { + this.$root.new(MkMessagingRoomWindow, { user: user }); }, add() { - (this as any).os.new(MkMessagingWindow); + this.$root.new(MkMessagingWindow); }, func() { if (this.props.design == 1) { diff --git a/src/client/app/desktop/views/widgets/polls.vue b/src/client/app/desktop/views/widgets/polls.vue index 71e07ce145..eee8408be4 100644 --- a/src/client/app/desktop/views/widgets/polls.vue +++ b/src/client/app/desktop/views/widgets/polls.vue @@ -47,7 +47,7 @@ export default define({ this.fetching = true; this.poll = null; - (this as any).api('notes/polls/recommendation', { + this.$root.api('notes/polls/recommendation', { limit: 1, offset: this.offset }).then(notes => { diff --git a/src/client/app/desktop/views/widgets/post-form.vue b/src/client/app/desktop/views/widgets/post-form.vue index f7526d7f8d..c898868848 100644 --- a/src/client/app/desktop/views/widgets/post-form.vue +++ b/src/client/app/desktop/views/widgets/post-form.vue @@ -53,7 +53,7 @@ export default define({ post() { this.posting = true; - (this as any).api('notes/create', { + this.$root.api('notes/create', { text: this.text }).then(data => { this.clear(); diff --git a/src/client/app/desktop/views/widgets/trends.vue b/src/client/app/desktop/views/widgets/trends.vue index 33a9177629..a1bb3ea36f 100644 --- a/src/client/app/desktop/views/widgets/trends.vue +++ b/src/client/app/desktop/views/widgets/trends.vue @@ -46,7 +46,7 @@ export default define({ this.fetching = true; this.note = null; - (this as any).api('notes/trend', { + this.$root.api('notes/trend', { limit: 1, offset: this.offset, renote: false, diff --git a/src/client/app/desktop/views/widgets/users.vue b/src/client/app/desktop/views/widgets/users.vue index 1e76bab315..8ee73d0ded 100644 --- a/src/client/app/desktop/views/widgets/users.vue +++ b/src/client/app/desktop/views/widgets/users.vue @@ -53,7 +53,7 @@ export default define({ this.fetching = true; this.users = []; - (this as any).api('users/recommendation', { + this.$root.api('users/recommendation', { limit: limit, offset: limit * this.page }).then(users => { diff --git a/src/client/app/dev/views/app.vue b/src/client/app/dev/views/app.vue index 4aced2274b..2379d71aa5 100644 --- a/src/client/app/dev/views/app.vue +++ b/src/client/app/dev/views/app.vue @@ -29,7 +29,7 @@ export default Vue.extend({ methods: { fetch() { this.fetching = true; - (this as any).api('app/show', { + this.$root.api('app/show', { appId: this.$route.params.id }).then(app => { this.app = app; diff --git a/src/client/app/dev/views/apps.vue b/src/client/app/dev/views/apps.vue index 4c8de9d48e..78a7cede98 100644 --- a/src/client/app/dev/views/apps.vue +++ b/src/client/app/dev/views/apps.vue @@ -30,7 +30,7 @@ export default Vue.extend({ }; }, mounted() { - (this as any).api('my/apps').then(apps => { + this.$root.api('my/apps').then(apps => { this.apps = apps; this.fetching = false; }); diff --git a/src/client/app/dev/views/new-app.vue b/src/client/app/dev/views/new-app.vue index 382d54fd67..298b6f9925 100644 --- a/src/client/app/dev/views/new-app.vue +++ b/src/client/app/dev/views/new-app.vue @@ -50,7 +50,7 @@ export default Vue.extend({ }, methods: { onSubmit() { - (this as any).api('app/create', { + this.$root.api('app/create', { name: this.name, description: this.description, callbackUrl: this.cb, diff --git a/src/client/app/init.ts b/src/client/app/init.ts index 87406f296f..0817c92f19 100644 --- a/src/client/app/init.ts +++ b/src/client/app/init.ts @@ -270,23 +270,6 @@ export default (callback: (launch: (router: VueRouter, api?: (os: MiOS) => API) } }, { passive: true }); - Vue.mixin({ - data() { - return { - //os, - os: { - stream: os.stream, - getMeta: os.getMeta, - getMetaSync: os.getMetaSync, - new: os.new, - windows: os.windows - }, - api: os.api, - apis: os.apis - }; - } - }); - const app = new Vue({ i18n: new VueI18n({ sync: false, @@ -296,6 +279,21 @@ export default (callback: (launch: (router: VueRouter, api?: (os: MiOS) => API) } }), store: os.store, + data() { + return { + os: { + windows: os.windows + }, + stream: os.stream, + apis: os.apis + }; + }, + methods: { + api: os.api, + getMeta: os.getMeta, + getMetaSync: os.getMetaSync, + new: os.new, + }, router, render: createEl => createEl(App) }); @@ -308,11 +306,7 @@ export default (callback: (launch: (router: VueRouter, api?: (os: MiOS) => API) return [app, os] as [Vue, MiOS]; }; - try { - callback(launch); - } catch (e) { - panic(e); - } + callback(launch); //#region 更新チェック const preventUpdate = os.store.state.device.preventUpdate; @@ -324,25 +318,3 @@ export default (callback: (launch: (router: VueRouter, api?: (os: MiOS) => API) //#endregion }); }; - -// BSoD -function panic(e) { - console.error(e); - - // Display blue screen - document.documentElement.style.background = '#1269e2'; - document.body.innerHTML = - '
' - + '

%i18n.common.BSoD.fatal-error%

' - + '

%i18n.common.BSoD.update-browser-os%

' - + '
' - + `

%i18n.common.BSoD.error-code%: ${e.toString()}

` - + `

%i18n.common.BSoD.browser-version%: ${navigator.userAgent}

` - + `

%i18n.common.BSoD.client-version%: ${version}

` - + '
' - + '

%i18n.common.BSoD.email-support%

' - + '

%i18n.common.BSoD.thanks%

' - + '
'; - - // TODO: Report the bug -} diff --git a/src/client/app/mobile/views/components/activity.vue b/src/client/app/mobile/views/components/activity.vue index 627bebbd32..18bff253de 100644 --- a/src/client/app/mobile/views/components/activity.vue +++ b/src/client/app/mobile/views/components/activity.vue @@ -18,7 +18,7 @@ export default Vue.extend({ }; }, mounted() { - (this as any).api('charts/user/notes', { + this.$root.api('charts/user/notes', { userId: this.user.id, span: 'day', limit: 21 diff --git a/src/client/app/mobile/views/components/drive.file-detail.vue b/src/client/app/mobile/views/components/drive.file-detail.vue index cda907fcd1..83ee03d1ea 100644 --- a/src/client/app/mobile/views/components/drive.file-detail.vue +++ b/src/client/app/mobile/views/components/drive.file-detail.vue @@ -92,7 +92,7 @@ export default Vue.extend({ rename() { const name = window.prompt(this.$t('rename'), this.file.name); if (name == null || name == '' || name == this.file.name) return; - (this as any).api('drive/files/update', { + this.$root.api('drive/files/update', { fileId: this.file.id, name: name }).then(() => { @@ -102,7 +102,7 @@ export default Vue.extend({ move() { (this as any).apis.chooseDriveFolder().then(folder => { - (this as any).api('drive/files/update', { + this.$root.api('drive/files/update', { fileId: this.file.id, folderId: folder == null ? null : folder.id }).then(() => { @@ -112,7 +112,7 @@ export default Vue.extend({ }, del() { - (this as any).api('drive/files/delete', { + this.$root.api('drive/files/delete', { fileId: this.file.id }).then(() => { this.browser.cd(this.file.folderId, true); @@ -120,7 +120,7 @@ export default Vue.extend({ }, toggleSensitive() { - (this as any).api('drive/files/update', { + this.$root.api('drive/files/update', { fileId: this.file.id, isSensitive: !this.file.isSensitive }); diff --git a/src/client/app/mobile/views/components/drive.vue b/src/client/app/mobile/views/components/drive.vue index b61af722cf..7c0a2cd74a 100644 --- a/src/client/app/mobile/views/components/drive.vue +++ b/src/client/app/mobile/views/components/drive.vue @@ -103,7 +103,7 @@ export default Vue.extend({ } }, mounted() { - this.connection = (this as any).os.stream.useSharedConnection('drive'); + this.connection = this.$root.stream.useSharedConnection('drive'); this.connection.on('fileCreated', this.onStreamDriveFileCreated); this.connection.on('fileUpdated', this.onStreamDriveFileUpdated); @@ -174,7 +174,7 @@ export default Vue.extend({ this.fetching = true; - (this as any).api('drive/folders/show', { + this.$root.api('drive/folders/show', { folderId: target }).then(folder => { this.folder = folder; @@ -269,7 +269,7 @@ export default Vue.extend({ const filesMax = 20; // フォルダ一覧取得 - (this as any).api('drive/folders', { + this.$root.api('drive/folders', { folderId: this.folder ? this.folder.id : null, limit: foldersMax + 1 }).then(folders => { @@ -282,7 +282,7 @@ export default Vue.extend({ }); // ファイル一覧取得 - (this as any).api('drive/files', { + this.$root.api('drive/files', { folderId: this.folder ? this.folder.id : null, limit: filesMax + 1 }).then(files => { @@ -312,7 +312,7 @@ export default Vue.extend({ if (this.folder == null) { // Fetch addtional drive info - (this as any).api('drive').then(info => { + this.$root.api('drive').then(info => { this.info = info; }); } @@ -325,7 +325,7 @@ export default Vue.extend({ const max = 30; // ファイル一覧取得 - (this as any).api('drive/files', { + this.$root.api('drive/files', { folderId: this.folder ? this.folder.id : null, limit: max + 1, untilId: this.files[this.files.length - 1].id @@ -364,7 +364,7 @@ export default Vue.extend({ this.fetching = true; - (this as any).api('drive/files/show', { + this.$root.api('drive/files/show', { fileId: file }).then(file => { this.file = file; @@ -411,7 +411,7 @@ export default Vue.extend({ createFolder() { const name = window.prompt(this.$t('folder-name')); if (name == null || name == '') return; - (this as any).api('drive/folders/create', { + this.$root.api('drive/folders/create', { name: name, parentId: this.folder ? this.folder.id : undefined }).then(folder => { @@ -426,7 +426,7 @@ export default Vue.extend({ } const name = window.prompt(this.$t('folder-name'), this.folder.name); if (name == null || name == '') return; - (this as any).api('drive/folders/update', { + this.$root.api('drive/folders/update', { name: name, folderId: this.folder.id }).then(folder => { @@ -440,7 +440,7 @@ export default Vue.extend({ return; } (this as any).apis.chooseDriveFolder().then(folder => { - (this as any).api('drive/folders/update', { + this.$root.api('drive/folders/update', { parentId: folder ? folder.id : null, folderId: this.folder.id }).then(folder => { @@ -452,7 +452,7 @@ export default Vue.extend({ urlUpload() { const url = window.prompt(this.$t('url-prompt')); if (url == null || url == '') return; - (this as any).api('drive/files/upload_from_url', { + this.$root.api('drive/files/upload_from_url', { url: url, folderId: this.folder ? this.folder.id : undefined }); diff --git a/src/client/app/mobile/views/components/follow-button.vue b/src/client/app/mobile/views/components/follow-button.vue index a13e2fab95..00e96082ce 100644 --- a/src/client/app/mobile/views/components/follow-button.vue +++ b/src/client/app/mobile/views/components/follow-button.vue @@ -37,7 +37,7 @@ export default Vue.extend({ }, mounted() { - this.connection = (this as any).os.stream.useSharedConnection('main'); + this.connection = this.$root.stream.useSharedConnection('main'); this.connection.on('follow', this.onFollowChange); this.connection.on('unfollow', this.onFollowChange); @@ -61,20 +61,20 @@ export default Vue.extend({ try { if (this.u.isFollowing) { - this.u = await (this as any).api('following/delete', { + this.u = await this.$root.api('following/delete', { userId: this.u.id }); } else { if (this.u.hasPendingFollowRequestFromYou) { - this.u = await (this as any).api('following/requests/cancel', { + this.u = await this.$root.api('following/requests/cancel', { userId: this.u.id }); } else if (this.u.isLocked) { - this.u = await (this as any).api('following/create', { + this.u = await this.$root.api('following/create', { userId: this.u.id }); } else { - this.u = await (this as any).api('following/create', { + this.u = await this.$root.api('following/create', { userId: this.user.id }); } diff --git a/src/client/app/mobile/views/components/friends-maker.vue b/src/client/app/mobile/views/components/friends-maker.vue index d1b9690d68..316b6b0701 100644 --- a/src/client/app/mobile/views/components/friends-maker.vue +++ b/src/client/app/mobile/views/components/friends-maker.vue @@ -32,7 +32,7 @@ export default Vue.extend({ this.fetching = true; this.users = []; - (this as any).api('users/recommendation', { + this.$root.api('users/recommendation', { limit: this.limit, offset: this.limit * this.page }).then(users => { diff --git a/src/client/app/mobile/views/components/media-image.vue b/src/client/app/mobile/views/components/media-image.vue index ddbe4cb401..4d46516767 100644 --- a/src/client/app/mobile/views/components/media-image.vue +++ b/src/client/app/mobile/views/components/media-image.vue @@ -47,7 +47,7 @@ export default Vue.extend({ }, methods: { onClick() { - (this as any).os.new(ImageViewer, { + this.$root.new(ImageViewer, { image: this.image }); } diff --git a/src/client/app/mobile/views/components/note-detail.vue b/src/client/app/mobile/views/components/note-detail.vue index 2931f5c36c..f6cbc82dd8 100644 --- a/src/client/app/mobile/views/components/note-detail.vue +++ b/src/client/app/mobile/views/components/note-detail.vue @@ -155,7 +155,7 @@ export default Vue.extend({ mounted() { // Get replies if (!this.compact) { - (this as any).api('notes/replies', { + this.$root.api('notes/replies', { noteId: this.p.id, limit: 8 }).then(replies => { @@ -167,7 +167,7 @@ export default Vue.extend({ if (this.p.geo) { const shouldShowMap = this.$store.getters.isSignedIn ? this.$store.state.settings.showMaps : true; if (shouldShowMap) { - (this as any).os.getGoogleMaps().then(maps => { + this.$root.os.getGoogleMaps().then(maps => { const uluru = new maps.LatLng(this.p.geo.coordinates[1], this.p.geo.coordinates[0]); const map = new maps.Map(this.$refs.map, { center: uluru, @@ -187,7 +187,7 @@ export default Vue.extend({ this.conversationFetching = true; // Fetch conversation - (this as any).api('notes/conversation', { + this.$root.api('notes/conversation', { noteId: this.p.replyId }).then(conversation => { this.conversationFetching = false; @@ -208,7 +208,7 @@ export default Vue.extend({ }, react() { - (this as any).os.new(MkReactionPicker, { + this.$root.new(MkReactionPicker, { source: this.$refs.reactButton, note: this.p, compact: true, @@ -217,7 +217,7 @@ export default Vue.extend({ }, menu() { - (this as any).os.new(MkNoteMenu, { + this.$root.new(MkNoteMenu, { source: this.$refs.menuButton, note: this.p, compact: true diff --git a/src/client/app/mobile/views/components/notifications.vue b/src/client/app/mobile/views/components/notifications.vue index 3a95e0d158..17d6e45336 100644 --- a/src/client/app/mobile/views/components/notifications.vue +++ b/src/client/app/mobile/views/components/notifications.vue @@ -57,13 +57,13 @@ export default Vue.extend({ mounted() { window.addEventListener('scroll', this.onScroll, { passive: true }); - this.connection = (this as any).os.stream.useSharedConnection('main'); + this.connection = this.$root.stream.useSharedConnection('main'); this.connection.on('notification', this.onNotification); const max = 10; - (this as any).api('i/notifications', { + this.$root.api('i/notifications', { limit: max + 1 }).then(notifications => { if (notifications.length == max + 1) { @@ -90,7 +90,7 @@ export default Vue.extend({ const max = 30; - (this as any).api('i/notifications', { + this.$root.api('i/notifications', { limit: max + 1, untilId: this.notifications[this.notifications.length - 1].id }).then(notifications => { @@ -107,7 +107,7 @@ export default Vue.extend({ onNotification(notification) { // TODO: ユーザーが画面を見てないと思われるとき(ブラウザやタブがアクティブじゃないなど)は送信しない - (this as any).os.stream.send('readNotification', { + this.$root.stream.send('readNotification', { id: notification.id }); diff --git a/src/client/app/mobile/views/components/post-form.vue b/src/client/app/mobile/views/components/post-form.vue index 8715046acb..a6e50934a9 100644 --- a/src/client/app/mobile/views/components/post-form.vue +++ b/src/client/app/mobile/views/components/post-form.vue @@ -110,7 +110,7 @@ export default Vue.extend({ }, created() { - (this as any).os.getMeta().then(meta => { + this.$root.getMeta().then(meta => { this.maxNoteTextLength = meta.maxNoteTextLength; }); }, @@ -190,7 +190,7 @@ export default Vue.extend({ // ダイレクトへのリプライはリプライ先ユーザーを初期設定 if (this.reply && this.reply.visibility === 'specified') { - (this as any).api('users/show', { userId: this.reply.userId }).then(user => { + this.$root.api('users/show', { userId: this.reply.userId }).then(user => { this.visibleUsers.push(user); }); } @@ -269,7 +269,7 @@ export default Vue.extend({ }, setVisibility() { - const w = (this as any).os.new(MkVisibilityChooser, { + const w = this.$root.new(MkVisibilityChooser, { source: this.$refs.visibilityButton, compact: true }); @@ -283,7 +283,7 @@ export default Vue.extend({ title: this.$t('username-prompt') }).then(acct => { if (acct.startsWith('@')) acct = acct.substr(1); - (this as any).api('users/show', parseAcct(acct)).then(user => { + this.$root.api('users/show', parseAcct(acct)).then(user => { this.visibleUsers.push(user); }); }); @@ -303,7 +303,7 @@ export default Vue.extend({ post() { this.posting = true; const viaMobile = this.$store.state.settings.disableViaMobile !== true; - (this as any).api('notes/create', { + this.$root.api('notes/create', { text: this.text == '' ? undefined : this.text, fileIds: this.files.length > 0 ? this.files.map(f => f.id) : undefined, replyId: this.reply ? this.reply.id : undefined, diff --git a/src/client/app/mobile/views/components/ui.header.vue b/src/client/app/mobile/views/components/ui.header.vue index 9dbc1f9d02..f5b9161286 100644 --- a/src/client/app/mobile/views/components/ui.header.vue +++ b/src/client/app/mobile/views/components/ui.header.vue @@ -48,7 +48,7 @@ export default Vue.extend({ this.$store.commit('setUiHeaderHeight', this.$refs.root.offsetHeight); if (this.$store.getters.isSignedIn) { - this.connection = (this as any).os.stream.useSharedConnection('main'); + this.connection = this.$root.stream.useSharedConnection('main'); this.connection.on('reversiInvited', this.onReversiInvited); this.connection.on('reversi_no_invites', this.onReversiNoInvites); diff --git a/src/client/app/mobile/views/components/ui.nav.vue b/src/client/app/mobile/views/components/ui.nav.vue index 5a582c7aca..c529ae2617 100644 --- a/src/client/app/mobile/views/components/ui.nav.vue +++ b/src/client/app/mobile/views/components/ui.nav.vue @@ -75,12 +75,12 @@ export default Vue.extend({ }, mounted() { - (this as any).os.getMeta().then(meta => { + this.$root.getMeta().then(meta => { this.announcements = meta.broadcasts; }); if (this.$store.getters.isSignedIn) { - this.connection = (this as any).os.stream.useSharedConnection('main'); + this.connection = this.$root.stream.useSharedConnection('main'); this.connection.on('reversiInvited', this.onReversiInvited); this.connection.on('reversi_no_invites', this.onReversiNoInvites); diff --git a/src/client/app/mobile/views/components/ui.vue b/src/client/app/mobile/views/components/ui.vue index 6f77f44454..f93c0d686b 100644 --- a/src/client/app/mobile/views/components/ui.vue +++ b/src/client/app/mobile/views/components/ui.vue @@ -43,7 +43,7 @@ export default Vue.extend({ this.$el.style.paddingTop = this.$store.state.uiHeaderHeight + 'px'; if (this.$store.getters.isSignedIn) { - this.connection = (this as any).os.stream.useSharedConnection('main'); + this.connection = this.$root.stream.useSharedConnection('main'); this.connection.on('notification', this.onNotification); } @@ -58,11 +58,11 @@ export default Vue.extend({ methods: { onNotification(notification) { // TODO: ユーザーが画面を見てないと思われるとき(ブラウザやタブがアクティブじゃないなど)は送信しない - (this as any).os.stream.send('readNotification', { + this.$root.stream.send('readNotification', { id: notification.id }); - (this as any).os.new(MkNotify, { + this.$root.new(MkNotify, { notification }); } diff --git a/src/client/app/mobile/views/components/user-list-timeline.vue b/src/client/app/mobile/views/components/user-list-timeline.vue index f0137d5df4..a9597319df 100644 --- a/src/client/app/mobile/views/components/user-list-timeline.vue +++ b/src/client/app/mobile/views/components/user-list-timeline.vue @@ -42,7 +42,7 @@ export default Vue.extend({ methods: { init() { if (this.connection) this.connection.dispose(); - this.connection = (this as any).os.stream.connectToChannel('userList', { + this.connection = this.$root.stream.connectToChannel('userList', { listId: this.list.id }); this.connection.on('note', this.onNote); @@ -56,7 +56,7 @@ export default Vue.extend({ this.fetching = true; (this.$refs.timeline as any).init(() => new Promise((res, rej) => { - (this as any).api('notes/user-list-timeline', { + this.$root.api('notes/user-list-timeline', { listId: this.list.id, limit: fetchLimit + 1, includeMyRenotes: this.$store.state.settings.showMyRenotes, @@ -79,7 +79,7 @@ export default Vue.extend({ this.moreFetching = true; - const promise = (this as any).api('notes/user-list-timeline', { + const promise = this.$root.api('notes/user-list-timeline', { listId: this.list.id, limit: fetchLimit + 1, untilId: (this.$refs.timeline as any).tail().id, diff --git a/src/client/app/mobile/views/components/user-timeline.vue b/src/client/app/mobile/views/components/user-timeline.vue index cfe1522666..6773b75763 100644 --- a/src/client/app/mobile/views/components/user-timeline.vue +++ b/src/client/app/mobile/views/components/user-timeline.vue @@ -41,7 +41,7 @@ export default Vue.extend({ fetch() { this.fetching = true; (this.$refs.timeline as any).init(() => new Promise((res, rej) => { - (this as any).api('users/notes', { + this.$root.api('users/notes', { userId: this.user.id, withFiles: this.withMedia, limit: fetchLimit + 1 @@ -62,7 +62,7 @@ export default Vue.extend({ this.moreFetching = true; - const promise = (this as any).api('users/notes', { + const promise = this.$root.api('users/notes', { userId: this.user.id, withFiles: this.withMedia, limit: fetchLimit + 1, diff --git a/src/client/app/mobile/views/pages/drive.vue b/src/client/app/mobile/views/pages/drive.vue index e9197bcfcf..ac207f1d51 100644 --- a/src/client/app/mobile/views/pages/drive.vue +++ b/src/client/app/mobile/views/pages/drive.vue @@ -45,7 +45,7 @@ export default Vue.extend({ window.addEventListener('popstate', this.onPopState); }, mounted() { - document.title = `${(this as any).os.instanceName} Drive`; + document.title = `${this.$root.os.instanceName} Drive`; }, beforeDestroy() { window.removeEventListener('popstate', this.onPopState); @@ -64,7 +64,7 @@ export default Vue.extend({ (this.$refs as any).browser.openContextMenu(); }, onMoveRoot(silent) { - const title = `${(this as any).os.instanceName} Drive`; + const title = `${this.$root.os.instanceName} Drive`; if (!silent) { // Rewrite URL @@ -77,7 +77,7 @@ export default Vue.extend({ this.folder = null; }, onOpenFolder(folder, silent) { - const title = `${folder.name} | ${(this as any).os.instanceName} Drive`; + const title = `${folder.name} | ${this.$root.os.instanceName} Drive`; if (!silent) { // Rewrite URL @@ -90,7 +90,7 @@ export default Vue.extend({ this.folder = folder; }, onOpenFile(file, silent) { - const title = `${file.name} | ${(this as any).os.instanceName} Drive`; + const title = `${file.name} | ${this.$root.os.instanceName} Drive`; if (!silent) { // Rewrite URL diff --git a/src/client/app/mobile/views/pages/favorites.vue b/src/client/app/mobile/views/pages/favorites.vue index ff652ddf0b..35f639ec05 100644 --- a/src/client/app/mobile/views/pages/favorites.vue +++ b/src/client/app/mobile/views/pages/favorites.vue @@ -30,14 +30,14 @@ export default Vue.extend({ this.fetch(); }, mounted() { - document.title = `${(this as any).os.instanceName} | %i18n:@notifications%`; + document.title = `${this.$root.os.instanceName} | %i18n:@notifications%`; }, methods: { fetch() { Progress.start(); this.fetching = true; - (this as any).api('i/favorites', { + this.$root.api('i/favorites', { limit: 11 }).then(favorites => { if (favorites.length == 11) { @@ -53,7 +53,7 @@ export default Vue.extend({ }, more() { this.moreFetching = true; - (this as any).api('i/favorites', { + this.$root.api('i/favorites', { limit: 11, untilId: this.favorites[this.favorites.length - 1].id }).then(favorites => { diff --git a/src/client/app/mobile/views/pages/followers.vue b/src/client/app/mobile/views/pages/followers.vue index b92c0088fb..4d69d2cf5c 100644 --- a/src/client/app/mobile/views/pages/followers.vue +++ b/src/client/app/mobile/views/pages/followers.vue @@ -46,18 +46,18 @@ export default Vue.extend({ Progress.start(); this.fetching = true; - (this as any).api('users/show', parseAcct(this.$route.params.user)).then(user => { + this.$root.api('users/show', parseAcct(this.$route.params.user)).then(user => { this.user = user; this.fetching = false; - document.title = `${this.$t('followers-of').replace('{}', this.name)} | ${(this as any).os.instanceName}`; + document.title = `${this.$t('followers-of').replace('{}', this.name)} | ${this.$root.os.instanceName}`; }); }, onLoaded() { Progress.done(); }, fetchUsers(iknow, limit, cursor, cb) { - (this as any).api('users/followers', { + this.$root.api('users/followers', { userId: this.user.id, iknow: iknow, limit: limit, diff --git a/src/client/app/mobile/views/pages/following.vue b/src/client/app/mobile/views/pages/following.vue index a4ec0ab6c7..52f74eff29 100644 --- a/src/client/app/mobile/views/pages/following.vue +++ b/src/client/app/mobile/views/pages/following.vue @@ -45,18 +45,18 @@ export default Vue.extend({ Progress.start(); this.fetching = true; - (this as any).api('users/show', parseAcct(this.$route.params.user)).then(user => { + this.$root.api('users/show', parseAcct(this.$route.params.user)).then(user => { this.user = user; this.fetching = false; - document.title = `${this.$t('followers-of').replace('{}', this.name)} | ${(this as any).os.instanceName}`; + document.title = `${this.$t('followers-of').replace('{}', this.name)} | ${this.$root.os.instanceName}`; }); }, onLoaded() { Progress.done(); }, fetchUsers(iknow, limit, cursor, cb) { - (this as any).api('users/following', { + this.$root.api('users/following', { userId: this.user.id, iknow: iknow, limit: limit, diff --git a/src/client/app/mobile/views/pages/games/reversi.vue b/src/client/app/mobile/views/pages/games/reversi.vue index 8a5653fc6e..4663ec7f19 100644 --- a/src/client/app/mobile/views/pages/games/reversi.vue +++ b/src/client/app/mobile/views/pages/games/reversi.vue @@ -15,7 +15,7 @@ export default Vue.extend({ XReversi: () => import('../../../../common/views/components/games/reversi/reversi.vue') }, mounted() { - document.title = `${(this as any).os.instanceName} %i18n:@reversi%`; + document.title = `${this.$root.os.instanceName} %i18n:@reversi%`; }, methods: { nav(game, actualNav) { diff --git a/src/client/app/mobile/views/pages/home.timeline.vue b/src/client/app/mobile/views/pages/home.timeline.vue index 4f28d23c09..0699a169e4 100644 --- a/src/client/app/mobile/views/pages/home.timeline.vue +++ b/src/client/app/mobile/views/pages/home.timeline.vue @@ -66,32 +66,32 @@ export default Vue.extend({ this.query = { query: this.tagTl.query }; - this.connection = (this as any).os.stream.connectToChannel('hashtag', { q: this.tagTl.query }); + this.connection = this.$root.stream.connectToChannel('hashtag', { q: this.tagTl.query }); this.connection.on('note', prepend); } else if (this.src == 'home') { this.endpoint = 'notes/timeline'; const onChangeFollowing = () => { this.fetch(); }; - this.connection = (this as any).os.stream.useSharedConnection('homeTimeline'); + this.connection = this.$root.stream.useSharedConnection('homeTimeline'); this.connection.on('note', prepend); this.connection.on('follow', onChangeFollowing); this.connection.on('unfollow', onChangeFollowing); } else if (this.src == 'local') { this.endpoint = 'notes/local-timeline'; - this.connection = (this as any).os.stream.useSharedConnection('localTimeline'); + this.connection = this.$root.stream.useSharedConnection('localTimeline'); this.connection.on('note', prepend); } else if (this.src == 'hybrid') { this.endpoint = 'notes/hybrid-timeline'; - this.connection = (this as any).os.stream.useSharedConnection('hybridTimeline'); + this.connection = this.$root.stream.useSharedConnection('hybridTimeline'); this.connection.on('note', prepend); } else if (this.src == 'global') { this.endpoint = 'notes/global-timeline'; - this.connection = (this as any).os.stream.useSharedConnection('globalTimeline'); + this.connection = this.$root.stream.useSharedConnection('globalTimeline'); this.connection.on('note', prepend); } else if (this.src == 'mentions') { this.endpoint = 'notes/mentions'; - this.connection = (this as any).os.stream.useSharedConnection('main'); + this.connection = this.$root.stream.useSharedConnection('main'); this.connection.on('mention', prepend); } else if (this.src == 'messages') { this.endpoint = 'notes/mentions'; @@ -103,7 +103,7 @@ export default Vue.extend({ prepend(note); } }; - this.connection = (this as any).os.stream.useSharedConnection('main'); + this.connection = this.$root.stream.useSharedConnection('main'); this.connection.on('mention', onNote); } @@ -119,7 +119,7 @@ export default Vue.extend({ this.fetching = true; (this.$refs.timeline as any).init(() => new Promise((res, rej) => { - (this as any).api(this.endpoint, Object.assign({ + this.$root.api(this.endpoint, Object.assign({ limit: fetchLimit + 1, untilDate: this.date ? this.date.getTime() : undefined }, this.baseQuery, this.query)).then(notes => { @@ -139,7 +139,7 @@ export default Vue.extend({ this.moreFetching = true; - const promise = (this as any).api(this.endpoint, Object.assign({ + const promise = this.$root.api(this.endpoint, Object.assign({ limit: fetchLimit + 1, untilId: (this.$refs.timeline as any).tail().id }, this.baseQuery, this.query)); diff --git a/src/client/app/mobile/views/pages/home.vue b/src/client/app/mobile/views/pages/home.vue index d197f1a44f..8849397df1 100644 --- a/src/client/app/mobile/views/pages/home.vue +++ b/src/client/app/mobile/views/pages/home.vue @@ -103,7 +103,7 @@ export default Vue.extend({ showNav(v) { if (v && this.lists === null) { - (this as any).api('users/lists/list').then(lists => { + this.$root.api('users/lists/list').then(lists => { this.lists = lists; }); } @@ -111,7 +111,7 @@ export default Vue.extend({ }, created() { - (this as any).os.getMeta().then(meta => { + this.$root.getMeta().then(meta => { this.enableLocalTimeline = !meta.disableLocalTimeline; }); @@ -128,7 +128,7 @@ export default Vue.extend({ }, mounted() { - document.title = (this as any).os.instanceName; + document.title = this.$root.os.instanceName; Progress.start(); diff --git a/src/client/app/mobile/views/pages/messaging-room.vue b/src/client/app/mobile/views/pages/messaging-room.vue index 64feba43a2..784c1fcaa5 100644 --- a/src/client/app/mobile/views/pages/messaging-room.vue +++ b/src/client/app/mobile/views/pages/messaging-room.vue @@ -45,11 +45,11 @@ export default Vue.extend({ methods: { fetch() { this.fetching = true; - (this as any).api('users/show', parseAcct(this.$route.params.user)).then(user => { + this.$root.api('users/show', parseAcct(this.$route.params.user)).then(user => { this.user = user; this.fetching = false; - document.title = `${this.$t('@.messaging')}: ${Vue.filter('userName')(this.user)} | ${(this as any).os.instanceName}`; + document.title = `${this.$t('@.messaging')}: ${Vue.filter('userName')(this.user)} | ${this.$root.os.instanceName}`; }); } } diff --git a/src/client/app/mobile/views/pages/messaging.vue b/src/client/app/mobile/views/pages/messaging.vue index 790d2a6254..59b5410286 100644 --- a/src/client/app/mobile/views/pages/messaging.vue +++ b/src/client/app/mobile/views/pages/messaging.vue @@ -13,7 +13,7 @@ import getAcct from '../../../../../misc/acct/render'; export default Vue.extend({ i18n: i18n(), mounted() { - document.title = `${(this as any).os.instanceName} ${this.$t('@.messaging')}`; + document.title = `${this.$root.os.instanceName} ${this.$t('@.messaging')}`; }, methods: { navigate(user) { diff --git a/src/client/app/mobile/views/pages/note.vue b/src/client/app/mobile/views/pages/note.vue index efe9c0c0ff..a0449298eb 100644 --- a/src/client/app/mobile/views/pages/note.vue +++ b/src/client/app/mobile/views/pages/note.vue @@ -33,14 +33,14 @@ export default Vue.extend({ this.fetch(); }, mounted() { - document.title = (this as any).os.instanceName; + document.title = this.$root.os.instanceName; }, methods: { fetch() { Progress.start(); this.fetching = true; - (this as any).api('notes/show', { + this.$root.api('notes/show', { noteId: this.$route.params.note }).then(note => { this.note = note; diff --git a/src/client/app/mobile/views/pages/notifications.vue b/src/client/app/mobile/views/pages/notifications.vue index 8fc61ad3cb..97fe995535 100644 --- a/src/client/app/mobile/views/pages/notifications.vue +++ b/src/client/app/mobile/views/pages/notifications.vue @@ -26,7 +26,7 @@ export default Vue.extend({ const ok = window.confirm(this.$t('read-all')); if (!ok) return; - (this as any).api('notifications/mark_all_as_read'); + this.$root.api('notifications/mark_all_as_read'); }, onFetched() { Progress.done(); diff --git a/src/client/app/mobile/views/pages/received-follow-requests.vue b/src/client/app/mobile/views/pages/received-follow-requests.vue index 08fe787921..48c46f64cd 100644 --- a/src/client/app/mobile/views/pages/received-follow-requests.vue +++ b/src/client/app/mobile/views/pages/received-follow-requests.vue @@ -31,7 +31,7 @@ export default Vue.extend({ Progress.start(); - (this as any).api('following/requests/list').then(requests => { + this.$root.api('following/requests/list').then(requests => { this.fetching = false; this.requests = requests; @@ -40,12 +40,12 @@ export default Vue.extend({ }, methods: { accept(user) { - (this as any).api('following/requests/accept', { userId: user.id }).then(() => { + this.$root.api('following/requests/accept', { userId: user.id }).then(() => { this.requests = this.requests.filter(r => r.follower.id != user.id); }); }, reject(user) { - (this as any).api('following/requests/reject', { userId: user.id }).then(() => { + this.$root.api('following/requests/reject', { userId: user.id }).then(() => { this.requests = this.requests.filter(r => r.follower.id != user.id); }); } diff --git a/src/client/app/mobile/views/pages/search.vue b/src/client/app/mobile/views/pages/search.vue index 13b0469933..00723c26fd 100644 --- a/src/client/app/mobile/views/pages/search.vue +++ b/src/client/app/mobile/views/pages/search.vue @@ -36,7 +36,7 @@ export default Vue.extend({ } }, mounted() { - document.title = `%i18n:@search%: ${this.q} | ${(this as any).os.instanceName}`; + document.title = `%i18n:@search%: ${this.q} | ${this.$root.os.instanceName}`; this.fetch(); }, @@ -46,7 +46,7 @@ export default Vue.extend({ Progress.start(); (this.$refs.timeline as any).init(() => new Promise((res, rej) => { - (this as any).api('notes/search', { + this.$root.api('notes/search', { limit: limit + 1, offset: this.offset, query: this.q @@ -65,7 +65,7 @@ export default Vue.extend({ more() { this.offset += limit; - const promise = (this as any).api('notes/search', { + const promise = this.$root.api('notes/search', { limit: limit + 1, offset: this.offset, query: this.q diff --git a/src/client/app/mobile/views/pages/settings.vue b/src/client/app/mobile/views/pages/settings.vue index 702e5879e9..bc1af8c57d 100644 --- a/src/client/app/mobile/views/pages/settings.vue +++ b/src/client/app/mobile/views/pages/settings.vue @@ -334,7 +334,7 @@ export default Vue.extend({ methods: { signout() { - (this as any).os.signout(); + this.$root.os.signout(); }, checkForUpdate() { diff --git a/src/client/app/mobile/views/pages/share.vue b/src/client/app/mobile/views/pages/share.vue index 83535b39c1..6eabbef18e 100644 --- a/src/client/app/mobile/views/pages/share.vue +++ b/src/client/app/mobile/views/pages/share.vue @@ -29,7 +29,7 @@ export default Vue.extend({ } }, mounted() { - (this as any).os.getMeta().then(meta => { + this.$root.getMeta().then(meta => { this.name = meta.name; }); } diff --git a/src/client/app/mobile/views/pages/tag.vue b/src/client/app/mobile/views/pages/tag.vue index 9a0c891920..aaf878ce45 100644 --- a/src/client/app/mobile/views/pages/tag.vue +++ b/src/client/app/mobile/views/pages/tag.vue @@ -41,7 +41,7 @@ export default Vue.extend({ Progress.start(); (this.$refs.timeline as any).init(() => new Promise((res, rej) => { - (this as any).api('notes/search_by_tag', { + this.$root.api('notes/search_by_tag', { limit: limit + 1, offset: this.offset, tag: this.$route.params.tag @@ -60,7 +60,7 @@ export default Vue.extend({ more() { this.offset += limit; - const promise = (this as any).api('notes/search_by_tag', { + const promise = this.$root.api('notes/search_by_tag', { limit: limit + 1, offset: this.offset, tag: this.$route.params.tag diff --git a/src/client/app/mobile/views/pages/user-list.vue b/src/client/app/mobile/views/pages/user-list.vue index 064da3ac3a..fdc621ef7d 100644 --- a/src/client/app/mobile/views/pages/user-list.vue +++ b/src/client/app/mobile/views/pages/user-list.vue @@ -33,7 +33,7 @@ export default Vue.extend({ Progress.start(); this.fetching = true; - (this as any).api('users/lists/show', { + this.$root.api('users/lists/show', { listId: this.$route.params.list }).then(list => { this.list = list; @@ -41,7 +41,7 @@ export default Vue.extend({ Progress.done(); - (this as any).api('users/show', { + this.$root.api('users/show', { userIds: this.list.userIds }).then(users => { this.users = users; diff --git a/src/client/app/mobile/views/pages/user-lists.vue b/src/client/app/mobile/views/pages/user-lists.vue index 3844bbbf7e..5cd9d144db 100644 --- a/src/client/app/mobile/views/pages/user-lists.vue +++ b/src/client/app/mobile/views/pages/user-lists.vue @@ -29,7 +29,7 @@ export default Vue.extend({ Progress.start(); - (this as any).api('users/lists/list').then(lists => { + this.$root.api('users/lists/list').then(lists => { this.fetching = false; this.lists = lists; @@ -41,7 +41,7 @@ export default Vue.extend({ (this as any).apis.input({ title: this.$t('enter-list-name'), }).then(async title => { - const list = await (this as any).api('users/lists/create', { + const list = await this.$root.api('users/lists/create', { title }); diff --git a/src/client/app/mobile/views/pages/user.vue b/src/client/app/mobile/views/pages/user.vue index 9e79115896..5b915bc1e1 100644 --- a/src/client/app/mobile/views/pages/user.vue +++ b/src/client/app/mobile/views/pages/user.vue @@ -105,12 +105,12 @@ export default Vue.extend({ fetch() { Progress.start(); - (this as any).api('users/show', parseAcct(this.$route.params.user)).then(user => { + this.$root.api('users/show', parseAcct(this.$route.params.user)).then(user => { this.user = user; this.fetching = false; Progress.done(); - document.title = `${Vue.filter('userName')(this.user)} | ${(this as any).os.instanceName}`; + document.title = `${Vue.filter('userName')(this.user)} | ${this.$root.os.instanceName}`; }); }, @@ -120,7 +120,7 @@ export default Vue.extend({ text: this.user.isMuted ? this.$t('unmute') : this.$t('mute'), action: () => { if (this.user.isMuted) { - (this as any).api('mute/delete', { + this.$root.api('mute/delete', { userId: this.user.id }).then(() => { this.user.isMuted = false; @@ -128,7 +128,7 @@ export default Vue.extend({ alert('error'); }); } else { - (this as any).api('mute/create', { + this.$root.api('mute/create', { userId: this.user.id }).then(() => { this.user.isMuted = true; @@ -142,7 +142,7 @@ export default Vue.extend({ text: this.user.isBlocking ? this.$t('unblock') : this.$t('block'), action: () => { if (this.user.isBlocking) { - (this as any).api('blocking/delete', { + this.$root.api('blocking/delete', { userId: this.user.id }).then(() => { this.user.isBlocking = false; @@ -150,7 +150,7 @@ export default Vue.extend({ alert('error'); }); } else { - (this as any).api('blocking/create', { + this.$root.api('blocking/create', { userId: this.user.id }).then(() => { this.user.isBlocking = true; @@ -161,7 +161,7 @@ export default Vue.extend({ } }]; - this.os.new(Menu, { + this.$root.new(Menu, { source: this.$refs.menu, compact: true, items: menu diff --git a/src/client/app/mobile/views/pages/user/home.followers-you-know.vue b/src/client/app/mobile/views/pages/user/home.followers-you-know.vue index 938a565aef..60f8d74c69 100644 --- a/src/client/app/mobile/views/pages/user/home.followers-you-know.vue +++ b/src/client/app/mobile/views/pages/user/home.followers-you-know.vue @@ -24,7 +24,7 @@ export default Vue.extend({ }; }, mounted() { - (this as any).api('users/followers', { + this.$root.api('users/followers', { userId: this.user.id, iknow: true, limit: 30 diff --git a/src/client/app/mobile/views/pages/user/home.friends.vue b/src/client/app/mobile/views/pages/user/home.friends.vue index d18a1e049e..5b1af95db6 100644 --- a/src/client/app/mobile/views/pages/user/home.friends.vue +++ b/src/client/app/mobile/views/pages/user/home.friends.vue @@ -21,7 +21,7 @@ export default Vue.extend({ }; }, mounted() { - (this as any).api('users/get_frequently_replied_users', { + this.$root.api('users/get_frequently_replied_users', { userId: this.user.id }).then(res => { this.users = res.map(x => x.user); diff --git a/src/client/app/mobile/views/pages/user/home.notes.vue b/src/client/app/mobile/views/pages/user/home.notes.vue index d2ffa275a5..d01292b619 100644 --- a/src/client/app/mobile/views/pages/user/home.notes.vue +++ b/src/client/app/mobile/views/pages/user/home.notes.vue @@ -21,7 +21,7 @@ export default Vue.extend({ }; }, mounted() { - (this as any).api('users/notes', { + this.$root.api('users/notes', { userId: this.user.id }).then(notes => { this.notes = notes; diff --git a/src/client/app/mobile/views/pages/user/home.photos.vue b/src/client/app/mobile/views/pages/user/home.photos.vue index 6aa78a5414..e1d9d0470b 100644 --- a/src/client/app/mobile/views/pages/user/home.photos.vue +++ b/src/client/app/mobile/views/pages/user/home.photos.vue @@ -26,7 +26,7 @@ export default Vue.extend({ }; }, mounted() { - (this as any).api('users/notes', { + this.$root.api('users/notes', { userId: this.user.id, withFiles: true, limit: 6 diff --git a/src/client/app/mobile/views/pages/welcome.vue b/src/client/app/mobile/views/pages/welcome.vue index c09ba1a78a..585bd4062b 100644 --- a/src/client/app/mobile/views/pages/welcome.vue +++ b/src/client/app/mobile/views/pages/welcome.vue @@ -93,7 +93,7 @@ export default Vue.extend({ }; }, created() { - (this as any).os.getMeta().then(meta => { + this.$root.getMeta().then(meta => { this.meta = meta; this.name = meta.name; this.description = meta.description; @@ -101,7 +101,7 @@ export default Vue.extend({ this.banner = meta.bannerUrl; }); - (this as any).api('stats').then(stats => { + this.$root.api('stats').then(stats => { this.stats = stats; }); @@ -111,7 +111,7 @@ export default Vue.extend({ 'image/gif' ]; - (this as any).api('notes/local-timeline', { + this.$root.api('notes/local-timeline', { fileType: image, excludeNsfw: true, limit: 6 diff --git a/src/client/app/mobile/views/pages/widgets.vue b/src/client/app/mobile/views/pages/widgets.vue index be6604b8a9..739d6ecadd 100644 --- a/src/client/app/mobile/views/pages/widgets.vue +++ b/src/client/app/mobile/views/pages/widgets.vue @@ -104,7 +104,7 @@ export default Vue.extend({ }, mounted() { - document.title = (this as any).os.instanceName; + document.title = this.$root.os.instanceName; }, methods: { @@ -135,7 +135,7 @@ export default Vue.extend({ saveHome() { this.$store.commit('settings/setMobileHome', this.widgets); - (this as any).api('i/update_mobile_home', { + this.$root.api('i/update_mobile_home', { home: this.widgets }); }