Skip to content

Commit da4ca03

Browse files
committed
clear cache. kinda bad fix but whatever.
1 parent df17091 commit da4ca03

6 files changed

Lines changed: 200 additions & 88 deletions

File tree

src/lib/AccountStatus/Standing.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112

113113
{#if detail >= 4}
114114
<h2>
115-
{#if messagecount > 9}
115+
{#if messagecount >= 9}
116116
<LocalizedText
117117
text="Moderator Messages (9+)"
118118
key="account.settings.standing.messages.toomany"

src/resources/authentication.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,18 @@ class Authentication {
176176
}
177177
});
178178
}
179-
static usernameFromCode(username, token) {
179+
static usernameFromCode(username, token, clear_cache = false) {
180180
// name is a misnomer, was just to lazy to change after new api update.
181181
// TODO: make this less misleading
182182
return new Promise((resolve, reject) => {
183+
const cc = clear_cache
184+
? {
185+
cache: "reload",
186+
}
187+
: {};
183188
fetch(
184189
`${ProjectApi.OriginApiUrl}/api/v1/users/userfromcode?username=${username}&token=${token}`,
190+
cc,
185191
)
186192
.then((r) =>
187193
r
@@ -321,6 +327,14 @@ class Authentication {
321327
.json()
322328
.then((j) => {
323329
if (j.error) return reject(j.error);
330+
331+
// clear userfromcode cache
332+
Authentication.usernameFromCode(
333+
username,
334+
token,
335+
true,
336+
);
337+
324338
resolve(j.token);
325339
})
326340
.catch(reject),

src/resources/projectapi.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
} from "$env/static/public";
66
import pmp_protobuf from "pmp-protobuf";
77
import JSZip from "jszip";
8+
import Authentication from "./authentication";
89

910
let OriginApiUrl = PUBLIC_API_URL;
1011

@@ -1280,6 +1281,14 @@ class ProjectApi {
12801281
reject(json.error);
12811282
return;
12821283
}
1284+
1285+
// clear usernamefromcode cache
1286+
Authentication.usernameFromCode(
1287+
this.username,
1288+
this.token,
1289+
true,
1290+
);
1291+
12831292
resolve();
12841293
})
12851294
.catch((err) => {
@@ -1345,6 +1354,14 @@ class ProjectApi {
13451354
reject(json.error);
13461355
return;
13471356
}
1357+
1358+
// clear cache
1359+
Authentication.usernameFromCode(
1360+
this.username,
1361+
this.token,
1362+
true,
1363+
);
1364+
13481365
resolve();
13491366
})
13501367
.catch((err) => {
@@ -2057,6 +2074,14 @@ class ProjectApi {
20572074
reject(json.error);
20582075
return;
20592076
}
2077+
2078+
// clear cache
2079+
Authentication.usernameFromCode(
2080+
this.username,
2081+
this.token,
2082+
true,
2083+
);
2084+
20602085
resolve();
20612086
})
20622087
.catch((err) => {
@@ -2163,6 +2188,14 @@ class ProjectApi {
21632188
reject(json.error);
21642189
return;
21652190
}
2191+
2192+
// clear cache
2193+
Authentication.usernameFromCode(
2194+
this.username,
2195+
this.token,
2196+
true,
2197+
);
2198+
21662199
resolve();
21672200
})
21682201
.catch((err) => {
@@ -2509,6 +2542,14 @@ class ProjectApi {
25092542
reject(json.error);
25102543
return;
25112544
}
2545+
2546+
// clear cache
2547+
Authentication.usernameFromCode(
2548+
this.username,
2549+
this.token,
2550+
true,
2551+
);
2552+
25122553
resolve();
25132554
})
25142555
.catch((err) => {

src/routes/messages/+page.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,10 @@
225225
markPolicyAsRead("TOS");
226226
markPolicyAsRead("guidelines");
227227
228-
ProjectClient.markAllMessagesAsRead();
228+
ProjectClient.markAllMessagesAsRead().then(() => {
229+
// clear cache
230+
Authentication.usernameFromCode(this.username, this.token, true);
231+
});
229232
230233
readMessages = readMessages.concat(
231234
messages.map((message) => message.id),

src/routes/settings/+page.svelte

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,13 @@
324324
localStorage.setItem("username", username);
325325
localStorage.setItem("token", token);
326326
327+
// clear cache
328+
Authentication.usernameFromCode(
329+
this.username,
330+
this.token,
331+
true,
332+
);
333+
327334
resolve();
328335
});
329336
});
@@ -357,6 +364,13 @@
357364
if (!remove) return;
358365
ProjectClient.removeOAuthMethod(method)
359366
.then(() => {
367+
// clear cache
368+
Authentication.usernameFromCode(
369+
this.username,
370+
this.token,
371+
true,
372+
);
373+
360374
loginMethods = loginMethods.filter((m) => m !== method);
361375
})
362376
.catch(alert);

0 commit comments

Comments
 (0)