Refactor & Clean up

This commit is contained in:
syuilo
2018-11-09 08:13:34 +09:00
parent ba845f5218
commit 60ef3e3563
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(),