Commit 9aba0ca6 authored by Robert Knight's avatar Robert Knight

Inline `_handle{Annotation,SessionChange}Notification` helpers

These methods are short and only called in one place, so there is not a
lot of value in having them as separate methods.
parent 26711012
...@@ -80,31 +80,6 @@ export class StreamerService { ...@@ -80,31 +80,6 @@ export class StreamerService {
this._store.clearPendingUpdates(); this._store.clearPendingUpdates();
} }
_handleAnnotationNotification(message) {
const action = message.options.action;
const annotations = message.payload;
switch (action) {
case 'create':
case 'update':
case 'past':
this._store.receiveRealTimeUpdates({ updatedAnnotations: annotations });
break;
case 'delete':
this._store.receiveRealTimeUpdates({ deletedAnnotations: annotations });
break;
}
if (this._updateImmediately) {
this.applyPendingUpdates();
}
}
_handleSessionChangeNotification(message) {
this._session.update(message.model);
this._groups.load();
}
/** @param {ErrorEvent} event */ /** @param {ErrorEvent} event */
_handleSocketError(event) { _handleSocketError(event) {
warnOnce('Error connecting to H push notification service:', event); warnOnce('Error connecting to H push notification service:', event);
...@@ -133,9 +108,28 @@ export class StreamerService { ...@@ -133,9 +108,28 @@ export class StreamerService {
} }
if (message.type === 'annotation-notification') { if (message.type === 'annotation-notification') {
this._handleAnnotationNotification(message); const annotations = message.payload;
switch (message.options.action) {
case 'create':
case 'update':
case 'past':
this._store.receiveRealTimeUpdates({
updatedAnnotations: annotations,
});
break;
case 'delete':
this._store.receiveRealTimeUpdates({
deletedAnnotations: annotations,
});
break;
}
if (this._updateImmediately) {
this.applyPendingUpdates();
}
} else if (message.type === 'session-change') { } else if (message.type === 'session-change') {
this._handleSessionChangeNotification(message); this._session.update(message.model);
this._groups.load();
} else if (message.type === 'whoyouare') { } else if (message.type === 'whoyouare') {
const userid = this._store.profile().userid; const userid = this._store.profile().userid;
if (message.userid !== userid) { if (message.userid !== userid) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment