Skip to content

Commit

Permalink
update Synapse backend artifact, and use AuthenticationController.cle…
Browse files Browse the repository at this point in the history
…arLocalCache when it needs to be cleared
  • Loading branch information
jay-hodgson committed May 16, 2024
1 parent eb116f6 commit 770e802
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<webappDirectory>
${project.build.directory}/${project.build.finalName}
</webappDirectory>
<synapse.version>493.0</synapse.version>
<synapse.version>499.0</synapse.version>
<gwtVersion>2.11.0</gwtVersion>
<org.springframework.version>5.3.33</org.springframework.version>
<guiceVersion>3.0</guiceVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@

import com.google.inject.Inject;
import org.sagebionetworks.web.client.cache.ClientCache;
import org.sagebionetworks.web.client.security.AuthenticationController;

public class WebStorageMaxSizeDetector {

public static final double MAX_SIZE = 4 * ClientProperties.MB; // cleared when approaching ~5MB limit that most browsers implement
public static final int INTERVAL_MS = 1000 * 60 * 5; // check every 5 minutes
ClientCache clientCache;
GWTWrapper gwt;
AuthenticationController authController;

@Inject
public WebStorageMaxSizeDetector(GWTWrapper gwt, ClientCache clientCache) {
public WebStorageMaxSizeDetector(
GWTWrapper gwt,
ClientCache clientCache,
AuthenticationController authController
) {
this.gwt = gwt;
this.clientCache = clientCache;
this.authController = authController;
}

public void start() {
Expand All @@ -40,7 +47,7 @@ private void checkMaxSizeNow() {
);
if (currentSize > MAX_SIZE) {
SynapseJSNIUtilsImpl._consoleLog("Clearing web storage due to the size");
clientCache.clear();
authController.clearLocalStorage();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ void initializeFromExistingAccessTokenCookie(

void checkForUserChange();
void checkForUserChange(Callback cb);
void clearLocalStorage();
}

0 comments on commit 770e802

Please sign in to comment.