summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/stream/channels/global-timeline.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2022-12-04 15:03:09 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2022-12-04 15:03:09 +0900
commitbbb49457f9fb5d46402e913c92ebf77722cad6ff (patch)
tree8ef285bcbab2c3a4a89d0a624a802d76a2864fed /packages/backend/src/server/api/stream/channels/global-timeline.ts
parent:art: (diff)
downloadsharkey-bbb49457f9fb5d46402e913c92ebf77722cad6ff.tar.gz
sharkey-bbb49457f9fb5d46402e913c92ebf77722cad6ff.tar.bz2
sharkey-bbb49457f9fb5d46402e913c92ebf77722cad6ff.zip
refactor: introduce bindThis decorator to bind this automaticaly
Diffstat (limited to 'packages/backend/src/server/api/stream/channels/global-timeline.ts')
-rw-r--r--packages/backend/src/server/api/stream/channels/global-timeline.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/packages/backend/src/server/api/stream/channels/global-timeline.ts b/packages/backend/src/server/api/stream/channels/global-timeline.ts
index a8617582dc..34f782e580 100644
--- a/packages/backend/src/server/api/stream/channels/global-timeline.ts
+++ b/packages/backend/src/server/api/stream/channels/global-timeline.ts
@@ -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,