Make "like" links one way

- Updated dolike() function to accept a "un-" switch
- [frio] Updated doLikeAction() function to call dolike() instead of having duplicated code
- Added boolean logic (with explanatory truth table) to smartly delete existing activities in Model\Item::performActivity
- Moved verb/activity parameter handling closer to their use in Model\Item::performActivity
- Updated all references to dolike() and doLikeAction() to include the "un-" switch
This commit is contained in:
Hypolite Petovan 2020-05-27 08:40:00 -04:00
parent e20d5ff0b5
commit df1c74bd33
13 changed files with 117 additions and 92 deletions

View file

@ -649,9 +649,15 @@ function imgdull(node) {
// trickery. This still could cause confusion if the "like" ajax call
// is delayed and NavUpdate runs before it completes.
function dolike(ident,verb) {
/**
* @param {int} ident The id of the relevant item
* @param {string} verb The verb of the action
* @param {boolean} un Whether to perform an activity removal instead of creation
*/
function dolike(ident, verb, un) {
unpause();
$('#like-rotator-' + ident.toString()).show();
verb = un ? 'un' + verb : verb;
$.get('like/' + ident.toString() + '?verb=' + verb, NavUpdate);
liking = 1;
force_update = true;