notherbase-fs 3.1.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,6 +16,7 @@ export default class User {
16
16
  this.router.post("/deletePermanently", this.deletePermanently);
17
17
  this.router.post("/getInventory", this.getInventory);
18
18
  this.router.post("/getAttributes", this.getAttributes);
19
+ this.router.post("/getInfo", this.getInfo);
19
20
  }
20
21
 
21
22
  logout = async (req, res) => {
@@ -160,4 +161,18 @@ export default class User {
160
161
  else fail(res, "Attributes up to date.");
161
162
  }
162
163
  }
164
+
165
+ getInfo = async (req, res) => {
166
+ if (loginCheck(req, res)) {
167
+ let user = await req.db.User.recallOne(req.session.currentUser);
168
+
169
+ if (user.memory._lastUpdate > req.body._lastUpdate) {
170
+ success(res, "Info found", {
171
+ email: user.memory.data.email,
172
+ username: user.memory.data.username
173
+ });
174
+ }
175
+ else fail(res, "Info up to date.");
176
+ }
177
+ }
163
178
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notherbase-fs",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "Functions to help make developing for NotherBase easier.",
5
5
  "exports": "./notherbase-fs.js",
6
6
  "scripts": {
@@ -10,6 +10,8 @@
10
10
  const currentRoute = "<%- route %>";
11
11
 
12
12
  <%- include("./scripts/base.js", {user: user}); %>
13
+
14
+ const base = new Base();
13
15
  </script>
14
16
 
15
17
 
@@ -12,9 +12,7 @@ class Base {
12
12
  this.items = [];
13
13
  this.lastUpdate = 0;
14
14
 
15
- <% if (user) { %>
16
- this.refresh();
17
- <% } %>
15
+ this.refresh();
18
16
  }
19
17
 
20
18
  async refresh() {
@@ -63,9 +61,7 @@ class Base {
63
61
  this.attributes = [];
64
62
  this.lastUpdate = 0;
65
63
 
66
- <% if (user) { %>
67
- this.refresh();
68
- <% } %>
64
+ this.refresh();
69
65
  }
70
66
 
71
67
  async refresh() {
@@ -95,16 +91,19 @@ class Base {
95
91
  constructor() {
96
92
  this.username = "";
97
93
  this.email = "";
94
+ this.lastUpdate = 0;
98
95
 
99
- <% if (user) { %>
100
- this.username = "<%= user.username %>";
101
- this.email = "<%= user.email %>";
102
-
103
- this.refresh();
104
- <% } %>
96
+ this.refresh();
105
97
  }
106
98
 
107
- refresh() {
99
+ async refresh() {
100
+ let response = await Base.commune("getInfo", { _lastUpdate: this.lastUpdate });
101
+ if (response.status === "success") {
102
+ this.lastUpdate = response.lastUpdate;
103
+ this.email = response.data.email;
104
+ this.username = response.data.username;
105
+ }
106
+
108
107
  let $email = $(".content#account .setting#email p");
109
108
  let $emailInput = $(".content#account .edit#email input");
110
109
  let $username = $(".content#account .setting#username p");
@@ -146,6 +145,7 @@ class Base {
146
145
  let response = await Base.commune("changeEmail", { email: $emailInput.val() });
147
146
 
148
147
  if (response.status === "success") {
148
+ this.email = $emailInput.val();
149
149
  $email.text($emailInput.val());
150
150
  $info.text("Email Updated.");
151
151
  }
@@ -182,6 +182,7 @@ class Base {
182
182
  let response = await Base.commune("changeUsername", { username: $usernameInput.val() });
183
183
 
184
184
  if (response.status === "success") {
185
+ this.username = $usernameInput.val();
185
186
  $username.text($usernameInput.val());
186
187
  $info.text("Username Updated.");
187
188
  }
@@ -197,6 +198,8 @@ class Base {
197
198
  this.playerAttributes = new this.#PlayerAttributes();
198
199
  this.playerAccount = new this.#AccountServices();
199
200
  this.menuClosing = false;
201
+
202
+ this.switchTab("inventory");
200
203
  }
201
204
 
202
205
  closeMenu = () => {
@@ -294,8 +297,4 @@ class Base {
294
297
 
295
298
  return response;
296
299
  }
297
- }
298
-
299
- const base = new Base();
300
-
301
- base.switchTab("inventory");
300
+ }