mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-21 17:26:29 -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',
|
'sendMessage',
|
||||||
);
|
);
|
||||||
|
|
||||||
messageTransporterLoggedIn1.startSendingOfReadyRequests();
|
messageTransporterLoggedIn1.markAsReady();
|
||||||
messageTransporterLoggedIn2.startSendingOfReadyRequests();
|
messageTransporterLoggedIn2.markAsReady();
|
||||||
messageTransporterGuest.startSendingOfReadyRequests();
|
messageTransporterGuest.markAsReady();
|
||||||
messageTransporterDecline.startSendingOfReadyRequests();
|
messageTransporterDecline.markAsReady();
|
||||||
|
|
||||||
jest.advanceTimersByTime(500);
|
jest.advanceTimersByTime(500);
|
||||||
});
|
});
|
||||||
|
|
|
@ -106,7 +106,7 @@ export class WebsocketGateway implements OnGatewayConnection {
|
||||||
|
|
||||||
realtimeNote.addClient(connection);
|
realtimeNote.addClient(connection);
|
||||||
|
|
||||||
websocketTransporter.startSendingOfReadyRequests();
|
websocketTransporter.markAsReady();
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
this.logger.error(
|
this.logger.error(
|
||||||
`Error occurred while initializing: ${(error as Error).message}`,
|
`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.
|
* 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.
|
* 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.thisSideReady = true
|
||||||
|
this.startSendingOfReadyRequests()
|
||||||
|
}
|
||||||
|
|
||||||
|
private startSendingOfReadyRequests(): void {
|
||||||
this.readyInterval = setInterval(() => {
|
this.readyInterval = setInterval(() => {
|
||||||
this.sendMessage({
|
this.sendMessage({
|
||||||
type: MessageType.READY_REQUEST
|
type: MessageType.READY_REQUEST
|
||||||
|
|
|
@ -180,10 +180,10 @@ describe('y-doc-sync-adapter', () => {
|
||||||
messageTransporterServerTo1.setAdapter(transporterAdapterServerTo1)
|
messageTransporterServerTo1.setAdapter(transporterAdapterServerTo1)
|
||||||
messageTransporterServerTo2.setAdapter(transporterAdapterServerTo2)
|
messageTransporterServerTo2.setAdapter(transporterAdapterServerTo2)
|
||||||
|
|
||||||
messageTransporterClient1.startSendingOfReadyRequests()
|
messageTransporterClient1.markAsReady()
|
||||||
messageTransporterClient2.startSendingOfReadyRequests()
|
messageTransporterClient2.markAsReady()
|
||||||
messageTransporterServerTo1.startSendingOfReadyRequests()
|
messageTransporterServerTo1.markAsReady()
|
||||||
messageTransporterServerTo2.startSendingOfReadyRequests()
|
messageTransporterServerTo2.markAsReady()
|
||||||
|
|
||||||
jest.advanceTimersByTime(1000)
|
jest.advanceTimersByTime(1000)
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ export const EditorPane: React.FC<EditorPaneProps> = ({ scrollState, onScroll, o
|
||||||
const mayEdit = useMayEdit()
|
const mayEdit = useMayEdit()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const listener = messageTransporter.doAsSoonAsConnected(() => messageTransporter.startSendingOfReadyRequests())
|
const listener = messageTransporter.doAsSoonAsConnected(() => messageTransporter.markAsReady())
|
||||||
return () => {
|
return () => {
|
||||||
listener.off()
|
listener.off()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue