From e3d44d7d0649cb05cdef65cd015568b1ad9526d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 2 Jun 2017 16:05:12 +0200 Subject: [PATCH] Use client default if server default printer profile in unavailable --- .../static/js/app/viewmodels/printerprofiles.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/octoprint/static/js/app/viewmodels/printerprofiles.js b/src/octoprint/static/js/app/viewmodels/printerprofiles.js index f19484a6..368f80ce 100644 --- a/src/octoprint/static/js/app/viewmodels/printerprofiles.js +++ b/src/octoprint/static/js/app/viewmodels/printerprofiles.js @@ -476,8 +476,16 @@ $(function() { }); self.profiles.updateItems(items); self.defaultProfile(defaultProfile); - self.currentProfile(currentProfile); - self.currentProfileData(currentProfileData); + + if (currentProfile && currentProfileData) { + self.currentProfile(currentProfile); + self.currentProfileData(currentProfileData); + } else { + // shouldn't normally happen, but just to not have anything else crash... + log.warn("Current printer profile could not be detected, using default values"); + self.currentProfile(""); + self.currentProfileData(ko.mapping.fromJS(cleanProfile(), self.currentProfileData)); + } }; self.addProfile = function(callback) {