Skip to content

Commit 383d2b4

Browse files
committed
realtime RealtimeUserData
1 parent 1206d8b commit 383d2b4

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

lib/realtime/realtime.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@ import {UpdateDirtyNoteJob} from "./realtimeUpdateDirtyNoteJob";
2424
import {CleanDanglingUserJob} from "./realtimeCleanDanglingUserJob";
2525
import {SaveRevisionJob} from "./realtimeSaveRevisionJob";
2626

27+
28+
export interface RealtimeUserData {
29+
id?: string
30+
color?: string
31+
address?: string
32+
'user-agent'?: string
33+
photo?: string
34+
35+
cursor?: any
36+
login?: boolean
37+
userid?: string
38+
name?: string
39+
40+
idle?: any
41+
type?: any
42+
}
2743
const chance = new Chance()
2844

2945
export let io: SocketIO.Server = null
@@ -95,8 +111,8 @@ export function emitCheck(note) {
95111
}
96112

97113
// actions
98-
export const users = {}
99114
export const notes = {}
115+
export const users: Record<string, RealtimeUserData> = {}
100116

101117
export function getNotePool(): any {
102118
return notes
@@ -130,11 +146,11 @@ export function getNoteFromNotePool(noteId) {
130146
return notes[noteId]
131147
}
132148

133-
export function getUserPool() {
149+
export function getUserPool(): Record<string, RealtimeUserData> {
134150
return users
135151
}
136152

137-
export function getUserFromUserPool(userId) {
153+
export function getUserFromUserPool(userId: string): RealtimeUserData | null {
138154
return users[userId]
139155
}
140156

0 commit comments

Comments
 (0)