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

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -23,7 +23,7 @@ export default Vue.extend({
}
},
mounted() {
document.title = (this as any).os.instanceName;
document.title = this.$root.os.instanceName;
Progress.start();
},

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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