Comparing version 0.3.0-alpha to 0.3.1-alpha
@@ -16,4 +16,4 @@ import Ressource from "../class/Resource"; | ||
file: string; | ||
ressource: string | undefined; | ||
resource: string | undefined; | ||
}; | ||
} |
@@ -21,3 +21,3 @@ /** Represents a attachment in a ressource */ | ||
file: this.file, | ||
ressource: (_a = this.resource) === null || _a === void 0 ? void 0 : _a.getIri(), | ||
resource: (_a = this.resource) === null || _a === void 0 ? void 0 : _a.getIri(), | ||
}; | ||
@@ -24,0 +24,0 @@ }; |
@@ -16,4 +16,4 @@ import Resource from "../class/Resource"; | ||
comment: string; | ||
ressource: string | undefined; | ||
resource: string | undefined; | ||
}; | ||
} |
@@ -21,3 +21,3 @@ /** Represents a comment in a resource */ | ||
comment: this.comment, | ||
ressource: (_a = this.resource) === null || _a === void 0 ? void 0 : _a.getIri(), | ||
resource: (_a = this.resource) === null || _a === void 0 ? void 0 : _a.getIri(), | ||
}; | ||
@@ -24,0 +24,0 @@ }; |
@@ -32,3 +32,3 @@ import Category from "../class/Category"; | ||
file: string; | ||
ressource: string | undefined; | ||
resource: string | undefined; | ||
}[]; | ||
@@ -35,0 +35,0 @@ categories: string[]; |
@@ -36,4 +36,3 @@ import { APIResourceData } from "../@types"; | ||
private getCreator; | ||
private getYourLike; | ||
hasLike(): boolean; | ||
isLiked(): boolean; | ||
like(): void; | ||
@@ -40,0 +39,0 @@ unlike(): void; |
@@ -33,15 +33,5 @@ import { __extends } from "tslib"; | ||
}; | ||
Resource.prototype.getYourLike = function () { | ||
var _this = this; | ||
if (this.client.auth.me) { | ||
var me = this.likes.cache.find(function (l) { var _a, _b; return ((_a = l.user) === null || _a === void 0 ? void 0 : _a.id) === ((_b = _this.client.auth.me) === null || _b === void 0 ? void 0 : _b.id); }); | ||
if (me) { | ||
return me; | ||
} | ||
} | ||
return null; | ||
}; | ||
/* Check if the current user like this resource */ | ||
Resource.prototype.hasLike = function () { | ||
return this.getYourLike() ? true : false; | ||
Resource.prototype.isLiked = function () { | ||
return this.likes.getMeLike() ? true : false; | ||
}; | ||
@@ -57,3 +47,3 @@ /* Current user like this resource */ | ||
Resource.prototype.unlike = function () { | ||
var l = this.getYourLike(); | ||
var l = this.likes.getMeLike(); | ||
if (l) { | ||
@@ -60,0 +50,0 @@ this.likes.remove(l); |
@@ -13,2 +13,4 @@ import { Collection } from "@discordjs/collection"; | ||
constructor(resource: Resource, data: APIResourceUserLikeData[]); | ||
/** Check if authenticated user has like this resource */ | ||
getMeLike(): UserLike | null; | ||
/** Add a like to this Resource */ | ||
@@ -15,0 +17,0 @@ add(like: UserLikeBuilder): Promise<Resource>; |
@@ -13,9 +13,24 @@ import { __awaiter, __extends, __generator } from "tslib"; | ||
} | ||
/** Check if authenticated user has like this resource */ | ||
ResourceLikeManager.prototype.getMeLike = function () { | ||
var _this = this; | ||
if (this.client.auth.me) { | ||
var me = this.cache.find(function (l) { var _a, _b; return ((_a = l.user) === null || _a === void 0 ? void 0 : _a.id) === ((_b = _this.client.auth.me) === null || _b === void 0 ? void 0 : _b.id); }); | ||
if (me) { | ||
return me; | ||
} | ||
} | ||
return null; | ||
}; | ||
/** Add a like to this Resource */ | ||
ResourceLikeManager.prototype.add = function (like) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var json, likeData, userLike; | ||
var hasPreviousLike, json, likeData, userLike; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
hasPreviousLike = this.getMeLike(); | ||
if (hasPreviousLike) { | ||
return [2 /*return*/, this.resource]; | ||
} | ||
json = like.setResource(this.resource).toJSON(); | ||
@@ -22,0 +37,0 @@ return [4 /*yield*/, this.client.rest.postRequest("/user_likes", json, true)]; |
@@ -16,11 +16,9 @@ import { __awaiter, __extends, __generator } from "tslib"; | ||
var collection = new Collection(); | ||
if (this.client.auth.token) { | ||
this.fetchAll() | ||
.then(function (data) { | ||
for (var _i = 0, data_1 = data; _i < data_1.length; _i++) { | ||
var a = data_1[_i]; | ||
collection.set(a.id, a); | ||
} | ||
}); | ||
} | ||
this.fetchAll() | ||
.then(function (data) { | ||
for (var _i = 0, data_1 = data; _i < data_1.length; _i++) { | ||
var a = data_1[_i]; | ||
collection.set(a.id, a); | ||
} | ||
}); | ||
return collection; | ||
@@ -27,0 +25,0 @@ }; |
{ | ||
"name": "rr-apilib", | ||
"version": "0.3.0-alpha", | ||
"version": "0.3.1-alpha", | ||
"description": "Library for interact with RR-API", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
158850
2249