Comparing version 0.8.1-alpha to 0.8.2-alpha
@@ -104,3 +104,6 @@ import { __awaiter, __extends, __generator } from "tslib"; | ||
_b.label = 7; | ||
case 7: return [2 /*return*/, this._add(finalResourceData)]; | ||
case 7: return [4 /*yield*/, this.client.validations.fetch(finalResourceData.validationStates[0].id)]; | ||
case 8: | ||
_b.sent(); | ||
return [2 /*return*/, this._add(finalResourceData)]; | ||
} | ||
@@ -121,2 +124,5 @@ }); | ||
resourceData = _a.sent(); | ||
return [4 /*yield*/, this.client.validations.fetchAll()]; | ||
case 2: | ||
_a.sent(); | ||
return [2 /*return*/, this._add(resourceData)]; | ||
@@ -123,0 +129,0 @@ } |
import { Collection } from "@discordjs/collection"; | ||
import Client from "../client/Client"; | ||
import BaseManager from "./BaseManager"; | ||
import { APIValidationStateData } from "../@types"; | ||
import ValidationState from "../class/ValidationState"; | ||
@@ -12,2 +13,4 @@ import ValidationStateBuilder from "../builders/ValidationStateBuilder"; | ||
constructor(client: Client); | ||
_add(data: APIValidationStateData): ValidationState; | ||
_remove(id: string): void; | ||
/** Fetch all existing validations state from the api */ | ||
@@ -14,0 +17,0 @@ fetchAll(): Promise<Collection<string, ValidationState>>; |
@@ -14,6 +14,19 @@ import { __awaiter, __extends, __generator } from "tslib"; | ||
} | ||
ValidationStateManager.prototype._add = function (data) { | ||
var existing = this.cache.get(data.id); | ||
if (existing) { | ||
existing._patch(data); | ||
return existing; | ||
} | ||
var validation = new ValidationState(this.client, data); | ||
this.cache.set(validation.id, validation); | ||
return validation; | ||
}; | ||
ValidationStateManager.prototype._remove = function (id) { | ||
this.cache.delete(id); | ||
}; | ||
/** Fetch all existing validations state from the api */ | ||
ValidationStateManager.prototype.fetchAll = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var data, _i, data_1, v, validation; | ||
var data, _i, data_1, v; | ||
return __generator(this, function (_a) { | ||
@@ -26,4 +39,3 @@ switch (_a.label) { | ||
v = data_1[_i]; | ||
validation = new ValidationState(this.client, v); | ||
this.cache.set(validation.id, validation); | ||
this._add(v); | ||
} | ||
@@ -38,3 +50,3 @@ return [2 /*return*/, this.cache]; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var data, vs; | ||
var data; | ||
return __generator(this, function (_a) { | ||
@@ -46,5 +58,3 @@ switch (_a.label) { | ||
if (data) { | ||
vs = new ValidationState(this.client, data); | ||
this.cache.set(vs.id, vs); | ||
return [2 /*return*/, vs]; | ||
return [2 /*return*/, this._add(data)]; | ||
} | ||
@@ -59,3 +69,3 @@ return [2 /*return*/, null]; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var json, data, vs; | ||
var json, data; | ||
return __generator(this, function (_a) { | ||
@@ -68,5 +78,3 @@ switch (_a.label) { | ||
data = _a.sent(); | ||
vs = new ValidationState(this.client, data); | ||
this.cache.set(vs.id, vs); | ||
return [2 /*return*/, vs]; | ||
return [2 /*return*/, this._add(data)]; | ||
} | ||
@@ -79,3 +87,3 @@ }); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var json, data, vs; | ||
var json, data; | ||
return __generator(this, function (_a) { | ||
@@ -88,5 +96,3 @@ switch (_a.label) { | ||
data = _a.sent(); | ||
vs = new ValidationState(this.client, data); | ||
this.cache.set(vs.id, vs); | ||
return [2 /*return*/, vs]; | ||
return [2 /*return*/, this._add(data)]; | ||
} | ||
@@ -93,0 +99,0 @@ }); |
{ | ||
"name": "rr-apilib", | ||
"version": "0.8.1-alpha", | ||
"version": "0.8.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
186149
2735
3