@fiduswriter/frontend 0.1.71 → 0.1.73

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.
Files changed (57) hide show
  1. package/css/login.css +268 -0
  2. package/css/show_profile.css +111 -40
  3. package/dist/app/index.d.ts.map +1 -1
  4. package/dist/app/index.js +1 -0
  5. package/dist/app/index.js.map +1 -1
  6. package/dist/common/templates.d.ts.map +1 -1
  7. package/dist/common/templates.js +1 -0
  8. package/dist/common/templates.js.map +1 -1
  9. package/dist/common/user_util.d.ts +8 -1
  10. package/dist/common/user_util.d.ts.map +1 -1
  11. package/dist/common/user_util.js +24 -0
  12. package/dist/common/user_util.js.map +1 -1
  13. package/dist/css/fwtoolkit/data_table.css +31 -6
  14. package/dist/css/fwtoolkit/dialog.css +51 -0
  15. package/dist/css/fwtoolkit/fwtoolkit.css +157 -26
  16. package/dist/css/fwtoolkit/inline_tools.css +5 -8
  17. package/dist/css/fwtoolkit/overview_menu.css +70 -12
  18. package/dist/css/login.css +268 -0
  19. package/dist/css/manifest.json +1 -0
  20. package/dist/css/show_profile.css +111 -40
  21. package/dist/feedback/index.d.ts.map +1 -1
  22. package/dist/feedback/index.js +6 -1
  23. package/dist/feedback/index.js.map +1 -1
  24. package/dist/menu/index.d.ts.map +1 -1
  25. package/dist/menu/index.js +16 -2
  26. package/dist/menu/index.js.map +1 -1
  27. package/dist/user/auth/login.d.ts +14 -0
  28. package/dist/user/auth/login.d.ts.map +1 -1
  29. package/dist/user/auth/login.js +253 -131
  30. package/dist/user/auth/login.js.map +1 -1
  31. package/dist/user/profile/dialog.d.ts +72 -0
  32. package/dist/user/profile/dialog.d.ts.map +1 -0
  33. package/dist/user/profile/dialog.js +436 -0
  34. package/dist/user/profile/dialog.js.map +1 -0
  35. package/dist/user/profile/dialogs.d.ts +6 -6
  36. package/dist/user/profile/dialogs.d.ts.map +1 -1
  37. package/dist/user/profile/dialogs.js +29 -14
  38. package/dist/user/profile/dialogs.js.map +1 -1
  39. package/dist/user/profile/index.d.ts +12 -14
  40. package/dist/user/profile/index.d.ts.map +1 -1
  41. package/dist/user/profile/index.js +35 -236
  42. package/dist/user/profile/index.js.map +1 -1
  43. package/dist/user/profile/templates.d.ts +14 -1
  44. package/dist/user/profile/templates.d.ts.map +1 -1
  45. package/dist/user/profile/templates.js +178 -191
  46. package/dist/user/profile/templates.js.map +1 -1
  47. package/package.json +3 -2
  48. package/src/app/index.ts +1 -0
  49. package/src/common/templates.ts +1 -0
  50. package/src/common/user_util.ts +26 -1
  51. package/src/feedback/index.ts +8 -1
  52. package/src/menu/index.ts +19 -2
  53. package/src/user/auth/login.ts +338 -153
  54. package/src/user/profile/dialog.ts +609 -0
  55. package/src/user/profile/dialogs.ts +51 -14
  56. package/src/user/profile/index.ts +37 -334
  57. package/src/user/profile/templates.ts +222 -223
@@ -9,7 +9,22 @@ import {
9
9
  deleteEmailDialogTemplate
10
10
  } from "./templates.js"
11
11
 
