Remove all data stores! Move to maps

This commit is contained in:
Amish Shah
2016-08-19 22:34:59 +01:00
parent 82ab92ca2a
commit 8d5d90e222
17 changed files with 81 additions and 111 deletions

View File

@@ -16,10 +16,10 @@ class APIRequest {
}
getAuth() {
if (this.rest.client.store.token && this.rest.client.store.user && this.rest.client.store.user.bot) {
return `Bot ${this.rest.client.store.token}`;
} else if (this.rest.client.store.token) {
return this.rest.client.store.token;
if (this.rest.client.token && this.rest.client.user && this.rest.client.user.bot) {
return `Bot ${this.rest.client.token}`;
} else if (this.rest.client.token) {
return this.rest.client.token;
}
throw Constants.Errors.NO_TOKEN;
}

View File

@@ -11,8 +11,8 @@ class RESTMethods {
loginEmailPassword(email, password) {
return new Promise((resolve, reject) => {
this.rest.client.store.email = email;
this.rest.client.store.password = password;
this.rest.client.email = email;
this.rest.client.password = password;
this.rest.makeRequest('post', Constants.Endpoints.login, false, { email, password })
.then(data => {
this.rest.client.manager.connectToWebSocket(data.token, resolve, reject);
@@ -31,8 +31,8 @@ class RESTMethods {
return new Promise((resolve, reject) => {
this.rest.makeRequest('get', Constants.Endpoints.gateway, true)
.then(res => {
this.rest.client.store.gateway = `${res.url}/?encoding=json&v=${this.rest.client.options.protocol_version}`;
resolve(this.rest.client.store.gateway);
this.rest.client.ws.gateway = `${res.url}/?encoding=json&v=${this.rest.client.options.protocol_version}`;
resolve(this.rest.client.ws.gateway);
})
.catch(reject);
});
@@ -117,7 +117,7 @@ class RESTMethods {
return resolve(dmChannel);
}
return this.rest.makeRequest('post', Constants.Endpoints.userChannels(this.rest.client.store.user.id), true, {
return this.rest.makeRequest('post', Constants.Endpoints.userChannels(this.rest.client.user.id), true, {
recipient_id: recipient.id,
})
.then(data => resolve(this.rest.client.actions.ChannelCreate.handle(data).channel))
@@ -181,14 +181,14 @@ class RESTMethods {
updateCurrentUser(_data) {
return new Promise((resolve, reject) => {
const user = this.rest.client.store.user;
const user = this.rest.client.user;
const data = {};
data.username = _data.username || user.username;
data.avatar = this.rest.client.resolver.resolveBase64(_data.avatar) || user.avatar;
if (!user.bot) {
data.password = this.rest.client.store.password;
data.email = _data.email || this.rest.client.store.email;
data.password = this.rest.client.password;
data.email = _data.email || this.rest.client.email;
data.new_password = _data.newPassword;
}