-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into regression/contextualbar-handler
- Loading branch information
Showing
21 changed files
with
145 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
95 changes: 0 additions & 95 deletions
95
apps/meteor/app/ui-cached-collection/client/models/CachedCollectionManager.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
apps/meteor/client/lib/cachedCollections/CachedCollectionManager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { CachedCollection } from './CachedCollection'; | ||
|
||
class CachedCollectionManager { | ||
private items = new Set<CachedCollection<any>>(); | ||
|
||
register(cachedCollection: CachedCollection<any>) { | ||
this.items.add(cachedCollection); | ||
} | ||
|
||
clearAllCachesOnLogout() { | ||
for (const item of this.items) { | ||
item.clearCacheOnLogout(); | ||
} | ||
} | ||
} | ||
|
||
const instance = new CachedCollectionManager(); | ||
|
||
export { | ||
/** @deprecated */ | ||
instance as CachedCollectionManager, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { CachedCollection } from './CachedCollection'; | ||
export { CachedCollectionManager } from './CachedCollectionManager'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,4 @@ | ||
import { CachedCollectionManager } from '../../app/ui-cached-collection/client'; | ||
import { sdk } from '../../app/utils/client/lib/SDKClient'; | ||
import { whenLoggedIn } from './loggedIn'; | ||
|
||
export const fetchFeatures = (): Promise<string[]> => | ||
new Promise((resolve, reject) => { | ||
CachedCollectionManager.onLogin(() => { | ||
sdk.call('license:getModules').then(resolve, reject); | ||
}); | ||
}); | ||
export const fetchFeatures = (): Promise<string[]> => whenLoggedIn().then(() => sdk.call('license:getModules')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Accounts } from 'meteor/accounts-base'; | ||
import { Meteor } from 'meteor/meteor'; | ||
import { Tracker } from 'meteor/tracker'; | ||
|
||
const isLoggedIn = () => { | ||
const uid = Tracker.nonreactive(() => Meteor.userId()); | ||
return uid !== null; | ||
}; | ||
|
||
export const whenLoggedIn = () => { | ||
if (isLoggedIn()) { | ||
return Promise.resolve(); | ||
} | ||
|
||
return new Promise<void>((resolve) => { | ||
const subscription = Accounts.onLogin(() => { | ||
subscription.stop(); | ||
resolve(); | ||
}); | ||
}); | ||
}; | ||
|
||
export const onLoggedIn = (cb: (() => () => void) | (() => Promise<() => void>) | (() => void)) => { | ||
let cleanup: (() => void) | undefined; | ||
const handler = async () => { | ||
cleanup?.(); | ||
const ret = await cb(); | ||
if (typeof ret === 'function') { | ||
cleanup = ret; | ||
} | ||
}; | ||
|
||
const subscription = Accounts.onLogin(handler); | ||
if (isLoggedIn()) handler(); | ||
|
||
return () => { | ||
subscription.stop(); | ||
cleanup?.(); | ||
}; | ||
}; |
2 changes: 1 addition & 1 deletion
2
apps/meteor/client/lib/settings/PrivateSettingsCachedCollection.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/meteor/client/lib/settings/PublicSettingsCachedCollection.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.