12
- export const changeAvatarDialog = (app: FrontendApp): void => {
12
+ /**
13
+ * Sub-dialogs of the profile dialog.
14
+ *
15
+ * `refresh` redraws the profile UI after a successful change. When the dialog
16
+ * is hosted by a {@link ProfileDialog} it passes its own in-place re-render so
17
+ * the dialog (and the active tab) survives; hosts without a profile dialog fall
18
+ * back to re-selecting the current page.
19
+ */
20
+ const pageRefresh = (app: FrontendApp, refresh?: () => void): (() => void) =>
21
+ refresh || (() => app.selectPage())
22
+
23
+ export const changeAvatarDialog = (
24
+ app: FrontendApp,
25
+ refresh?: () => void
26
+ ): void => {
27
+ const redraw = pageRefresh(app, refresh)
13
28
  const buttons = [
14
29
  {
15
30
  text: gettext("Upload"),
@@ -31,7 +46,7 @@ export const changeAvatarDialog = (app: FrontendApp): void => {
31
46
  })
32
47
  .then(() => deactivateWait())
33
48
  .then(() => app.getConfiguration())
34
- .then(() => app.selectPage())
49
+ .then(() => redraw())
35
50
  .catch(() => {
36
51
  deactivateWait()
37
52
  addAlert("error", gettext("Could not update profile avatar"))
@@ -71,26 +86,30 @@ export const changeAvatarDialog = (app: FrontendApp): void => {
71
86
  }
72
87
  }
73
88
 
74
- const deleteAvatar = (app: FrontendApp): void => {
89
+ const deleteAvatar = (app: FrontendApp, refresh?: () => void): void => {
90
+ const redraw = pageRefresh(app, refresh)
75
91
  activateWait()
76
92
 
77
93
  app.apiConnectors.userProfile.avatarDelete()
78
94
  .then(() => deactivateWait())
79
95
  .then(() => app.getConfiguration())
80
- .then(() => app.selectPage())
96
+ .then(() => redraw())
81
97
  .catch(() => {
82
98
  deactivateWait()
83
99
  addAlert("error", gettext("Could not delete avatar"))
84
100
  })
85
101
  }
86
102
 
87
- export const deleteAvatarDialog = (app: FrontendApp): void => {
103
+ export const deleteAvatarDialog = (
104
+ app: FrontendApp,
105
+ refresh?: () => void
106
+ ): void => {
88
107
  const buttons = [
89
108
  {
90
109
  text: gettext("Delete"),
91
110
  classes: "fw-dark",
92
111
  click: () => {
93
- deleteAvatar(app)
112
+ deleteAvatar(app, refresh)
94
113
  dialog.close()
95
114
  }
96
115
  },
@@ -172,7 +191,11 @@ export const changePwdDialog = ({username, app}: {username: string; app: Fronten
172
191
  dialog.open()
173
192
  }
174
193
 
175
- export const addEmailDialog = (app: FrontendApp): void => {
194
+ export const addEmailDialog = (
195
+ app: FrontendApp,
196
+ refresh?: () => void
197
+ ): void => {
198
+ const redraw = pageRefresh(app, refresh)
176
199
  const buttons = [
177
200
  {
178
201
  text: gettext("Submit"),
@@ -198,7 +221,7 @@ export const addEmailDialog = (app: FrontendApp): void => {
198
221
  dialog.close()
199
222
  return app
200
223
  .getConfiguration()
201
- .then(() => app.selectPage())
224
+ .then(() => redraw())
202
225
  .then(() =>
203
226
  addAlert(
204
227
  "info",
@@ -228,8 +251,13 @@ export const addEmailDialog = (app: FrontendApp): void => {
228
251
  dialog.open()
229
252
  }
230
253
 
231
- export const deleteEmailDialog = (target: HTMLElement, app: FrontendApp): void => {
254
+ export const deleteEmailDialog = (
255
+ target: HTMLElement,
256
+ app: FrontendApp,
257
+ refresh?: () => void
258
+ ): void => {
232
259
  const email = target.dataset.email
260
+ const redraw = pageRefresh(app, refresh)
233
261
 
234
262
  const buttons = [
235
263
  {
@@ -244,7 +272,7 @@ export const deleteEmailDialog = (target: HTMLElement, app: FrontendApp): void =
244
272
  deactivateWait()
245
273
  })
246
274
  .then(() => app.getConfiguration())
247
- .then(() => app.selectPage())
275
+ .then(() => redraw())
248
276
  .then(() =>
249
277
  addAlert("info", gettext("Email successfully deleted!"))
250
278
  )
@@ -269,9 +297,14 @@ export const deleteEmailDialog = (target: HTMLElement, app: FrontendApp): void =
269
297
  dialog.open()
270
298
  }
271
299
 
272
- export const deleteSocialaccountDialog = (target: HTMLElement, app: FrontendApp): void => {
300
+ export const deleteSocialaccountDialog = (
301
+ target: HTMLElement,
302
+ app: FrontendApp,
303
+ refresh?: () => void
304
+ ): void => {
273
305
  const socialaccount = Number.parseInt(target.dataset.socialaccount!)
274
306
  const provider = target.dataset.provider
307
+ const redraw = pageRefresh(app, refresh)
275
308
 
276
309
  const buttons = [
277
310
  {
@@ -286,7 +319,7 @@ export const deleteSocialaccountDialog = (target: HTMLElement, app: FrontendApp)
286
319
  deactivateWait()
287
320
  })
288
321
  .then(() => app.getConfiguration())
289
- .then(() => app.selectPage())
322
+ .then(() => redraw())
290
323
  .then(() =>
291
324
  addAlert(
292
325
  "info",
@@ -314,11 +347,15 @@ export const deleteSocialaccountDialog = (target: HTMLElement, app: FrontendApp)
314
347
  dialog.open()
315
348
  }
316
349
 
317
- export const changePrimaryEmailDialog = (app: FrontendApp): void => {
350
+ export const changePrimaryEmailDialog = (
351
+ app: FrontendApp,
352
+ refresh?: () => void
353
+ ): void => {
318
354
  const primEmailRadio = document.querySelector(
319
355
  ".primary-email-radio:checked"
320
356
  ) as HTMLInputElement
321
357
  const email = primEmailRadio.value
358
+ const redraw = pageRefresh(app, refresh)
322
359
  const buttons = [
323
360
  {
324
361
  text: gettext("Submit"),
@@ -332,7 +369,7 @@ export const changePrimaryEmailDialog = (app: FrontendApp): void => {
332
369
  deactivateWait()
333
370
  return app.getConfiguration()
334
371
  })
335
- .then(() => app.selectPage())
372
+ .then(() => redraw())
336
373
  .then(() =>
337
374
  addAlert("info", gettext("The primary email has been updated."))
338
375
  )
@@ -1,41 +1,31 @@
1
1
  import {baseBodyTemplate} from "../../common/index.js"
2
2
  import {FeedbackTab} from "../../feedback/index.js"
3
3
  import {SiteMenu} from "../../menu/index.js"
4
- import {
5
- activateWait,
6
- addAlert,
7
- deactivateWait,
8
- dropdownSelect,
9
- ensureCSS,
10
- findTarget,
11
- setDocTitle,
12
- whenReady
13
- } from "fwtoolkit"
14
- import {DeleteUserDialog} from "./delete_user.js"
15
- import {
16
- addEmailDialog,
17
- changeAvatarDialog,
18
- changePrimaryEmailDialog,
19
- changePwdDialog,
20
- deleteAvatarDialog,
21
- deleteEmailDialog,
22
- deleteSocialaccountDialog
23
- } from "./dialogs.js"
24
- import {profileContents} from "./templates.js"
25
- import type {FrontendApp, User} from "../../types.js"
4
+ import {ensureCSS, setDocTitle, whenReady} from "fwtoolkit"
26
5
 
6
+ import {ProfileDialog} from "./dialog.js"
7
+ import type {FrontendApp, User} from "../../types.js"
27
8
  import type {PluginList} from "../../app/index.js"
28
9
 
10
+ // Re-export the dialog so hosts can open "Configure profile" over any page
11
+ // without going through the dedicated host route.
12
+ export {ProfileDialog, type ProfileDialogOptions} from "./dialog.js"
13
+
14
+ /**
15
+ * Thin host page for the profile dialog.
16
+ *
17
+ * Design 5 moved profile configuration into a dialog. The `/user/profile/`
18
+ * route is kept working (bookmarks, deep links, e-mail verification flows) by
19
+ * rendering the standard page chrome and immediately opening the
20
+ * {@link ProfileDialog} over it. When the dialog is closed on this route we
21
+ * return to the documents overview.
22
+ */
29
23
  export class Profile {
30
24
  app: FrontendApp
31
25
  user: User & {id?: number}
32
26
  socialaccount_providers: Array<Record<string, unknown>>
33
- pluginTemplates: string[]
34
- clickTargets: Record<string, (el: Record<string, any>, event: Event) => void>
35
- postRenderHandlers: Array<() => void>
36
- plugins: Record<string, {init(): void}> | null
37
- dom!: HTMLElement
38
27
  profilePlugins: PluginList
28
+ dialog: ProfileDialog
39
29
 
40
30
  constructor({
41
31
  app,
@@ -52,144 +42,37 @@ export class Profile {
52
42
  this.user = user
53
43
  this.socialaccount_providers = socialaccount_providers
54
44
  this.profilePlugins = profilePlugins
55
- this.pluginTemplates = []
56
- this.plugins = null
57
- this.clickTargets = {
58
- "#add-profile-email": (_el, _event) => addEmailDialog(this.app),
59
- "#fw-edit-profile-pwd": (_el, _event) =>
60
- changePwdDialog({username: this.user.username, app: this.app}),
61
- "#delete-account": (_el, _event) => {
62
- const dialog = new DeleteUserDialog(
63
- (this.dom.querySelector("#delete-account") as HTMLElement).dataset.username!,
64
- this.app
65
- )
66
- dialog.init()
67
- },
68
- "#submit-profile": (_el, _event) => this.save(),
69
- ".delete-email": (el, _event) =>
70
- deleteEmailDialog(el.target, this.app),
71
- ".delete-socialaccount": (el, _event) =>
72
- deleteSocialaccountDialog(el.target, this.app)
73
- }
74
-
75
- this.postRenderHandlers = [
76
- () => {
77
- dropdownSelect(
78
- this.dom.querySelector("#edit-avatar-pulldown") as HTMLSelectElement,
79
- {
80
- onChange: (value: string | false) => {
81
- switch (value) {
82
- case "change":
83
- changeAvatarDialog(this.app)
84
- break
85
- case "delete":
86
- deleteAvatarDialog(this.app)
87
- break
88
- }
89
- },
90
- button: this.dom.querySelector("#edit-avatar-btn") as HTMLElement | false | undefined
91
- }
92
- )
93
- },
94
- () => {
95
- this.dom
96
- .querySelectorAll(".primary-email-radio")
97
- .forEach(el =>
98
- el.addEventListener("change", () =>
99
- changePrimaryEmailDialog(this.app)
100
- )
101
- )
102
- }
103
- ]
104
- if (this.app.settings.TWO_FACTOR_ENABLED) {
105
- this.clickTargets["#setup-two-factor"] = (_el, _event) => {
106
- import("../auth/two_factor.js").then(({twoFactorSetupDialog}) => {
107
- twoFactorSetupDialog(this.app)
108
- })
109
- }
110
- this.clickTargets["#disable-two-factor"] = (_el, _event) => {
111
- import("../auth/two_factor.js").then(({twoFactorDisableDialog}) => {
112
- twoFactorDisableDialog(this.app)
113
- })
114
- }
115
-
116
- this.postRenderHandlers.push(() => this.updateTwoFactorStatus())
117
- }
118
- if (
119
- this.app.settings.E2EE_MODE &&
120
- this.app.settings.E2EE_MODE !== "disabled"
121
- ) {
122
- this.clickTargets["#setup-e2ee-passphrase"] = (_el, _event) => {
123
- this.setupE2EEPassphrase()
124
- }
125
- this.clickTargets["#change-e2ee-passphrase"] = (_el, _event) => {
126
- this.changeE2EEPassphrase()
127
- }
128
- this.clickTargets["#recover-e2ee-passphrase"] = (_el, _event) => {
129
- this.recoverE2EEPassphrase()
45
+ this.dialog = new ProfileDialog({
46
+ app,
47
+ user,
48
+ socialaccount_providers,
49
+ profilePlugins,
50
+ onClose: () => {
51
+ if (window.location.pathname === "/user/profile/") {
52
+ this.app.goTo("/")
53
+ }
130
54
  }
131
-
132
- this.postRenderHandlers.push(() =>
133
- this.updateE2EEPassphraseStatus()
134
- )
135
- }
55
+ })
136
56
  }
137
57
 
138
58
  init(): Promise<void> {
139
59
  return whenReady().then(() => {
140
- this.activateFidusPlugins()
141
60
  this.render()
142
- const smenu = new SiteMenu(this.app, "")
143
- smenu.init()
144
- this.dom.addEventListener("click", (event: Event) => {
145
- const el: Record<string, any> = {}
146
- Object.entries(this.clickTargets).find(([selector, handler]) => {
147
- if (findTarget(event, selector, el)) {
148
- handler(el, event)
149
- return true
150
- }
151
- return false
152
- })
153
- })
154
- this.postRenderHandlers.forEach(handler => handler())
155
- })
156
- }
157
-
158
- activateFidusPlugins(): void {
159
- if (this.plugins) {
160
- return
161
- }
162
- // Add plugins.
163
- this.plugins = {}
164
-
165
- this.profilePlugins.forEach(([app, plugin]) => {
166
- if (!this.app.settings.APPS.includes(app)) {
167
- return
168
- }
169
- Object.values(plugin).forEach(pluginExport => {
170
- if (typeof pluginExport === "function") {
171
- const name = (pluginExport as any).name
172
- this.plugins![name] = new (pluginExport as any)(this)
173
- this.plugins![name].init()
174
- }
175
- })
61
+ this.dialog.open()
176
62
  })
177
63
  }
178
64
 
179
65
  render(): void {
180
- this.dom = document.createElement("body")
181
- this.dom.classList.add("fw-scrollable")
182
- this.dom.innerHTML = baseBodyTemplate({
183
- contents: profileContents(
184
- this.user,
185
- this.socialaccount_providers,
186
- this.app.settings,
187
- this.pluginTemplates
188
- ),
66
+ const dom = document.createElement("body")
67
+ dom.classList.add("fw-scrollable")
68
+ // The dialog carries the profile UI; the page behind it keeps the
69
+ // #profile-wrapper marker so deep links and host-page styling behave.
70
+ dom.innerHTML = baseBodyTemplate({
71
+ contents: '<div id="profile-wrapper"></div>',
189
72
  user: this.user,
190
73
  app: this.app
191
74
  })
192
- document.body = this.dom
75
+ document.body = dom
193
76
 
194
77
  ensureCSS([
195
78
  staticUrl("css/show_profile.css"),
@@ -197,189 +80,9 @@ export class Profile {
197
80
  ])
198
81
 
199
82
  setDocTitle(gettext("Configure profile"), this.app as {name: string})
83
+ const smenu = new SiteMenu(this.app, "")
84
+ smenu.init()
200
85
  const feedbackTab = new FeedbackTab(this.app)
201
86
  feedbackTab.init()
202
87
  }
203
-
204
- updateTwoFactorStatus(): void {
205
- import("../auth/two_factor.js").then(({checkTwoFactorStatus}) => {
206
- checkTwoFactorStatus(this.app).then((enabled: boolean) => {
207
- const enabledStatus = this.dom.querySelector(
208
- "#two-factor-enabled-status"
209
- ) as HTMLElement
210
- const disabledStatus = this.dom.querySelector(
211
- "#two-factor-disabled-status"
212
- ) as HTMLElement
213
- const setupBtn = this.dom.querySelector("#setup-two-factor") as HTMLElement
214
- const disableBtn = this.dom.querySelector(
215
- "#disable-two-factor"
216
- ) as HTMLElement
217
-
218
- if (enabled) {
219
- enabledStatus.style.display = "inline"
220
- disabledStatus.style.display = "none"
221
- setupBtn.style.display = "none"
222
- disableBtn.style.display = "inline"
223
- } else {
224
- enabledStatus.style.display = "none"
225
- disabledStatus.style.display = "inline"
226
- setupBtn.style.display = "inline"
227
- disableBtn.style.display = "none"
228
- }
229
- })
230
- })
231
- }
232
-
233
- updateE2EEPassphraseStatus(): void {
234
- import("fwtoolkit/e2ee/passphrase-manager").then(
235
- ({PassphraseManager}) => {
236
- PassphraseManager.hasEncryptionKeys().then((hasKeys: boolean) => {
237
- const enabledStatus = this.dom.querySelector(
238
- "#e2ee-passphrase-enabled-status"
239
- ) as HTMLElement
240
- const disabledStatus = this.dom.querySelector(
241
- "#e2ee-passphrase-disabled-status"
242
- ) as HTMLElement
243
- const setupBtn = this.dom.querySelector(
244
- "#setup-e2ee-passphrase"
245
- ) as HTMLElement
246
- const changeBtn = this.dom.querySelector(
247
- "#change-e2ee-passphrase"
248
- ) as HTMLElement
249
- const recoverBtn = this.dom.querySelector(
250
- "#recover-e2ee-passphrase"
251
- ) as HTMLElement
252
-
253
- if (hasKeys) {
254
- enabledStatus.style.display = "inline"
255
- disabledStatus.style.display = "none"
256
- setupBtn.style.display = "none"
257
- changeBtn.style.display = "inline"
258
- recoverBtn.style.display = "inline"
259
- } else {
260
- enabledStatus.style.display = "none"
261
- disabledStatus.style.display = "inline"
262
- setupBtn.style.display = "inline"
263
- changeBtn.style.display = "none"
264
- recoverBtn.style.display = "none"
265
- }
266
- })
267
- }
268
- )
269
- }
270
-
271
- async setupE2EEPassphrase(): Promise<void> {
272
- const {PassphraseManager} = await import(
273
- "fwtoolkit/e2ee/passphrase-manager"
274
- )
275
- const {setupPassphraseDialog} = await import(
276
- "fwtoolkit/e2ee/passphrase-dialog"
277
- )
278
-
279
- setupPassphraseDialog(async (passphrase: string) => {
280
- try {
281
- const {recoveryKey} =
282
- await PassphraseManager.setupEncryption(
283
- passphrase
284
- )
285
- const {showRecoveryKeyDialog} = await import(
286
- "fwtoolkit/e2ee/passphrase-dialog"
287
- )
288
- await showRecoveryKeyDialog(recoveryKey, () => {})
289
- this.updateE2EEPassphraseStatus()
290
- } catch (e: any) {
291
- addAlert("error", gettext("Failed to set up passphrase: ") + e.message)
292
- }
293
- })
294
- }
295
-
296
- async recoverE2EEPassphrase(): Promise<void> {
297
- const {PassphraseManager} = await import(
298
- "fwtoolkit/e2ee/passphrase-manager"
299
- )
300
- const {recoverWithKeyDialog, showRecoveryKeyDialog} = await import(
301
- "fwtoolkit/e2ee/passphrase-dialog"
302
- )
303
-
304
- const recoverResult: any = await new Promise(resolve => {
305
- recoverWithKeyDialog(resolve)
306
- })
307
- if (!recoverResult) {
308
- return
309
- }
310
- try {
311
- const {newRecoveryKey} =
312
- await PassphraseManager.recoverWithRecoveryKey(
313
- recoverResult.recoveryKey,
314
- recoverResult.newPassphrase,
315
- recoverResult.accountPassword
316
- )
317
- await new Promise<void>(resolve => {
318
- showRecoveryKeyDialog(newRecoveryKey, resolve)
319
- })
320
- this.updateE2EEPassphraseStatus()
321
- } catch (e: any) {
322
- addAlert("error", gettext("Recovery failed: ") + e.message)
323
- }
324
- }
325
-
326
- async changeE2EEPassphrase(): Promise<void> {
327
- const {PassphraseManager} = await import(
328
- "fwtoolkit/e2ee/passphrase-manager"
329
- )
330
- const {changePassphraseDialog} = await import(
331
- "fwtoolkit/e2ee/passphrase-dialog"
332
- )
333
-
334
- const changeResult: any = await new Promise(resolve => {
335
- changePassphraseDialog(resolve)
336
- })
337
- if (!changeResult) {
338
- return
339
- }
340
- try {
341
- await PassphraseManager.changePassphrase(
342
- changeResult.oldPassphrase,
343
- changeResult.newPassphrase,
344
- changeResult.accountPassword
345
- )
346
- addAlert("success", gettext("Passphrase changed successfully."))
347
- } catch (e: any) {
348
- addAlert("error", gettext("Failed to change passphrase: ") + e.message)
349
- }
350
- }
351
-
352
- save(): Promise<void> {
353
- activateWait()
354
- const newLang = (this.dom.querySelector("#language") as HTMLSelectElement).value
355
- const inlineReferences = (this.dom.querySelector("#inline-references") as HTMLInputElement).checked
356
- const inlineMath = (this.dom.querySelector("#inline-math") as HTMLInputElement).checked
357
- const grammarCheckContinuous = (this.dom.querySelector("#grammar-check-continuous") as HTMLInputElement).checked
358
- return this.app.apiConnectors.userProfile.save({
359
- username: (this.dom.querySelector("#username") as HTMLInputElement).value,
360
- first_name: (this.dom.querySelector("#first_name") as HTMLInputElement).value,
361
- last_name: (this.dom.querySelector("#last_name") as HTMLInputElement).value,
362
- language: newLang
363
- })
364
- .catch(() => addAlert("error", gettext("Could not save profile data")))
365
- .then(() =>
366
- this.app.apiConnectors.userProfile.updatePreferences({
367
- inline_references: inlineReferences,
368
- inline_math: inlineMath,
369
- grammar_check_continuous: grammarCheckContinuous
370
- })
371
- )
372
- .catch(() => addAlert("error", gettext("Could not save preferences")))
373
- .then(() => {
374
- deactivateWait()
375
- return this.app.getConfiguration()
376
- })
377
- .then(() => {
378
- const currentLang = document.documentElement.lang
379
-
380
- if (currentLang !== newLang) {
381
- window.location.reload()
382
- }
383
- })
384
- }
385
88
  }