Skip to content
This repository has been archived by the owner on Apr 16, 2022. It is now read-only.

Commit

Permalink
HOTFIX: private fields are to early
Browse files Browse the repository at this point in the history
  • Loading branch information
ShoyuVanilla committed May 27, 2020
1 parent 83d3a50 commit a416cf2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions module/lang/en.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"cgmp.disable-gm-as-pc-s": "Disable GM speaking as PC tokens",
"cgmp.disable-gm-as-pc-l": "Make all chats GM says as PC into Out of Character chats, except rolls",
"cgmp.blind-hidden-tokens-s": "Blind chats out of hidden tokens",
"cgmp.blind-hidden-tokens-l": "Blind all chats out of hidden tokens, including rolls. Only GM can see them",
"cgmp.blind-hidden-tokens-s": "Blind chats made by hidden tokens",
"cgmp.blind-hidden-tokens-l": "Blind all chats made by hidden tokens, including rolls. Only GM can see them",
"cgmp.disable-chat-recall-s": "Disable Chat Recalls",
"cgmp.disable-chat-recall-l": "Disable using up and down arrow keys to recall chats, so that they can be used to move the text cursor",
"cgmp.notify-typing-s": "Notify typings",
Expand Down
58 changes: 29 additions & 29 deletions module/scripts/typing-notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,58 @@ const REMOTE_TYPING_TIMEOUT = 5000;
const TYPING_EMIT_INTERVAL = 200;

export class TypingNotifier {
#notifyWrapperElement;
#notifyDiv;
#typingUsers;
#isNoticeVisible;
#lastPacketSent;
_notifyWrapperElement;
_notifyDiv;
_typingUsers;
_isNoticeVisible;
_lastPacketSent;

constructor() {
this.#typingUsers = new Map();
this.#isNoticeVisible = false;
this._typingUsers = new Map();
this._isNoticeVisible = false;
this._render();
game.socket.on('module.CautiousGamemastersPack', data => this._onRemotePacket(data));
}

_render() {
this.#notifyWrapperElement = document.createElement("div");
this.#notifyWrapperElement.className = "typing-notify hidden";
this._notifyWrapperElement = document.createElement("div");
this._notifyWrapperElement.className = "typing-notify hidden";
let element = document.getElementById("chat-controls");
element.appendChild(this.#notifyWrapperElement);
element.appendChild(this._notifyWrapperElement);
let innerWrapper = document.createElement("div");
innerWrapper.innerHTML = '<span class="dots-cont"><span class="dot dot-1"></span><span class="dot dot-2"></span><span class="dot dot-3"></span></span>';
this.#notifyWrapperElement.appendChild(innerWrapper);
this.#notifyDiv = document.createElement("div");
this.#notifyDiv.className = "notify-text";
innerWrapper.appendChild(this.#notifyDiv);
this.#isNoticeVisible = false;
this._notifyWrapperElement.appendChild(innerWrapper);
this._notifyDiv = document.createElement("div");
this._notifyDiv.className = "notify-text";
innerWrapper.appendChild(this._notifyDiv);
this._isNoticeVisible = false;
}

_emitTypingEnd() {
game.socket.emit('module.CautiousGamemastersPack', {
header: PACKET_HEADER.TYPING_END,
user: game.user.id
});
this.#lastPacketSent = undefined;
this._lastPacketSent = undefined;
}

_emitTyping() {
if (this.#lastPacketSent && new Date().getTime - this.#lastPacketSent < TYPING_EMIT_INTERVAL) return;
if (this._lastPacketSent && new Date().getTime - this._lastPacketSent < TYPING_EMIT_INTERVAL) return;
game.socket.emit('module.CautiousGamemastersPack', {
header: PACKET_HEADER.TYPING_MESSAGE,
user: game.user.id
});
this.#lastPacketSent = new Date().getTime;
this._lastPacketSent = new Date().getTime;
}

_setVisible(visible) {
if (!this.#notifyWrapperElement || visible === this.#isNoticeVisible) return;
this.#isNoticeVisible = visible;
this.#notifyWrapperElement.classList.toggle('hidden');
if (!this._notifyWrapperElement || visible === this._isNoticeVisible) return;
this._isNoticeVisible = visible;
this._notifyWrapperElement.classList.toggle('hidden');
}

_onRemoteTypingEnded(id) {
this.#typingUsers.delete(id);
this._typingUsers.delete(id);
this.updateNotice();
}

Expand All @@ -79,13 +79,13 @@ export class TypingNotifier {
switch (data.header) {
case PACKET_HEADER.TYPING_MESSAGE:
let pushed = true;
if (this.#typingUsers.has(id)) { pushed = false; clearTimeout(this.#typingUsers.get(id)); }
this.#typingUsers.set(id,
if (this._typingUsers.has(id)) { pushed = false; clearTimeout(this._typingUsers.get(id)); }
this._typingUsers.set(id,
setTimeout(() => this._onRemoteTypingEnded(id), REMOTE_TYPING_TIMEOUT));
if (pushed) this.updateNotice();
break;
case PACKET_HEADER.TYPING_END:
if (this.#typingUsers.has(id)) clearTimeout(this.#typingUsers.get(id));
if (this._typingUsers.has(id)) clearTimeout(this._typingUsers.get(id));
this._onRemoteTypingEnded(id);
break;
default:
Expand All @@ -94,8 +94,8 @@ export class TypingNotifier {
}

updateNotice() {
if (!this.#notifyWrapperElement) return;
const mapSize = this.#typingUsers.size;
if (!this._notifyWrapperElement) return;
const mapSize = this._typingUsers.size;
if (mapSize === 0) {
this._setVisible(false);
return;
Expand All @@ -105,7 +105,7 @@ export class TypingNotifier {
let cnt = 0;
let users = [];

this.#typingUsers.forEach((value, key) => {
this._typingUsers.forEach((value, key) => {
users.push(game.users.get(key).name);
cnt++;
});
Expand All @@ -117,7 +117,7 @@ export class TypingNotifier {
} else {
text = game.i18n.format("cgmp.typing-many", { user1: users[0], user2: users[1], others: cnt - 2 });
}
this.#notifyDiv.innerHTML = text;
this._notifyDiv.innerHTML = text;

this._setVisible(true);
}
Expand Down

0 comments on commit a416cf2

Please sign in to comment.