mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-21 09:16:30 -05:00
refactor: rename ready function to match its intent
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
354700e973
commit
25ee20c15d
5 changed files with 14 additions and 11 deletions
|
@ -146,10 +146,10 @@ describe('realtime user status adapter', () => {
|
|||
'sendMessage',
|
||||
);
|
||||
|
||||
messageTransporterLoggedIn1.startSendingOfReadyRequests();
|
||||
messageTransporterLoggedIn2.startSendingOfReadyRequests();
|
||||
messageTransporterGuest.startSendingOfReadyRequests();
|
||||
messageTransporterDecline.startSendingOfReadyRequests();
|
||||
messageTransporterLoggedIn1.markAsReady();
|
||||
messageTransporterLoggedIn2.markAsReady();
|
||||
messageTransporterGuest.markAsReady();
|
||||
messageTransporterDecline.markAsReady();
|
||||
|
||||
jest.advanceTimersByTime(500);
|
||||
});
|
||||
|
|
|
@ -106,7 +106,7 @@ export class WebsocketGateway implements OnGatewayConnection {
|
|||
|
||||
realtimeNote.addClient(connection);
|
||||
|
||||
websocketTransporter.startSendingOfReadyRequests();
|
||||
websocketTransporter.markAsReady();
|
||||
} catch (error: unknown) {
|
||||
this.logger.error(
|
||||
`Error occurred while initializing: ${(error as Error).message}`,
|
||||
|
|
|
@ -212,9 +212,12 @@ export class MessageTransporter extends EventEmitter2<MessageEventPayloadMap> {
|
|||
* Marks the transporter as ready for communication and starts sending of ready requests to the other side.
|
||||
* This method should be called after all preparations are done and messages can be processed.
|
||||
*/
|
||||
public startSendingOfReadyRequests(): void {
|
||||
public markAsReady(): void {
|
||||
this.thisSideReady = true
|
||||
this.startSendingOfReadyRequests()
|
||||
}
|
||||
|
||||
private startSendingOfReadyRequests(): void {
|
||||
this.readyInterval = setInterval(() => {
|
||||
this.sendMessage({
|
||||
type: MessageType.READY_REQUEST
|
||||
|
|
|
@ -180,10 +180,10 @@ describe('y-doc-sync-adapter', () => {
|
|||
messageTransporterServerTo1.setAdapter(transporterAdapterServerTo1)
|
||||
messageTransporterServerTo2.setAdapter(transporterAdapterServerTo2)
|
||||
|
||||
messageTransporterClient1.startSendingOfReadyRequests()
|
||||
messageTransporterClient2.startSendingOfReadyRequests()
|
||||
messageTransporterServerTo1.startSendingOfReadyRequests()
|
||||
messageTransporterServerTo2.startSendingOfReadyRequests()
|
||||
messageTransporterClient1.markAsReady()
|
||||
messageTransporterClient2.markAsReady()
|
||||
messageTransporterServerTo1.markAsReady()
|
||||
messageTransporterServerTo2.markAsReady()
|
||||
|
||||
jest.advanceTimersByTime(1000)
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ export const EditorPane: React.FC<EditorPaneProps> = ({ scrollState, onScroll, o
|
|||
const mayEdit = useMayEdit()
|
||||
|
||||
useEffect(() => {
|
||||
const listener = messageTransporter.doAsSoonAsConnected(() => messageTransporter.startSendingOfReadyRequests())
|
||||
const listener = messageTransporter.doAsSoonAsConnected(() => messageTransporter.markAsReady())
|
||||
return () => {
|
||||
listener.off()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue