()
| 4 | const _ = require('lodash') |
| 5 | |
| 6 | function extraProvisions () { |
| 7 | usersApi.extraProvisions({ userId: me.get('_id') }) |
| 8 | .then(({ provisionType, ...obj }) => { |
| 9 | if (provisionType === 'library') { |
| 10 | const { premiumAdded, isInLibraryNetwork, hideEmail, libraryName, showLoginModal, isCreatedViaLibrary } = obj |
| 11 | handleStorage(libraryNetworkLSKey(), isInLibraryNetwork, 24 * 60) |
| 12 | handleStorage(hideEmailLibraryKey(), hideEmail, 24 * 60) |
| 13 | handleStorage(showLibraryLoginModalKey(), showLoginModal, 60) |
| 14 | handleStorage(isCreatedViaLibraryKey(), isCreatedViaLibrary, 24 * 60) |
| 15 | handleStorage(libraryNameKey(), libraryName, 24 * 60) |
| 16 | |
| 17 | const lib = me.get('library') || {} |
| 18 | if (!lib.name && libraryName) { |
| 19 | lib.name = libraryName |
| 20 | me.set('library', lib) |
| 21 | me.save() |
| 22 | } |
| 23 | if (premiumAdded) me.fetch({ cache: false }) |
| 24 | } else if (provisionType === 'teacher') { |
| 25 | const { esportsAdded } = obj |
| 26 | if (esportsAdded) me.fetch({ cache: false }) |
| 27 | } |
| 28 | }) |
| 29 | .catch((err) => { |
| 30 | console.error('provision err', err) |
| 31 | }) |
| 32 | } |
| 33 | |
| 34 | function handleStorage (key, value, expirationInMinutes) { |
| 35 | if (value) { |
nothing calls this directly
no test coverage detected