Skip to content

Commit d57b574

Browse files
committed
fix: don't send a message to pubnub when there aren't files to sync
In case when some platform specific file is changed, "applyChanges" message should be send only for the file's platform.
1 parent 10d31d4 commit d57b574

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/services/livesync/playground/preview-app-livesync-service.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,13 @@ export class PreviewAppLiveSyncService implements IPreviewAppLiveSyncService {
108108
}
109109

110110
private async syncFilesForPlatformSafe(data: IPreviewAppLiveSyncData, filesData: IPreviewAppFilesData, platform: string, deviceId?: string): Promise<void> {
111-
this.$logger.info(`Start syncing changes for platform ${platform}.`);
112-
113111
try {
114112
const payloads = this.$previewAppFilesService.getFilesPayload(data, filesData, platform);
115-
await this.$previewSdkService.applyChanges(payloads);
116-
this.$logger.info(`Successfully synced ${payloads.files.map(filePayload => filePayload.file.yellow)} for platform ${platform}.`);
113+
if (payloads && payloads.files && payloads.files.length) {
114+
this.$logger.info(`Start syncing changes for platform ${platform}.`);
115+
await this.$previewSdkService.applyChanges(payloads);
116+
this.$logger.info(`Successfully synced ${payloads.files.map(filePayload => filePayload.file.yellow)} for platform ${platform}.`);
117+
}
117118
} catch (err) {
118119
this.$logger.warn(`Unable to apply changes for platform ${platform}. Error is: ${err}, ${stringify(err)}.`);
119120
}

0 commit comments

Comments
 (0)