refactor: introduce bindThis decorator to bind this automaticaly
This commit is contained in:
parent
e73581f715
commit
bbb49457f9
199 changed files with 969 additions and 96 deletions
|
@ -6,6 +6,7 @@ import { isUserRelated } from '@/misc/is-user-related.js';
|
|||
import type { Packed } from '@/misc/schema.js';
|
||||
import { MetaService } from '@/core/MetaService.js';
|
||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import Channel from '../channel.js';
|
||||
|
||||
class GlobalTimelineChannel extends Channel {
|
||||
|
@ -21,9 +22,10 @@ class GlobalTimelineChannel extends Channel {
|
|||
connection: Channel['connection'],
|
||||
) {
|
||||
super(id, connection);
|
||||
this.onNote = this.onNote.bind(this);
|
||||
//this.onNote = this.onNote.bind(this);
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async init(params: any) {
|
||||
const meta = await this.metaService.fetch();
|
||||
if (meta.disableGlobalTimeline) {
|
||||
|
@ -34,6 +36,7 @@ class GlobalTimelineChannel extends Channel {
|
|||
this.subscriber.on('notesStream', this.onNote);
|
||||
}
|
||||
|
||||
@bindThis
|
||||
private async onNote(note: Packed<'Note'>) {
|
||||
if (note.visibility !== 'public') return;
|
||||
if (note.channelId != null) return;
|
||||
|
@ -78,6 +81,7 @@ class GlobalTimelineChannel extends Channel {
|
|||
this.send('note', note);
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public dispose() {
|
||||
// Unsubscribe events
|
||||
this.subscriber.off('notesStream', this.onNote);
|
||||
|
@ -95,6 +99,7 @@ export class GlobalTimelineChannelService {
|
|||
) {
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public create(id: string, connection: Channel['connection']): GlobalTimelineChannel {
|
||||
return new GlobalTimelineChannel(
|
||||
this.metaService,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue