File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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"
Original file line number Diff line number Diff 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 ) ,
Original file line number Diff line number Diff line change 55} from "$env/static/public" ;
66import pmp_protobuf from "pmp-protobuf" ;
77import JSZip from "jszip" ;
8+ import Authentication from "./authentication" ;
89
910let 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 ) => {
Original file line number Diff line number Diff line change 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 ),
Original file line number Diff line number Diff line change 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 });
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);
You can’t perform that action at this time.
0 commit comments