Merge pull request #16135 from MiladNazeri/bugz-1395/emoji-stuck-on-start

[bugz-1415] :: Emoji App trying to shut down twice
This commit is contained in:
MiladNazeri 2019-09-05 11:14:11 -07:00 committed by GitHub
commit 21b8e268c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 64 additions and 147 deletions

View file

@ -388,7 +388,8 @@ function playPopAnimation() {
var emojiCodeMap; var emojiCodeMap;
var customEmojiCodeMap; var customEmojiCodeMap;
var signalsConnected = false; var signalsConnected = false;
function init() { var _this;
function startup() {
// make a map of just the utf codes to help with accesing // make a map of just the utf codes to help with accesing
emojiCodeMap = emojiList.reduce(function (codeMap, currentEmojiInList, index) { emojiCodeMap = emojiList.reduce(function (codeMap, currentEmojiInList, index) {
if ( if (
@ -414,55 +415,30 @@ function init() {
pruneOldAvimojis(); pruneOldAvimojis();
Script.scriptEnding.connect(unload);
Window.domainChanged.connect(onDomainChanged); Window.domainChanged.connect(onDomainChanged);
MyAvatar.scaleChanged.connect(onScaleChanged); MyAvatar.scaleChanged.connect(onScaleChanged);
Script.scriptEnding.connect(scriptEnding);
signalsConnected = true; signalsConnected = true;
}
function AviMoji() {
// #endregion _this = this;
// ************************************* this._avimojiQMLWindow = null;
// END main
// *************************************
// *************************************
// START cleanup
// *************************************
// #region cleanup
function scriptEnding() {
resetEmojis();
if (signalsConnected) {
Script.scriptEnding.disconnect(scriptEnding);
Window.domainChanged.disconnect(onDomainChanged);
MyAvatar.scaleChanged.disconnect(onScaleChanged);
signalsConnected = false;
} }
AviMoji.prototype = {
addEmoji: addEmojiFromQML,
registerAvimojiQMLWindow: registerAvimojiQMLWindow
};
return new AviMoji();
} }
// #endregion
// *************************************
// END cleanup
// *************************************
// *************************************
// START API
// *************************************
// #region API
var _this;
function AviMoji() {
_this = this;
this._avimojiQMLWindow;
}
function registerAvimojiQMLWindow(avimojiQMLWindow) { function registerAvimojiQMLWindow(avimojiQMLWindow) {
this._avimojiQMLWindow = avimojiQMLWindow; this._avimojiQMLWindow = avimojiQMLWindow;
} }
function addEmojiFromQML(code) { function addEmojiFromQML(code) {
var emojiObject = emojiList[emojiCodeMap[code]]; var emojiObject = emojiList[emojiCodeMap[code]];
var emojiFilename; var emojiFilename;
@ -475,25 +451,17 @@ function addEmojiFromQML(code) {
handleSelectedEmoji(emojiFilename); handleSelectedEmoji(emojiFilename);
} }
function unload() { function unload() {
scriptEnding(); resetEmojis();
if (signalsConnected) {
Window.domainChanged.disconnect(onDomainChanged);
MyAvatar.scaleChanged.disconnect(onScaleChanged);
signalsConnected = false;
}
} }
function startup() {
init();
}
AviMoji.prototype = { var aviMoji = startup();
startup: startup,
addEmoji: addEmojiFromQML,
unload: unload,
registerAvimojiQMLWindow: registerAvimojiQMLWindow
};
module.exports = aviMoji;
module.exports = AviMoji;
// #endregion
// *************************************
// END API
// *************************************

View file

@ -38,7 +38,6 @@ var customEmojiList = Script.require("./emojiApp/resources/modules/customEmojiLi
// #region EMOTE_UTILITY // #region EMOTE_UTILITY
function updateEmoteAppBarPosition() { function updateEmoteAppBarPosition() {
if (!emoteAppBarWindow) { if (!emoteAppBarWindow) {
return; return;
@ -544,12 +543,11 @@ function onDisplayModeChanged(isHMDMode) {
} }
var EmojiAPI = Script.require("./emojiApp/simplifiedEmoji.js"); var emojiAPI = Script.require("./emojiApp/simplifiedEmoji.js");
var emojiAPI = new EmojiAPI();
var keyPressSignalsConnected = false; var keyPressSignalsConnected = false;
var emojiCodeMap; var emojiCodeMap;
var customEmojiCodeMap; var customEmojiCodeMap;
function init() { function setup() {
deleteOldReticles(); deleteOldReticles();
// make a map of just the utf codes to help with accesing // make a map of just the utf codes to help with accesing
@ -578,7 +576,6 @@ function init() {
Window.minimizedChanged.connect(onWindowMinimizedChanged); Window.minimizedChanged.connect(onWindowMinimizedChanged);
Window.geometryChanged.connect(onGeometryChanged); Window.geometryChanged.connect(onGeometryChanged);
HMD.displayModeChanged.connect(onDisplayModeChanged); HMD.displayModeChanged.connect(onDisplayModeChanged);
emojiAPI.startup();
getSounds(); getSounds();
handleEmoteIndicatorVisibleChanged(true); handleEmoteIndicatorVisibleChanged(true);
@ -586,12 +583,11 @@ function init() {
Controller.keyPressEvent.connect(keyPressHandler); Controller.keyPressEvent.connect(keyPressHandler);
Controller.keyReleaseEvent.connect(keyReleaseHandler); Controller.keyReleaseEvent.connect(keyReleaseHandler);
keyPressSignalsConnected = true; keyPressSignalsConnected = true;
Script.scriptEnding.connect(unload);
Script.scriptEnding.connect(shutdown);
} }
function shutdown() { function unload() {
if (emoteAppBarWindow) { if (emoteAppBarWindow) {
emoteAppBarWindow.fromQml.disconnect(onMessageFromEmoteAppBar); emoteAppBarWindow.fromQml.disconnect(onMessageFromEmoteAppBar);
emoteAppBarWindow.close(); emoteAppBarWindow.close();
@ -606,7 +602,6 @@ function shutdown() {
endReactionWrapper(react); endReactionWrapper(react);
}); });
emojiAPI.unload();
maybeClearClapSoundInterval(); maybeClearClapSoundInterval();
maybeClearReticleUpdateLimiterTimeout(); maybeClearReticleUpdateLimiterTimeout();
maybeDeleteRemoteIndicatorTimeout(); maybeDeleteRemoteIndicatorTimeout();
@ -759,37 +754,4 @@ function toggleEmojiApp() {
// END EMOJI // END EMOJI
// ************************************* // *************************************
// ************************************* setup();
// START API
// *************************************
// #region API
function startup() {
init();
}
function unload() {
shutdown();
}
var _this;
function EmoteBar() {
_this = this;
}
EmoteBar.prototype = {
startup: startup,
unload: unload
};
module.exports = EmoteBar;
// #endregion
// *************************************
// END API
// *************************************

View file

@ -47,15 +47,24 @@ function onAvatarAdded(uuid) {
} }
// Called on init // Create a new nametag list manager, connect signals, and return back a new Nametag object.
var avatarNametagMode; var avatarNametagMode;
function startup() { function startup() {
nameTagListManager.create(); nameTagListManager.create();
handleAvatarNametagMode(Settings.getValue("simplifiedNametag/avatarNametagMode", "on")); handleAvatarNametagMode(Settings.getValue("simplifiedNametag/avatarNametagMode", "on"));
Script.scriptEnding.connect(unload);
Window.domainChanged.connect(onDomainChange); Window.domainChanged.connect(onDomainChange);
AvatarManager.avatarRemovedEvent.connect(onAvatarRemoved); AvatarManager.avatarRemovedEvent.connect(onAvatarRemoved);
AvatarManager.avatarAddedEvent.connect(onAvatarAdded); AvatarManager.avatarAddedEvent.connect(onAvatarAdded);
function NameTag() {}
NameTag.prototype = {
handleAvatarNametagMode: handleAvatarNametagMode
};
return new NameTag();
} }
@ -77,23 +86,7 @@ function handleAvatarNametagMode(newAvatarNameTagMode) {
} }
// ************************************* var nameTag = startup();
// START api
// *************************************
// #region api
function NameTag() {} module.exports = nameTag;
NameTag.prototype = {
startup: startup,
unload: unload,
handleAvatarNametagMode: handleAvatarNametagMode
};
module.exports = NameTag;
// #endregion
// *************************************
// END api
// *************************************

View file

@ -8,7 +8,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
function simplifiedStatusIndicator(properties) { function SimplifiedStatusIndicator() {
var that = this; var that = this;
var DEBUG = false; var DEBUG = false;
@ -86,6 +86,7 @@ function simplifiedStatusIndicator(properties) {
}); });
} }
// Get status from database // Get status from database
function getStatus(callback) { function getStatus(callback) {
var queryParamString = "type=getStatus"; var queryParamString = "type=getStatus";
@ -125,6 +126,17 @@ function simplifiedStatusIndicator(properties) {
// #region SIGNALS // #region SIGNALS
function updateProperties(properties) {
// Overwrite with the given properties
var overwriteableKeys = ["statusChanged"];
Object.keys(properties).forEach(function (key) {
if (overwriteableKeys.indexOf(key) > -1) {
that[key] = properties[key];
}
});
}
var currentStatus = "available"; // Default is available var currentStatus = "available"; // Default is available
function toggleStatus() { function toggleStatus() {
if (currentStatus === "busy") { if (currentStatus === "busy") {
@ -207,6 +219,8 @@ function simplifiedStatusIndicator(properties) {
Window.domainChanged.connect(onDomainChanged); Window.domainChanged.connect(onDomainChanged);
getStatus(setStatus); getStatus(setStatus);
Script.scriptEnding.connect(unload);
} }
@ -224,20 +238,15 @@ function simplifiedStatusIndicator(properties) {
// #endregion APP LIFETIME // #endregion APP LIFETIME
that.startup = startup;
that.unload = unload;
that.toggleStatus = toggleStatus; that.toggleStatus = toggleStatus;
that.setStatus = setStatus; that.setStatus = setStatus;
that.getLocalStatus = getLocalStatus; that.getLocalStatus = getLocalStatus;
that.statusChanged = statusChanged; that.statusChanged = statusChanged;
that.updateProperties = updateProperties;
// Overwrite with the given properties
var overwriteableKeys = ["statusChanged"]; startup();
Object.keys(properties).forEach(function (key) {
if (overwriteableKeys.indexOf(key) > -1) {
that[key] = properties[key];
}
});
} }
var simplifiedStatusIndicator = new SimplifiedStatusIndicator();
module.exports = simplifiedStatusIndicator; module.exports = simplifiedStatusIndicator;

View file

@ -583,12 +583,9 @@ function restoreLODSettings() {
} }
var SimplifiedNametag = Script.require("./simplifiedNametag/simplifiedNametag.js?" + Date.now()); var nametag = Script.require("./simplifiedNametag/simplifiedNametag.js?" + Date.now());
var SimplifiedStatusIndicator = Script.require("./simplifiedStatusIndicator/simplifiedStatusIndicator.js?" + Date.now()); var si = Script.require("./simplifiedStatusIndicator/simplifiedStatusIndicator.js?" + Date.now())
var SimplifiedEmote = Script.require("../simplifiedEmote/simplifiedEmote.js?" + Date.now()); var emote = Script.require("../simplifiedEmote/simplifiedEmote.js?" + Date.now());
var si;
var nametag;
var emote;
var oldShowAudioTools; var oldShowAudioTools;
var oldShowBubbleTools; var oldShowBubbleTools;
var keepExistingUIAndScriptsSetting = Settings.getValue("simplifiedUI/keepExistingUIAndScripts", false); var keepExistingUIAndScriptsSetting = Settings.getValue("simplifiedUI/keepExistingUIAndScripts", false);
@ -607,16 +604,8 @@ function startup() {
loadSimplifiedTopBar(); loadSimplifiedTopBar();
si = new SimplifiedStatusIndicator({
statusChanged: onStatusChanged
});
si.startup();
nametag = new SimplifiedNametag(); si.updateProperties({ statusChanged: onStatusChanged });
nametag.startup();
emote = new SimplifiedEmote();
emote.startup();
updateInputDeviceMutedOverlay(Audio.muted); updateInputDeviceMutedOverlay(Audio.muted);
updateOutputDeviceMutedOverlay(isOutputMuted()); updateOutputDeviceMutedOverlay(isOutputMuted());
@ -665,10 +654,6 @@ function shutdown() {
maybeDeleteInputDeviceMutedOverlay(); maybeDeleteInputDeviceMutedOverlay();
maybeDeleteOutputDeviceMutedOverlay(); maybeDeleteOutputDeviceMutedOverlay();
nametag.unload();
si.unload();
emote.unload();
Audio.mutedDesktopChanged.disconnect(onDesktopInputDeviceMutedChanged); Audio.mutedDesktopChanged.disconnect(onDesktopInputDeviceMutedChanged);
Audio.mutedHMDChanged.disconnect(onHMDInputDeviceMutedChanged); Audio.mutedHMDChanged.disconnect(onHMDInputDeviceMutedChanged);
Window.geometryChanged.disconnect(onGeometryChanged); Window.geometryChanged.disconnect(onGeometryChanged);