pxt-core 7.4.8 → 7.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/built/pxt.js CHANGED
@@ -97871,7 +97871,8 @@ var pxt;
97871
97871
  highContrast: false,
97872
97872
  language: pxt.appTarget.appTheme.defaultLocale,
97873
97873
  reader: "",
97874
- skillmap: { mapProgress: {}, completedTags: {} }
97874
+ skillmap: { mapProgress: {}, completedTags: {} },
97875
+ email: false
97875
97876
  });
97876
97877
  let _client;
97877
97878
  function client() { return _client; }
@@ -98077,15 +98078,15 @@ var pxt;
98077
98078
  async patchUserPreferencesAsync(ops, immediate = false) {
98078
98079
  ops = Array.isArray(ops) ? ops : [ops];
98079
98080
  ops = ops.filter(op => !!op);
98081
+ const curPref = await this.userPreferencesAsync();
98080
98082
  if (!ops.length) {
98081
- return;
98083
+ return { success: true, res: curPref };
98082
98084
  }
98083
- const curPref = await this.userPreferencesAsync();
98084
98085
  ts.pxtc.jsonPatch.patchInPlace(curPref, ops);
98085
98086
  await this.setUserPreferencesAsync(curPref);
98086
98087
  // If we're not logged in, non-persistent local state is all we'll use
98087
98088
  if (!await this.loggedInAsync()) {
98088
- return;
98089
+ return { success: true, res: curPref };
98089
98090
  }
98090
98091
  // If the user is logged in, save to cloud, but debounce the api call as this can be called frequently from skillmaps
98091
98092
  // Replace matching patches in the queue
@@ -98117,19 +98118,21 @@ var pxt;
98117
98118
  else {
98118
98119
  pxt.reportError("identity", "update preferences failed", result);
98119
98120
  }
98121
+ return { success: result.success, res: result.resp };
98120
98122
  };
98121
98123
  if (immediate) {
98122
- await savePrefs();
98124
+ return await savePrefs();
98123
98125
  }
98124
98126
  else {
98125
98127
  if (!debouncePreferencesChangedStarted) {
98126
98128
  debouncePreferencesChangedStarted = pxt.U.now();
98127
98129
  }
98128
98130
  if (PREFERENCES_DEBOUNCE_MAX_MS < pxt.U.now() - debouncePreferencesChangedStarted) {
98129
- await savePrefs();
98131
+ return await savePrefs();
98130
98132
  }
98131
98133
  else {
98132
98134
  debouncePreferencesChangedTimeout = setTimeout(savePrefs, PREFERENCES_DEBOUNCE_MS);
98135
+ return { success: false, res: undefined }; // This needs to be implemented correctly to return a promise with the debouncer
98133
98136
  }
98134
98137
  }
98135
98138
  }
package/built/pxtlib.d.ts CHANGED
@@ -57,6 +57,10 @@ declare namespace pxt.auth {
57
57
  type UserBadgeState = {
58
58
  badges: Badge[];
59
59
  };
60
+ type SetPrefResult = {
61
+ success: boolean;
62
+ res: UserPreferences;
63
+ };
60
64
  /**
61
65
  * User preference state that should be synced with the cloud.
62
66
  */
@@ -66,6 +70,7 @@ declare namespace pxt.auth {
66
70
  reader?: string;
67
71
  skillmap?: UserSkillmapState;
68
72
  badges?: UserBadgeState;
73
+ email?: boolean;
69
74
  };
70
75
  const DEFAULT_USER_PREFERENCES: () => UserPreferences;
71
76
  /**
@@ -125,7 +130,7 @@ declare namespace pxt.auth {
125
130
  avatarUrl?: string;
126
131
  }): Promise<boolean>;
127
132
  private prefPatchOps;
128
- patchUserPreferencesAsync(ops: ts.pxtc.jsonPatch.PatchOperation | ts.pxtc.jsonPatch.PatchOperation[], immediate?: boolean): Promise<void>;
133
+ patchUserPreferencesAsync(ops: ts.pxtc.jsonPatch.PatchOperation | ts.pxtc.jsonPatch.PatchOperation[], immediate?: boolean): Promise<SetPrefResult>;
129
134
  hasUserId(): boolean;
130
135
  private fetchUserAsync;
131
136
  private setUserProfileAsync;
package/built/pxtlib.js CHANGED
@@ -185,7 +185,8 @@ var pxt;
185
185
  highContrast: false,
186
186
  language: pxt.appTarget.appTheme.defaultLocale,
187
187
  reader: "",
188
- skillmap: { mapProgress: {}, completedTags: {} }
188
+ skillmap: { mapProgress: {}, completedTags: {} },
189
+ email: false
189
190
  });
190
191
  let _client;
191
192
  function client() { return _client; }
@@ -391,15 +392,15 @@ var pxt;
391
392
  async patchUserPreferencesAsync(ops, immediate = false) {
392
393
  ops = Array.isArray(ops) ? ops : [ops];
393
394
  ops = ops.filter(op => !!op);
395
+ const curPref = await this.userPreferencesAsync();
394
396
  if (!ops.length) {
395
- return;
397
+ return { success: true, res: curPref };
396
398
  }
397
- const curPref = await this.userPreferencesAsync();
398
399
  ts.pxtc.jsonPatch.patchInPlace(curPref, ops);
399
400
  await this.setUserPreferencesAsync(curPref);
400
401
  // If we're not logged in, non-persistent local state is all we'll use
401
402
  if (!await this.loggedInAsync()) {
402
- return;
403
+ return { success: true, res: curPref };
403
404
  }
404
405
  // If the user is logged in, save to cloud, but debounce the api call as this can be called frequently from skillmaps
405
406
  // Replace matching patches in the queue
@@ -431,19 +432,21 @@ var pxt;
431
432
  else {
432
433
  pxt.reportError("identity", "update preferences failed", result);
433
434
  }
435
+ return { success: result.success, res: result.resp };
434
436
  };
435
437
  if (immediate) {
436
- await savePrefs();
438
+ return await savePrefs();
437
439
  }
438
440
  else {
439
441
  if (!debouncePreferencesChangedStarted) {
440
442
  debouncePreferencesChangedStarted = pxt.U.now();
441
443
  }
442
444
  if (PREFERENCES_DEBOUNCE_MAX_MS < pxt.U.now() - debouncePreferencesChangedStarted) {
443
- await savePrefs();
445
+ return await savePrefs();
444
446
  }
445
447
  else {
446
448
  debouncePreferencesChangedTimeout = setTimeout(savePrefs, PREFERENCES_DEBOUNCE_MS);
449
+ return { success: false, res: undefined }; // This needs to be implemented correctly to return a promise with the debouncer
447
450
  }
448
451
  }
449
452
  }