Comparing version 0.5.0-alpha to 0.5.2-alpha
@@ -41,4 +41,4 @@ import { APIResourceData } from "../@types"; | ||
isLiked(): boolean; | ||
like(): void; | ||
unlike(): void; | ||
like(): Promise<Resource> | undefined; | ||
unlike(): Promise<Resource> | undefined; | ||
/** Return data for api request */ | ||
@@ -45,0 +45,0 @@ toJSON(): { |
@@ -48,3 +48,3 @@ import { __extends } from "tslib"; | ||
if (me) { | ||
this.likes.add(new UserLikeBuilder().setUser(me)); | ||
return this.likes.add(new UserLikeBuilder().setUser(me)); | ||
} | ||
@@ -56,3 +56,3 @@ }; | ||
if (l) { | ||
this.likes.remove(l); | ||
return this.likes.remove(l); | ||
} | ||
@@ -59,0 +59,0 @@ }; |
@@ -12,2 +12,4 @@ import { Collection } from "@discordjs/collection"; | ||
constructor(resource: Resource); | ||
/** Sort comments by created date */ | ||
sort(): Collection<string, Comment>; | ||
/** Create a new comment for this resource */ | ||
@@ -14,0 +16,0 @@ create(data: CommentBuilder): Promise<Resource>; |
@@ -16,4 +16,12 @@ import { __awaiter, __extends, __generator } from "tslib"; | ||
} | ||
var sorted = _this.sort(); | ||
_this.cache = sorted; | ||
return _this; | ||
} | ||
/** Sort comments by created date */ | ||
ResourceCommentManager.prototype.sort = function () { | ||
return this.cache.sort(function (c1, c2) { | ||
return c2.createdAt.getTime() - c1.createdAt.getTime(); | ||
}); | ||
}; | ||
/** Create a new comment for this resource */ | ||
@@ -20,0 +28,0 @@ ResourceCommentManager.prototype.create = function (data) { |
@@ -20,3 +20,4 @@ import { Collection } from "@discordjs/collection"; | ||
/** Edit an existing resource */ | ||
edit(ressource: Resource): Promise<Resource>; | ||
edit(resource: Resource): Promise<Resource>; | ||
private refreshCategoryManager; | ||
} |
@@ -42,3 +42,3 @@ import { __awaiter, __extends, __generator } from "tslib"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var data, ressource; | ||
var data, resource; | ||
return __generator(this, function (_a) { | ||
@@ -50,5 +50,5 @@ switch (_a.label) { | ||
if (data) { | ||
ressource = new Resource(this.client, data); | ||
this.cache.set(ressource.id, ressource); | ||
return [2 /*return*/, ressource]; | ||
resource = new Resource(this.client, data); | ||
this.cache.set(resource.id, resource); | ||
return [2 /*return*/, resource]; | ||
} | ||
@@ -63,3 +63,3 @@ return [2 /*return*/, null]; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var data, ressourceData, ressource; | ||
var data, ressourceData, resource; | ||
return __generator(this, function (_a) { | ||
@@ -72,5 +72,6 @@ switch (_a.label) { | ||
ressourceData = _a.sent(); | ||
ressource = new Resource(this.client, ressourceData); | ||
this.cache.set(ressource.id, ressource); | ||
return [2 /*return*/, ressource]; | ||
resource = new Resource(this.client, ressourceData); | ||
this.cache.set(resource.id, resource); | ||
this.refreshCategoryManager(resource); | ||
return [2 /*return*/, resource]; | ||
} | ||
@@ -81,15 +82,16 @@ }); | ||
/** Edit an existing resource */ | ||
ResourceManager.prototype.edit = function (ressource) { | ||
ResourceManager.prototype.edit = function (resource) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var data, ressourceData, editRessource; | ||
var data, resourceData, editResource; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
data = ressource.toJSON(); | ||
return [4 /*yield*/, this.client.rest.putRequest("/resources/".concat(ressource.id), data)]; | ||
data = resource.toJSON(); | ||
return [4 /*yield*/, this.client.rest.putRequest("/resources/".concat(resource.id), data)]; | ||
case 1: | ||
ressourceData = _a.sent(); | ||
editRessource = new Resource(this.client, ressourceData); | ||
this.cache.set(editRessource.id, editRessource); | ||
return [2 /*return*/, editRessource]; | ||
resourceData = _a.sent(); | ||
editResource = new Resource(this.client, resourceData); | ||
this.cache.set(editResource.id, editResource); | ||
this.refreshCategoryManager(editResource); | ||
return [2 /*return*/, editResource]; | ||
} | ||
@@ -99,2 +101,7 @@ }); | ||
}; | ||
ResourceManager.prototype.refreshCategoryManager = function (resource) { | ||
resource.categories.cache.forEach(function (c) { | ||
return c.client.resources.cache.set(resource.id, resource); | ||
}); | ||
}; | ||
return ResourceManager; | ||
@@ -101,0 +108,0 @@ }(BaseManager)); |
{ | ||
"name": "rr-apilib", | ||
"version": "0.5.0-alpha", | ||
"version": "0.5.2-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
169913
2424