Refactor & Clean up
This commit is contained in:
parent
ba845f5218
commit
60ef3e3563
154 changed files with 438 additions and 481 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 => {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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}`;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ export default Vue.extend({
|
|||
|
||||
methods: {
|
||||
signout() {
|
||||
(this as any).os.signout();
|
||||
this.$root.os.signout();
|
||||
},
|
||||
|
||||
checkForUpdate() {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue