Refactor & Clean up

This commit is contained in:
syuilo 2018-11-09 08:13:34 +09:00
parent ba845f5218
commit 60ef3e3563
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
154 changed files with 438 additions and 481 deletions

View file

@ -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

View file

@ -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
});

View file

@ -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
});

View file

@ -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
});
}

View file

@ -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 => {

View file

@ -47,7 +47,7 @@ export default Vue.extend({
},
methods: {
onClick() {
(this as any).os.new(ImageViewer, {
this.$root.new(ImageViewer, {
image: this.image
});
}

View file

@ -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

View file

@ -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
});

View file

@ -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,

View file

@ -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);

View file

@ -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);

View file

@ -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
});
}

View file

@ -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,

View file

@ -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,