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/components/CloudSyncTab.jsx b/frontend/src/components/CloudSyncTab.jsx index 88df2610..75011dbf 100644 --- a/frontend/src/components/CloudSyncTab.jsx +++ b/frontend/src/components/CloudSyncTab.jsx @@ -49,7 +49,7 @@ const CloudSyncTab = (props) => { const itemColor = "white"; const isCloud = window?.location?.host === "localhost:3002" || window?.location?.host === "shuffler.io"; - const { themeMode, brandColor } = useContext(Context); + const { themeMode, brandColor, setUpdateOrg } = useContext(Context); const theme = getTheme(themeMode, brandColor); useEffect(() => { getSettings(); }, []); @@ -457,6 +457,8 @@ const CloudSyncTab = (props) => { setLoading(false); if (response.status === 200) { console.log("Cloud sync success?"); + handleGetOrg(userdata.active_org.id); + setUpdateOrg(true); } else { console.log("Cloud sync fail?"); } diff --git a/frontend/src/components/LeftSideBar.jsx b/frontend/src/components/LeftSideBar.jsx index ab256f75..cacef366 100644 --- a/frontend/src/components/LeftSideBar.jsx +++ b/frontend/src/components/LeftSideBar.jsx @@ -64,7 +64,7 @@ const ExpandMoreAndLessIcon = "/icons/expandMoreIcon.svg"; const LeftSideBar = ({ userdata, serverside, globalUrl, notifications, }) => { const navigate = useNavigate(); - const {setLeftSideBarOpenByClick, leftSideBarOpenByClick, setSearchBarModalOpen, searchBarModalOpen, logoutUrl, themeMode, handleThemeChange, isDocSearchModalOpen, setIsDocSearchModalOpen, supportEmail} = useContext(Context); + const {setLeftSideBarOpenByClick, leftSideBarOpenByClick, updateOrg, setUpdateOrg, setSearchBarModalOpen, searchBarModalOpen, logoutUrl, themeMode, handleThemeChange, isDocSearchModalOpen, setIsDocSearchModalOpen, supportEmail} = useContext(Context); const [expandLeftNav, setExpandLeftNav] = useState(false); const [activeOrgName, setActiveOrgName] = useState( userdata?.active_org?.name || "Select Organziation" @@ -956,6 +956,7 @@ const LeftSideBar = ({ userdata, serverside, globalUrl, notifications, }) => { .then((org) => { if (!fetched && org) { setActiveOrgData(org); + setUpdateOrg(false); if (!isCloud) { if (org?.cloud_sync && org?.subscriptions[0]?.name?.toLowerCase().includes("enterprise") && org?.subscriptions[0]?.active) { setIsProdStatusOn(true); @@ -972,7 +973,7 @@ const LeftSideBar = ({ userdata, serverside, globalUrl, notifications, }) => { return () => { fetched = true; }; - }, [userdata?.active_org?.id, globalUrl]); + }, [userdata?.active_org?.id, globalUrl, updateOrg]); return (