diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2018-11-09 16:00:29 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-09 16:00:29 +0900 |
| commit | 3f79c9ae4927d4186c708e130ecbb1ea4f72d9fa (patch) | |
| tree | 3af53c7b8d5ecc5f0c21cbc5abec3ec5254606b0 /src/client/app/desktop | |
| parent | [Client] Fix bug (diff) | |
| download | misskey-3f79c9ae4927d4186c708e130ecbb1ea4f72d9fa.tar.gz misskey-3f79c9ae4927d4186c708e130ecbb1ea4f72d9fa.tar.bz2 misskey-3f79c9ae4927d4186c708e130ecbb1ea4f72d9fa.zip | |
Refactor client (#3178)
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
Diffstat (limited to 'src/client/app/desktop')
27 files changed, 194 insertions, 226 deletions
diff --git a/src/client/app/desktop/api/choose-drive-file.ts b/src/client/app/desktop/api/choose-drive-file.ts deleted file mode 100644 index a362a1289b..0000000000 --- a/src/client/app/desktop/api/choose-drive-file.ts +++ /dev/null @@ -1,29 +0,0 @@ -import OS from '../../mios'; -import { url } from '../../config'; -import MkChooseFileFromDriveWindow from '../views/components/choose-file-from-drive-window.vue'; - -export default (os: OS) => opts => { - return new Promise((res, rej) => { - const o = opts || {}; - - if (document.body.clientWidth > 800) { - const w = os.new(MkChooseFileFromDriveWindow, { - title: o.title, - multiple: o.multiple, - initFolder: o.currentFolder - }); - w.$once('selected', file => { - res(file); - }); - document.body.appendChild(w.$el); - } else { - window['cb'] = file => { - res(file); - }; - - window.open(url + `/selectdrive?multiple=${o.multiple}`, - 'choose_drive_window', - 'height=500, width=800'); - } - }); -}; diff --git a/src/client/app/desktop/api/choose-drive-folder.ts b/src/client/app/desktop/api/choose-drive-folder.ts deleted file mode 100644 index 68dc7988b5..0000000000 --- a/src/client/app/desktop/api/choose-drive-folder.ts +++ /dev/null @@ -1,16 +0,0 @@ -import OS from '../../mios'; -import MkChooseFolderFromDriveWindow from '../views/components/choose-folder-from-drive-window.vue'; - -export default (os: OS) => opts => { - return new Promise((res, rej) => { - const o = opts || {}; - const w = os.new(MkChooseFolderFromDriveWindow, { - title: o.title, - initFolder: o.currentFolder - }); - w.$once('selected', folder => { - res(folder); - }); - document.body.appendChild(w.$el); - }); -}; diff --git a/src/client/app/desktop/api/contextmenu.ts b/src/client/app/desktop/api/contextmenu.ts deleted file mode 100644 index c92f087551..0000000000 --- a/src/client/app/desktop/api/contextmenu.ts +++ /dev/null @@ -1,15 +0,0 @@ -import OS from '../../mios'; -import Ctx from '../views/components/context-menu.vue'; - -export default (os: OS) => (e, menu, opts?) => { - const o = opts || {}; - const vm = os.new(Ctx, { - menu, - x: e.pageX - window.pageXOffset, - y: e.pageY - window.pageYOffset, - }); - vm.$once('closed', () => { - if (o.closed) o.closed(); - }); - document.body.appendChild(vm.$el); -}; diff --git a/src/client/app/desktop/api/dialog.ts b/src/client/app/desktop/api/dialog.ts deleted file mode 100644 index 23f35b7aa9..0000000000 --- a/src/client/app/desktop/api/dialog.ts +++ /dev/null @@ -1,18 +0,0 @@ -import OS from '../../mios'; -import Dialog from '../views/components/dialog.vue'; - -export default (os: OS) => opts => { - return new Promise<string>((res, rej) => { - const o = opts || {}; - const d = os.new(Dialog, { - title: o.title, - text: o.text, - modal: o.modal, - buttons: o.actions - }); - d.$once('clicked', id => { - res(id); - }); - document.body.appendChild(d.$el); - }); -}; diff --git a/src/client/app/desktop/api/input.ts b/src/client/app/desktop/api/input.ts deleted file mode 100644 index bd7bfa0129..0000000000 --- a/src/client/app/desktop/api/input.ts +++ /dev/null @@ -1,19 +0,0 @@ -import OS from '../../mios'; -import InputDialog from '../views/components/input-dialog.vue'; - -export default (os: OS) => opts => { - return new Promise<string>((res, rej) => { - const o = opts || {}; - const d = os.new(InputDialog, { - title: o.title, - placeholder: o.placeholder, - default: o.default, - type: o.type || 'text', - allowEmpty: o.allowEmpty - }); - d.$once('done', text => { - res(text); - }); - document.body.appendChild(d.$el); - }); -}; diff --git a/src/client/app/desktop/api/notify.ts b/src/client/app/desktop/api/notify.ts deleted file mode 100644 index 72e5827607..0000000000 --- a/src/client/app/desktop/api/notify.ts +++ /dev/null @@ -1,9 +0,0 @@ -import OS from '../../mios'; -import Notification from '../views/components/ui-notification.vue'; - -export default (os: OS) => message => { - const vm = os.new(Notification, { - message - }); - document.body.appendChild(vm.$el); -}; diff --git a/src/client/app/desktop/api/post.ts b/src/client/app/desktop/api/post.ts deleted file mode 100644 index 3ff9c5bb8c..0000000000 --- a/src/client/app/desktop/api/post.ts +++ /dev/null @@ -1,22 +0,0 @@ -import OS from '../../mios'; -import PostFormWindow from '../views/components/post-form-window.vue'; -import RenoteFormWindow from '../views/components/renote-form-window.vue'; - -export default (os: OS) => opts => { - const o = opts || {}; - if (o.renote) { - const vm = os.new(RenoteFormWindow, { - note: o.renote, - animation: o.animation == null ? true : o.animation - }); - if (o.cb) vm.$once('closed', o.cb); - document.body.appendChild(vm.$el); - } else { - const vm = os.new(PostFormWindow, { - reply: o.reply, - animation: o.animation == null ? true : o.animation - }); - if (o.cb) vm.$once('closed', o.cb); - document.body.appendChild(vm.$el); - } -}; diff --git a/src/client/app/desktop/api/update-avatar.ts b/src/client/app/desktop/api/update-avatar.ts index f08e8a2b4e..ae8b723ea6 100644 --- a/src/client/app/desktop/api/update-avatar.ts +++ b/src/client/app/desktop/api/update-avatar.ts @@ -1,15 +1,14 @@ -import OS from '../../mios'; import { apiUrl } from '../../config'; import CropWindow from '../views/components/crop-window.vue'; import ProgressDialog from '../views/components/progress-dialog.vue'; -export default (os: OS) => { +export default ($root: any) => { const cropImage = file => new Promise((resolve, reject) => { const regex = RegExp('\.(jpg|jpeg|png|gif|webp|bmp|tiff)$'); if (!regex.test(file.name) ) { - os.apis.dialog({ + $root.$dialog({ title: '%fa:info-circle% %i18n:desktop.invalid-filetype%', text: null, actions: [{ @@ -19,7 +18,7 @@ export default (os: OS) => { return reject('invalid-filetype'); } - const w = os.new(CropWindow, { + const w = $root.new(CropWindow, { image: file, title: '%i18n:desktop.avatar-crop-title%', aspectRatio: 1 / 1 @@ -27,14 +26,14 @@ export default (os: OS) => { w.$once('cropped', blob => { const data = new FormData(); - data.append('i', os.store.state.i.token); + data.append('i', $root.$store.state.i.token); data.append('file', blob, file.name + '.cropped.png'); - os.api('drive/folders/find', { + $root.api('drive/folders/find', { name: '%i18n:desktop.avatar%' }).then(avatarFolder => { if (avatarFolder.length === 0) { - os.api('drive/folders/create', { + $root.api('drive/folders/create', { name: '%i18n:desktop.avatar%' }).then(iconFolder => { resolve(upload(data, iconFolder)); @@ -55,7 +54,7 @@ export default (os: OS) => { }); const upload = (data, folder) => new Promise((resolve, reject) => { - const dialog = os.new(ProgressDialog, { + const dialog = $root.new(ProgressDialog, { title: '%i18n:desktop.uploading-avatar%' }); document.body.appendChild(dialog.$el); @@ -79,19 +78,19 @@ export default (os: OS) => { }); const setAvatar = file => { - return os.api('i/update', { + return $root.api('i/update', { avatarId: file.id }).then(i => { - os.store.commit('updateIKeyValue', { + $root.$store.commit('updateIKeyValue', { key: 'avatarId', value: i.avatarId }); - os.store.commit('updateIKeyValue', { + $root.$store.commit('updateIKeyValue', { key: 'avatarUrl', value: i.avatarUrl }); - os.apis.dialog({ + $root.$dialog({ title: '%fa:info-circle% %i18n:desktop.avatar-updated%', text: null, actions: [{ @@ -106,7 +105,7 @@ export default (os: OS) => { return (file = null) => { const selectedFile = file ? Promise.resolve(file) - : os.apis.chooseDriveFile({ + : $root.$chooseDriveFile({ multiple: false, title: '%fa:image% %i18n:desktop.choose-avatar%' }); diff --git a/src/client/app/desktop/api/update-banner.ts b/src/client/app/desktop/api/update-banner.ts index 42c9d69349..c338d4e95c 100644 --- a/src/client/app/desktop/api/update-banner.ts +++ b/src/client/app/desktop/api/update-banner.ts @@ -1,15 +1,14 @@ -import OS from '../../mios'; import { apiUrl } from '../../config'; import CropWindow from '../views/components/crop-window.vue'; import ProgressDialog from '../views/components/progress-dialog.vue'; -export default (os: OS) => { +export default ($root: any) => { const cropImage = file => new Promise((resolve, reject) => { const regex = RegExp('\.(jpg|jpeg|png|gif|webp|bmp|tiff)$'); if (!regex.test(file.name) ) { - os.apis.dialog({ + $root.dialog({ title: '%fa:info-circle% %i18n:desktop.invalid-filetype%', text: null, actions: [{ @@ -19,7 +18,7 @@ export default (os: OS) => { return reject('invalid-filetype'); } - const w = os.new(CropWindow, { + const w = $root.new(CropWindow, { image: file, title: '%i18n:desktop.banner-crop-title%', aspectRatio: 16 / 9 @@ -27,14 +26,14 @@ export default (os: OS) => { w.$once('cropped', blob => { const data = new FormData(); - data.append('i', os.store.state.i.token); + data.append('i', $root.$store.state.i.token); data.append('file', blob, file.name + '.cropped.png'); - os.api('drive/folders/find', { + $root.api('drive/folders/find', { name: '%i18n:desktop.banner%' }).then(bannerFolder => { if (bannerFolder.length === 0) { - os.api('drive/folders/create', { + $root.api('drive/folders/create', { name: '%i18n:desktop.banner%' }).then(iconFolder => { resolve(upload(data, iconFolder)); @@ -55,7 +54,7 @@ export default (os: OS) => { }); const upload = (data, folder) => new Promise((resolve, reject) => { - const dialog = os.new(ProgressDialog, { + const dialog = $root.new(ProgressDialog, { title: '%i18n:desktop.uploading-banner%' }); document.body.appendChild(dialog.$el); @@ -79,19 +78,19 @@ export default (os: OS) => { }); const setBanner = file => { - return os.api('i/update', { + return $root.api('i/update', { bannerId: file.id }).then(i => { - os.store.commit('updateIKeyValue', { + $root.$store.commit('updateIKeyValue', { key: 'bannerId', value: i.bannerId }); - os.store.commit('updateIKeyValue', { + $root.$store.commit('updateIKeyValue', { key: 'bannerUrl', value: i.bannerUrl }); - os.apis.dialog({ + $root.$dialog({ title: '%fa:info-circle% %i18n:desktop.banner-updated%', text: null, actions: [{ @@ -106,7 +105,7 @@ export default (os: OS) => { return (file = null) => { const selectedFile = file ? Promise.resolve(file) - : os.apis.chooseDriveFile({ + : $root.$chooseDriveFile({ multiple: false, title: '%fa:image% %i18n:desktop.choose-banner%' }); diff --git a/src/client/app/desktop/script.ts b/src/client/app/desktop/script.ts index ca9771e2fe..f2d27fa16e 100644 --- a/src/client/app/desktop/script.ts +++ b/src/client/app/desktop/script.ts @@ -2,6 +2,7 @@ * Desktop Client */ +import Vue from 'vue'; import VueRouter from 'vue-router'; // Style @@ -11,15 +12,6 @@ import init from '../init'; import fuckAdBlock from '../common/scripts/fuck-ad-block'; import composeNotification from '../common/scripts/compose-notification'; -import chooseDriveFolder from './api/choose-drive-folder'; -import chooseDriveFile from './api/choose-drive-file'; -import dialog from './api/dialog'; -import input from './api/input'; -import post from './api/post'; -import notify from './api/notify'; -import updateAvatar from './api/update-avatar'; -import updateBanner from './api/update-banner'; - import MkIndex from './views/pages/index.vue'; import MkHome from './views/pages/home.vue'; import MkDeck from './views/pages/deck/deck.vue'; @@ -36,12 +28,131 @@ import MkTag from './views/pages/tag.vue'; import MkReversi from './views/pages/games/reversi.vue'; import MkShare from './views/pages/share.vue'; import MkFollow from '../common/views/pages/follow.vue'; + +import Ctx from './views/components/context-menu.vue'; +import PostFormWindow from './views/components/post-form-window.vue'; +import RenoteFormWindow from './views/components/renote-form-window.vue'; +import MkChooseFileFromDriveWindow from './views/components/choose-file-from-drive-window.vue'; +import MkChooseFolderFromDriveWindow from './views/components/choose-folder-from-drive-window.vue'; +import Dialog from './views/components/dialog.vue'; +import InputDialog from './views/components/input-dialog.vue'; +import Notification from './views/components/ui-notification.vue'; + +import { url } from '../config'; import MiOS from '../mios'; /** * init */ init(async (launch) => { + Vue.mixin({ + methods: { + $contextmenu(e, menu, opts?) { + const o = opts || {}; + const vm = this.$root.new(Ctx, { + menu, + x: e.pageX - window.pageXOffset, + y: e.pageY - window.pageYOffset, + }); + vm.$once('closed', () => { + if (o.closed) o.closed(); + }); + }, + + $post(opts) { + const o = opts || {}; + if (o.renote) { + const vm = this.$root.new(RenoteFormWindow, { + note: o.renote, + animation: o.animation == null ? true : o.animation + }); + if (o.cb) vm.$once('closed', o.cb); + } else { + const vm = this.$root.new(PostFormWindow, { + reply: o.reply, + animation: o.animation == null ? true : o.animation + }); + if (o.cb) vm.$once('closed', o.cb); + } + }, + + $chooseDriveFile(opts) { + return new Promise((res, rej) => { + const o = opts || {}; + + if (document.body.clientWidth > 800) { + const w = this.$root.new(MkChooseFileFromDriveWindow, { + title: o.title, + multiple: o.multiple, + initFolder: o.currentFolder + }); + w.$once('selected', file => { + res(file); + }); + } else { + window['cb'] = file => { + res(file); + }; + + window.open(url + `/selectdrive?multiple=${o.multiple}`, + 'choose_drive_window', + 'height=500, width=800'); + } + }); + }, + + $chooseDriveFolder(opts) { + return new Promise((res, rej) => { + const o = opts || {}; + const w = this.$root.new(MkChooseFolderFromDriveWindow, { + title: o.title, + initFolder: o.currentFolder + }); + w.$once('selected', folder => { + res(folder); + }); + }); + }, + + $dialog(opts) { + return new Promise<string>((res, rej) => { + const o = opts || {}; + const d = this.$root.new(Dialog, { + title: o.title, + text: o.text, + modal: o.modal, + buttons: o.actions + }); + d.$once('clicked', id => { + res(id); + }); + }); + }, + + $input(opts) { + return new Promise<string>((res, rej) => { + const o = opts || {}; + const d = this.$root.new(InputDialog, { + title: o.title, + placeholder: o.placeholder, + default: o.default, + type: o.type || 'text', + allowEmpty: o.allowEmpty + }); + d.$once('done', text => { + res(text); + }); + }); + }, + + $notify(message) { + this.$root.new(Notification, { + message + }); + } + } + }); + // Register directives require('./views/directives'); @@ -75,22 +186,13 @@ init(async (launch) => { }); // Launch the app - const [, os] = launch(router, os => ({ - chooseDriveFolder: chooseDriveFolder(os), - chooseDriveFile: chooseDriveFile(os), - dialog: dialog(os), - input: input(os), - post: post(os), - notify: notify(os), - updateAvatar: updateAvatar(os), - updateBanner: updateBanner(os) - })); + const [app, os] = launch(router); if (os.store.getters.isSignedIn) { /** * Fuck AD Block */ - fuckAdBlock(os); + fuckAdBlock(app); } /** diff --git a/src/client/app/desktop/views/components/drive.file.vue b/src/client/app/desktop/views/components/drive.file.vue index c403418b21..7840d7e748 100644 --- a/src/client/app/desktop/views/components/drive.file.vue +++ b/src/client/app/desktop/views/components/drive.file.vue @@ -35,7 +35,6 @@ import Vue from 'vue'; import i18n from '../../../i18n'; import * as anime from 'animejs'; -import contextmenu from '../../api/contextmenu'; import copyToClipboard from '../../../common/scripts/copy-to-clipboard'; export default Vue.extend({ @@ -70,7 +69,7 @@ export default Vue.extend({ onContextmenu(e) { this.isContextmenuShowing = true; - contextmenu((this as any).os)(e, [{ + this.$contextmenu(e, [{ type: 'item', text: this.$t('contextmenu.rename'), icon: 'i-cursor', @@ -116,10 +115,10 @@ export default Vue.extend({ action: this.addApp }] }*/], { - closed: () => { - this.isContextmenuShowing = false; - } - }); + closed: () => { + this.isContextmenuShowing = false; + } + }); }, onDragstart(e) { @@ -149,7 +148,7 @@ export default Vue.extend({ }, rename() { - this.$root.apis.input({ + this.$input({ title: this.$t('contextmenu.rename-file'), placeholder: this.$t('contextmenu.input-new-file-name'), default: this.file.name, @@ -171,7 +170,7 @@ export default Vue.extend({ copyUrl() { copyToClipboard(this.file.url); - this.$root.apis.dialog({ + this.$dialog({ title: this.$t('contextmenu.copied'), text: this.$t('contextmenu.copied-url-to-clipboard'), actions: [{ @@ -181,11 +180,11 @@ export default Vue.extend({ }, setAsAvatar() { - this.$root.apis.updateAvatar(this.file); + this.$updateAvatar(this.file); }, setAsBanner() { - this.$root.apis.updateBanner(this.file); + this.$updateBanner(this.file); }, addApp() { diff --git a/src/client/app/desktop/views/components/drive.folder.vue b/src/client/app/desktop/views/components/drive.folder.vue index 2f595ddbe3..fe9bad2c28 100644 --- a/src/client/app/desktop/views/components/drive.folder.vue +++ b/src/client/app/desktop/views/components/drive.folder.vue @@ -26,7 +26,6 @@ <script lang="ts"> import Vue from 'vue'; import i18n from '../../../i18n'; -import contextmenu from '../../api/contextmenu'; export default Vue.extend({ i18n: i18n('desktop/views/components/drive.folder.vue'), @@ -54,7 +53,7 @@ export default Vue.extend({ onContextmenu(e) { this.isContextmenuShowing = true; - contextmenu((this as any).os)(e, [{ + this.$contextmenu(e, [{ type: 'item', text: this.$t('contextmenu.move-to-this-folder'), icon: 'arrow-right', @@ -75,10 +74,10 @@ export default Vue.extend({ icon: ['far', 'trash-alt'], action: this.deleteFolder }], { - closed: () => { - this.isContextmenuShowing = false; - } - }); + closed: () => { + this.isContextmenuShowing = false; + } + }); }, onMouseover() { @@ -156,7 +155,7 @@ export default Vue.extend({ }).catch(err => { switch (err) { case 'detected-circular-definition': - this.$root.apis.dialog({ + this.$dialog({ title: this.$t('unable-to-process'), text: this.$t('circular-reference-detected'), actions: [{ @@ -196,7 +195,7 @@ export default Vue.extend({ }, rename() { - this.$root.apis.input({ + this.$input({ title: this.$t('contextmenu.rename-folder'), placeholder: this.$t('contextmenu.input-new-folder-name'), default: this.folder.name diff --git a/src/client/app/desktop/views/components/drive.vue b/src/client/app/desktop/views/components/drive.vue index cf9b8e7152..1e89aa9adf 100644 --- a/src/client/app/desktop/views/components/drive.vue +++ b/src/client/app/desktop/views/components/drive.vue @@ -65,7 +65,6 @@ import XNavFolder from './drive.nav-folder.vue'; import XFolder from './drive.folder.vue'; import XFile from './drive.file.vue'; import contains from '../../../common/scripts/contains'; -import contextmenu from '../../api/contextmenu'; import { url } from '../../../config'; export default Vue.extend({ @@ -137,7 +136,7 @@ export default Vue.extend({ }, methods: { onContextmenu(e) { - contextmenu((this as any).os)(e, [{ + this.$contextmenu(e, [{ type: 'item', text: this.$t('contextmenu.create-folder'), icon: ['far', 'folder'], @@ -314,7 +313,7 @@ export default Vue.extend({ }).catch(err => { switch (err) { case 'detected-circular-definition': - this.$root.apis.dialog({ + this.$dialog({ title: this.$t('unable-to-process'), text: this.$t('circular-reference-detected'), actions: [{ @@ -335,7 +334,7 @@ export default Vue.extend({ }, urlUpload() { - this.$root.apis.input({ + this.$input({ title: this.$t('url-upload'), placeholder: this.$t('url-of-file') }).then(url => { @@ -344,7 +343,7 @@ export default Vue.extend({ folderId: this.folder ? this.folder.id : undefined }); - this.$root.apis.dialog({ + this.$dialog({ title: this.$t('url-upload-requested'), text: this.$t('may-take-time'), actions: [{ @@ -355,7 +354,7 @@ export default Vue.extend({ }, createFolder() { - this.$root.apis.input({ + this.$input({ title: this.$t('create-folder'), placeholder: this.$t('folder-name') }).then(name => { diff --git a/src/client/app/desktop/views/components/home.vue b/src/client/app/desktop/views/components/home.vue index aa25b5b952..500773ee9f 100644 --- a/src/client/app/desktop/views/components/home.vue +++ b/src/client/app/desktop/views/components/home.vue @@ -186,7 +186,7 @@ export default Vue.extend({ methods: { hint() { - this.$root.apis.dialog({ + this.$dialog({ title: this.$t('@.customization-tips.title'), text: this.$t('@.customization-tips.paragraph'), actions: [{ diff --git a/src/client/app/desktop/views/components/post-form.vue b/src/client/app/desktop/views/components/post-form.vue index 87fc3388d2..44178d9414 100644 --- a/src/client/app/desktop/views/components/post-form.vue +++ b/src/client/app/desktop/views/components/post-form.vue @@ -245,7 +245,7 @@ export default Vue.extend({ }, chooseFileFromDrive() { - this.$root.apis.chooseDriveFile({ + this.$chooseDriveFile({ multiple: true }).then(files => { files.forEach(this.attachMedia); @@ -363,7 +363,7 @@ export default Vue.extend({ }, addVisibleUser() { - this.$root.apis.input({ + this.$input({ title: this.$t('enter-username') }).then(acct => { if (acct.startsWith('@')) acct = acct.substr(1); @@ -401,13 +401,13 @@ export default Vue.extend({ this.clear(); this.deleteDraft(); this.$emit('posted'); - this.$root.apis.notify(this.renote + this.$notify(this.renote ? this.$t('reposted') : this.reply ? this.$t('replied') : this.$t('posted')); }).catch(err => { - this.$root.apis.notify(this.renote + this.$notify(this.renote ? this.$t('renote-failed') : this.reply ? this.$t('reply-failed') diff --git a/src/client/app/desktop/views/components/renote-form.vue b/src/client/app/desktop/views/components/renote-form.vue index d2b3c25c0c..c538b90dac 100644 --- a/src/client/app/desktop/views/components/renote-form.vue +++ b/src/client/app/desktop/views/components/renote-form.vue @@ -34,9 +34,9 @@ export default Vue.extend({ renoteId: this.note.id }).then(data => { this.$emit('posted'); - this.$root.apis.notify(this.$t('success')); + this.$notify(this.$t('success')); }).catch(err => { - this.$root.apis.notify(this.$t('failure')); + this.$notify(this.$t('failure')); }).then(() => { this.wait = false; }); diff --git a/src/client/app/desktop/views/components/settings.2fa.vue b/src/client/app/desktop/views/components/settings.2fa.vue index 885b19d424..e106038f03 100644 --- a/src/client/app/desktop/views/components/settings.2fa.vue +++ b/src/client/app/desktop/views/components/settings.2fa.vue @@ -35,7 +35,7 @@ export default Vue.extend({ }, methods: { register() { - this.$root.apis.input({ + this.$input({ title: this.$t('enter-password'), type: 'password' }).then(password => { @@ -48,14 +48,14 @@ export default Vue.extend({ }, unregister() { - this.$root.apis.input({ + this.$input({ title: this.$t('enter-password'), type: 'password' }).then(password => { this.$root.api('i/2fa/unregister', { password: password }).then(() => { - this.$root.apis.notify(this.$t('unregistered')); + this.$notify(this.$t('unregistered')); this.$store.state.i.twoFactorEnabled = false; }); }); @@ -65,10 +65,10 @@ export default Vue.extend({ this.$root.api('i/2fa/done', { token: this.token }).then(() => { - this.$root.apis.notify(this.$t('success')); + this.$notify(this.$t('success')); this.$store.state.i.twoFactorEnabled = true; }).catch(() => { - this.$root.apis.notify(this.$t('failed')); + this.$notify(this.$t('failed')); }); } } diff --git a/src/client/app/desktop/views/components/settings.vue b/src/client/app/desktop/views/components/settings.vue index f834e84309..7080943da8 100644 --- a/src/client/app/desktop/views/components/settings.vue +++ b/src/client/app/desktop/views/components/settings.vue @@ -513,7 +513,7 @@ export default Vue.extend({ this.$emit('done'); }, updateWallpaper() { - this.$root.apis.chooseDriveFile({ + this.$chooseDriveFile({ multiple: false }).then(file => { this.$root.api('i/update', { @@ -533,16 +533,16 @@ export default Vue.extend({ }, checkForUpdate() { this.checkingForUpdate = true; - checkForUpdate((this as any).os, true, true).then(newer => { + checkForUpdate(this.$root, true, true).then(newer => { this.checkingForUpdate = false; this.latestVersion = newer; if (newer == null) { - this.$root.apis.dialog({ + this.$dialog({ title: this.$t('no-updates'), text: this.$t('no-updates-desc') }); } else { - this.$root.apis.dialog({ + this.$dialog({ title: this.$t('update-available'), text: this.$t('update-available-desc') }); @@ -551,7 +551,7 @@ export default Vue.extend({ }, clean() { localStorage.clear(); - this.$root.apis.dialog({ + this.$dialog({ title: this.$t('cache-cleared'), text: this.$t('cache-cleared-desc') }); diff --git a/src/client/app/desktop/views/components/timeline.vue b/src/client/app/desktop/views/components/timeline.vue index d0929c4dc4..410b4e25f7 100644 --- a/src/client/app/desktop/views/components/timeline.vue +++ b/src/client/app/desktop/views/components/timeline.vue @@ -109,7 +109,7 @@ export default Vue.extend({ icon: 'plus', text: this.$t('add-list'), action: () => { - this.$root.apis.input({ + this.$input({ title: this.$t('list-name'), }).then(async title => { const list = await this.$root.api('users/lists/create', { diff --git a/src/client/app/desktop/views/components/ui.header.post.vue b/src/client/app/desktop/views/components/ui.header.post.vue index 79c1abd872..b273ad8d4d 100644 --- a/src/client/app/desktop/views/components/ui.header.post.vue +++ b/src/client/app/desktop/views/components/ui.header.post.vue @@ -12,7 +12,7 @@ export default Vue.extend({ i18n: i18n('desktop/views/components/ui.header.post.vue'), methods: { post() { - this.$root.apis.post(); + this.$post(); } } }); diff --git a/src/client/app/desktop/views/components/ui.sidebar.vue b/src/client/app/desktop/views/components/ui.sidebar.vue index ac6740b93c..76990fa5a4 100644 --- a/src/client/app/desktop/views/components/ui.sidebar.vue +++ b/src/client/app/desktop/views/components/ui.sidebar.vue @@ -139,7 +139,7 @@ export default Vue.extend({ }, post() { - this.$root.apis.post(); + this.$post(); }, drive() { diff --git a/src/client/app/desktop/views/components/ui.vue b/src/client/app/desktop/views/components/ui.vue index 09a3aa7900..fa5efbc93e 100644 --- a/src/client/app/desktop/views/components/ui.vue +++ b/src/client/app/desktop/views/components/ui.vue @@ -67,7 +67,7 @@ export default Vue.extend({ methods: { post() { - this.$root.apis.post(); + this.$post(); }, toggleZenMode() { 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 2f4ed16d83..8c52ea4af2 100644 --- a/src/client/app/desktop/views/components/user-lists-window.vue +++ b/src/client/app/desktop/views/components/user-lists-window.vue @@ -29,7 +29,7 @@ export default Vue.extend({ }, methods: { add() { - this.$root.apis.input({ + this.$input({ title: this.$t('list-name'), }).then(async title => { const list = await this.$root.api('users/lists/create', { 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 1fad1ddd81..ead5ee2bdb 100644 --- a/src/client/app/desktop/views/pages/deck/deck.column.vue +++ b/src/client/app/desktop/views/pages/deck/deck.column.vue @@ -29,7 +29,6 @@ import Vue from 'vue'; import i18n from '../../../../i18n'; import Menu from '../../../../common/views/components/menu.vue'; -import contextmenu from '../../../api/contextmenu'; import { countIf } from '../../../../../../prelude/array'; export default Vue.extend({ @@ -168,7 +167,7 @@ export default Vue.extend({ icon: 'pencil-alt', text: this.$t('rename'), action: () => { - this.$root.apis.input({ + this.$input({ title: this.$t('rename'), default: this.name, allowEmpty: false @@ -230,7 +229,7 @@ export default Vue.extend({ onContextmenu(e) { if (this.isTemporaryColumn) return; - contextmenu((this as any).os)(e, this.getMenu()); + this.$contextmenu(e, this.getMenu()); }, showMenu() { diff --git a/src/client/app/desktop/views/pages/deck/deck.vue b/src/client/app/desktop/views/pages/deck/deck.vue index a702053c18..ea204d0fc0 100644 --- a/src/client/app/desktop/views/pages/deck/deck.vue +++ b/src/client/app/desktop/views/pages/deck/deck.vue @@ -255,7 +255,7 @@ export default Vue.extend({ icon: 'hashtag', text: this.$t('@deck.hashtag'), action: () => { - this.$root.apis.input({ + this.$input({ title: this.$t('enter-hashtag-tl-title') }).then(title => { this.$store.dispatch('settings/addDeckColumn', { diff --git a/src/client/app/desktop/views/pages/user/user.header.vue b/src/client/app/desktop/views/pages/user/user.header.vue index 903a465c9c..a2f3f183b8 100644 --- a/src/client/app/desktop/views/pages/user/user.header.vue +++ b/src/client/app/desktop/views/pages/user/user.header.vue @@ -81,7 +81,7 @@ export default Vue.extend({ onBannerClick() { if (!this.$store.getters.isSignedIn || this.$store.state.i.id != this.user.id) return; - this.$root.apis.updateBanner().then(i => { + this.$updateBanner().then(i => { this.user.bannerUrl = i.bannerUrl; }); } 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 d6bcd72f5a..41e2fa6e5e 100644 --- a/src/client/app/desktop/views/pages/user/user.profile.vue +++ b/src/client/app/desktop/views/pages/user/user.profile.vue @@ -101,7 +101,7 @@ export default Vue.extend({ listId: list.id, userId: this.user.id }); - this.$root.apis.dialog({ + this.$dialog({ title: 'Done!', text: this.$t('list-pushed').replace('{user}', this.user.name).replace('{list}', list.title) }); |