diff --git a/backend/go-app/main.go b/backend/go-app/main.go index 78dde288..5f54465a 100755 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -4956,6 +4956,17 @@ func handleCloudSetup(resp http.ResponseWriter, request *http.Request) { resp.Write(b) } else { + + // Delete cache for the sync features + cacheKey := fmt.Sprintf("org_sync_features_%s", org.Id) + shuffle.DeleteCache(ctx, cacheKey) + + subscriptionCacheKey := fmt.Sprintf("org_subscriptions_%s", org.Id) + shuffle.DeleteCache(ctx, subscriptionCacheKey) + + licenseCacheKey := fmt.Sprintf("org_licensed_%s", org.Id) + shuffle.DeleteCache(ctx, licenseCacheKey) + resp.WriteHeader(200) resp.Write([]byte(fmt.Sprintf(`{"success": true, "reason": "Successfully disabled cloud sync for org."}`))) } @@ -5047,6 +5058,23 @@ func handleCloudSetup(resp http.ResponseWriter, request *http.Request) { shuffle.SetCache(ctx, cacheKey, featuresBytes, 1800) } + subscriptionCacheKey := fmt.Sprintf("org_subscriptions_%s", org.Id) + subscriptionsBytes, err := json.Marshal(responseData.Subscriptions) + if err != nil { + log.Printf("[ERROR] Failed to marshal Subscriptions for cache: %s", err) + } else { + shuffle.SetCache(ctx, subscriptionCacheKey, subscriptionsBytes, 1800) + } + + licenseCacheKey := fmt.Sprintf("org_licensed_%s", org.Id) + licensedBytes, err := json.Marshal(responseData.Licensed) + if err != nil { + log.Printf("[ERROR] Failed to marshal Licensed for cache: %s", err) + } else { + + shuffle.SetCache(ctx, licenseCacheKey, licensedBytes, 1800) + } + org.SyncConfig = shuffle.SyncConfig{ Apikey: responseData.SessionKey, Interval: responseData.IntervalSeconds, diff --git a/frontend/src/context/ContextApi.jsx b/frontend/src/context/ContextApi.jsx index d344e3ed..a0ac37e1 100644 --- a/frontend/src/context/ContextApi.jsx +++ b/frontend/src/context/ContextApi.jsx @@ -15,6 +15,7 @@ export const AppContext = (props) => { const [windowWidth, setWindowWidth] = useState(serverside === true ? 100 : window.innerWidth); const [brandColor, setBrandColor] = useState(() => localStorage.getItem("brandColor") || "#ff8544"); const [brandName, setBrandName] = useState(()=> localStorage.getItem("brandName") || "Shuffle"); + const [updateOrg, setUpdateOrg] = useState(false); const [themeMode, setThemeMode] = useState( () => localStorage.getItem("theme") || "dark" @@ -117,6 +118,8 @@ export const AppContext = (props) => { setBrandColor, brandName, setBrandName, + updateOrg, + setUpdateOrg, }}> {props.children}