From 61d4fb2ad104fdefd9a6ea0f25c3991fd7b80e65 Mon Sep 17 00:00:00 2001 From: Kalila L Date: Mon, 5 Oct 2020 20:40:58 -0400 Subject: [PATCH 1/6] First run script. --- scripts/defaultScripts.js | 3 ++- scripts/system/onFirstRun.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 scripts/system/onFirstRun.js diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index d9a86dbd91..71fb644528 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -35,7 +35,8 @@ var DEFAULT_SCRIPTS_COMBINED = [ "system/audioMuteOverlay.js", "system/inspect.js", "system/keyboardShortcuts/keyboardShortcuts.js", - "system/checkForUpdates.js" + "system/checkForUpdates.js", + "system/onFirstRun.js" ]; var DEFAULT_SCRIPTS_SEPARATE = [ "system/controllers/controllerScripts.js", diff --git a/scripts/system/onFirstRun.js b/scripts/system/onFirstRun.js new file mode 100644 index 0000000000..b2ab89a932 --- /dev/null +++ b/scripts/system/onFirstRun.js @@ -0,0 +1,28 @@ +'use strict'; + +// +// onFirstRun.js +// +// Created by Kalila L. on Oct 5 2020. +// Copyright 2020 Vircadia contributors. +// +// This script triggers on first run to perform first party +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +(function() { // BEGIN LOCAL_SCOPE + var SETTING_TO_CHECK = 'firstRun'; + var DEFAULT_NAME = 'anonymous'; + + if (Settings.getValue('firstRun', false)) { + var selectedDisplayName = Window.prompt('Enter a display name.', MyAvatar.displayName); + + if (selectedDisplayName === '') { + MyAvatar.displayName = DEFAULT_NAME; + } else { + MyAvatar.displayName = selectedDisplayName; + } + } +}()); \ No newline at end of file From 4154e16f77f9bf76c1c605d9c54b57132a8345d7 Mon Sep 17 00:00:00 2001 From: kasenvr <52365539+kasenvr@users.noreply.github.com> Date: Mon, 12 Oct 2020 16:46:46 -0400 Subject: [PATCH 2/6] Update onFirstRun.js --- scripts/system/onFirstRun.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/onFirstRun.js b/scripts/system/onFirstRun.js index b2ab89a932..05d59a9e26 100644 --- a/scripts/system/onFirstRun.js +++ b/scripts/system/onFirstRun.js @@ -6,7 +6,7 @@ // Created by Kalila L. on Oct 5 2020. // Copyright 2020 Vircadia contributors. // -// This script triggers on first run to perform first party +// This script triggers on first run to perform bootstrapping actions. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -25,4 +25,4 @@ MyAvatar.displayName = selectedDisplayName; } } -}()); \ No newline at end of file +}()); From 58cfb75d4109df73ad605bb4f69299b19477f7a3 Mon Sep 17 00:00:00 2001 From: kasenvr <52365539+kasenvr@users.noreply.github.com> Date: Mon, 12 Oct 2020 18:03:21 -0400 Subject: [PATCH 3/6] Update onFirstRun.js --- scripts/system/onFirstRun.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/onFirstRun.js b/scripts/system/onFirstRun.js index 05d59a9e26..b7efc24297 100644 --- a/scripts/system/onFirstRun.js +++ b/scripts/system/onFirstRun.js @@ -14,9 +14,9 @@ (function() { // BEGIN LOCAL_SCOPE var SETTING_TO_CHECK = 'firstRun'; - var DEFAULT_NAME = 'anonymous'; + var DEFAULT_NAME = ''; - if (Settings.getValue('firstRun', false)) { + if ((Settings.getValue('firstRun', false) && MyAvatar.displayName === '') || MyAvatar.displayName === '') { var selectedDisplayName = Window.prompt('Enter a display name.', MyAvatar.displayName); if (selectedDisplayName === '') { From 6442055600d53a76dca90c90b0f39c0de20b0f0e Mon Sep 17 00:00:00 2001 From: kasenvr <52365539+kasenvr@users.noreply.github.com> Date: Tue, 13 Oct 2020 04:59:04 -0400 Subject: [PATCH 4/6] Apply suggestions from code review Co-authored-by: David Rowe --- scripts/system/onFirstRun.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/system/onFirstRun.js b/scripts/system/onFirstRun.js index b7efc24297..785017b935 100644 --- a/scripts/system/onFirstRun.js +++ b/scripts/system/onFirstRun.js @@ -14,9 +14,13 @@ (function() { // BEGIN LOCAL_SCOPE var SETTING_TO_CHECK = 'firstRun'; - var DEFAULT_NAME = ''; + var DEFAULT_DISPLAY_NAME = ''; - if ((Settings.getValue('firstRun', false) && MyAvatar.displayName === '') || MyAvatar.displayName === '') { + if (!Settings.getValue('firstRun', false)) { + return; + } + + if (MyAvatar.displayName === '') { var selectedDisplayName = Window.prompt('Enter a display name.', MyAvatar.displayName); if (selectedDisplayName === '') { From 4dd1026e1f822aff4c4f4080e69fe7ec0453318f Mon Sep 17 00:00:00 2001 From: kasenvr <52365539+kasenvr@users.noreply.github.com> Date: Tue, 13 Oct 2020 04:59:49 -0400 Subject: [PATCH 5/6] Update onFirstRun.js --- scripts/system/onFirstRun.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/onFirstRun.js b/scripts/system/onFirstRun.js index 785017b935..03bdae8e4e 100644 --- a/scripts/system/onFirstRun.js +++ b/scripts/system/onFirstRun.js @@ -16,7 +16,7 @@ var SETTING_TO_CHECK = 'firstRun'; var DEFAULT_DISPLAY_NAME = ''; - if (!Settings.getValue('firstRun', false)) { + if (!Settings.getValue(SETTING_TO_CHECK, false)) { return; } From 2777854e73a1357a2d99cb5c76eb612d46cc7996 Mon Sep 17 00:00:00 2001 From: kasenvr <52365539+kasenvr@users.noreply.github.com> Date: Tue, 13 Oct 2020 15:51:52 -0400 Subject: [PATCH 6/6] Update scripts/system/onFirstRun.js Co-authored-by: David Rowe --- scripts/system/onFirstRun.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/onFirstRun.js b/scripts/system/onFirstRun.js index 03bdae8e4e..65c1d06ec5 100644 --- a/scripts/system/onFirstRun.js +++ b/scripts/system/onFirstRun.js @@ -24,7 +24,7 @@ var selectedDisplayName = Window.prompt('Enter a display name.', MyAvatar.displayName); if (selectedDisplayName === '') { - MyAvatar.displayName = DEFAULT_NAME; + MyAvatar.displayName = DEFAULT_DISPLAY_NAME; } else { MyAvatar.displayName = selectedDisplayName; }