StringUtil = tslib_1.__importStar(StringUtil);
Handler_1 = tslib_1.__importDefault(Handler_1);
User_1 = tslib_1.__importDefault(User_1);
+ const availableReactions = new Map(Object.entries(window.REACTION_TYPES));
class UiLikeHandler {
/**
* Initializes the like handler.
*/
constructor(objectType, opts) {
- this._containers = new Map();
+ this._containers = new WeakMap();
if (!opts.containerSelector) {
throw new Error("[WoltLabSuite/Core/Ui/Like/Handler] Expected a non-empty string for option 'containerSelector'.");
}
else {
summaryList.classList.add("reactionSummaryListTiny");
}
- const availableReactions = new Map(Object.entries(window.REACTION_TYPES));
Object.entries(elementData.users).forEach(([reactionTypeId, count]) => {
const reaction = availableReactions.get(reactionTypeId);
if (reactionTypeId === "reactionTypeID" || !reaction) {
EventHandler = tslib_1.__importStar(EventHandler);
StringUtil = tslib_1.__importStar(StringUtil);
Dialog_1 = tslib_1.__importDefault(Dialog_1);
+ const availableReactions = new Map(Object.entries(window.REACTION_TYPES));
class CountButtons {
/**
* Initializes the like handler.
reaction.remove();
}
});
- const availableReactions = new Map(Object.entries(window.REACTION_TYPES));
existingReactions.forEach((count, reactionTypeId) => {
if (sortedElements.has(reactionTypeId)) {
const reaction = sortedElements.get(reactionTypeId);
CloseOverlay_1 = tslib_1.__importDefault(CloseOverlay_1);
UiScreen = tslib_1.__importStar(UiScreen);
CountButtons_1 = tslib_1.__importDefault(CountButtons_1);
+ const availableReactions = Object.values(window.REACTION_TYPES);
class UiReactionHandler {
/**
* Initializes the reaction handler.
// The element may have no react button.
return;
}
- const availableReactions = Object.values(window.REACTION_TYPES);
if (availableReactions.length === 1) {
const reaction = availableReactions[0];
elementData.reactButton.title = reaction.title;
event.preventDefault();
event.stopPropagation();
}
- const availableReactions = Object.values(window.REACTION_TYPES);
if (availableReactions.length === 1) {
const reaction = availableReactions[0];
this._popoverCurrentObjectId = objectId;
* Sort the reaction types by the showOrder field.
*/
_getSortedReactionTypes() {
- return Object.values(window.REACTION_TYPES).sort((a, b) => a.showOrder - b.showOrder);
+ return availableReactions.sort((a, b) => a.showOrder - b.showOrder);
}
/**
* Closes the react popover.
users: LikeUsers;
}
+const availableReactions = new Map(Object.entries(window.REACTION_TYPES));
+
class UiLikeHandler {
- protected readonly _containers = new Map<HTMLElement, ElementData>();
+ protected readonly _containers = new WeakMap<HTMLElement, ElementData>();
protected readonly _objectType: string;
protected readonly _options: LikeHandlerOptions;
summaryList.classList.add("reactionSummaryListTiny");
}
- const availableReactions = new Map(Object.entries(window.REACTION_TYPES));
Object.entries(elementData.users).forEach(([reactionTypeId, count]) => {
const reaction = availableReactions.get(reactionTypeId);
if (reactionTypeId === "reactionTypeID" || !reaction) {
};
}
+const availableReactions = new Map<string, Reaction>(Object.entries(window.REACTION_TYPES));
+
class CountButtons {
protected readonly _containers = new Map<string, ElementData>();
protected _currentObjectId = 0;
}
});
- const availableReactions = new Map<string, Reaction>(Object.entries(window.REACTION_TYPES));
-
existingReactions.forEach((count, reactionTypeId) => {
if (sortedElements.has(reactionTypeId)) {
const reaction = sortedElements.get(reactionTypeId)!;
};
}
+const availableReactions = Object.values(window.REACTION_TYPES);
+
class UiReactionHandler {
readonly countButtons: CountButtons;
protected readonly _cache = new Map<string, unknown>();
return;
}
- const availableReactions = Object.values(window.REACTION_TYPES);
if (availableReactions.length === 1) {
const reaction = availableReactions[0];
elementData.reactButton.title = reaction.title;
event.stopPropagation();
}
- const availableReactions = Object.values(window.REACTION_TYPES);
if (availableReactions.length === 1) {
const reaction = availableReactions[0];
this._popoverCurrentObjectId = objectId;
* Sort the reaction types by the showOrder field.
*/
protected _getSortedReactionTypes(): Reaction[] {
- return Object.values(window.REACTION_TYPES).sort((a, b) => a.showOrder - b.showOrder);
+ return availableReactions.sort((a, b) => a.showOrder - b.showOrder);
}
/**