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

View file

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

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;
function startup() {
nameTagListManager.create();
handleAvatarNametagMode(Settings.getValue("simplifiedNametag/avatarNametagMode", "on"));
Script.scriptEnding.connect(unload);
Window.domainChanged.connect(onDomainChange);
AvatarManager.avatarRemovedEvent.connect(onAvatarRemoved);
AvatarManager.avatarAddedEvent.connect(onAvatarAdded);
function NameTag() {}
NameTag.prototype = {
handleAvatarNametagMode: handleAvatarNametagMode
};
return new NameTag();
}
@ -77,23 +86,7 @@ function handleAvatarNametagMode(newAvatarNameTagMode) {
}
// *************************************
// START api
// *************************************
// #region api
var nameTag = startup();
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
function simplifiedStatusIndicator(properties) {
function SimplifiedStatusIndicator() {
var that = this;
var DEBUG = false;
@ -86,6 +86,7 @@ function simplifiedStatusIndicator(properties) {
});
}
// Get status from database
function getStatus(callback) {
var queryParamString = "type=getStatus";
@ -125,6 +126,17 @@ function simplifiedStatusIndicator(properties) {
// #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
function toggleStatus() {
if (currentStatus === "busy") {
@ -207,6 +219,8 @@ function simplifiedStatusIndicator(properties) {
Window.domainChanged.connect(onDomainChanged);
getStatus(setStatus);
Script.scriptEnding.connect(unload);
}
@ -224,20 +238,15 @@ function simplifiedStatusIndicator(properties) {
// #endregion APP LIFETIME
that.startup = startup;
that.unload = unload;
that.toggleStatus = toggleStatus;
that.setStatus = setStatus;
that.getLocalStatus = getLocalStatus;
that.statusChanged = statusChanged;
// Overwrite with the given properties
var overwriteableKeys = ["statusChanged"];
Object.keys(properties).forEach(function (key) {
if (overwriteableKeys.indexOf(key) > -1) {
that[key] = properties[key];
}
});
that.updateProperties = updateProperties;
startup();
}
var simplifiedStatusIndicator = new SimplifiedStatusIndicator();
module.exports = simplifiedStatusIndicator;

View file

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