mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-25 01:11:32 +00:00
refactor function by simplifying function argument (from two arguments to a single object)
GitOrigin-RevId: e4244a07a4ca196afa226e3fac9de74d30f7d4ea
This commit is contained in:
parent
777beaadc3
commit
af01ace5a0
4 changed files with 12 additions and 8 deletions
|
@ -19,7 +19,7 @@ export default function useSetProjectWideSettings() {
|
|||
(compiler: ProjectCompiler) => {
|
||||
if (project?.compiler) {
|
||||
setProject({ ...project, compiler })
|
||||
saveProjectSettings(projectId, { compiler })
|
||||
saveProjectSettings({ projectId, compiler })
|
||||
}
|
||||
},
|
||||
[projectId, project, setProject]
|
||||
|
@ -29,7 +29,7 @@ export default function useSetProjectWideSettings() {
|
|||
(imageName: string) => {
|
||||
if (project?.imageName) {
|
||||
setProject({ ...project, imageName })
|
||||
saveProjectSettings(projectId, { imageName })
|
||||
saveProjectSettings({ projectId, imageName })
|
||||
}
|
||||
},
|
||||
[projectId, project, setProject]
|
||||
|
|
|
@ -19,7 +19,7 @@ export default function useSetRootDocId() {
|
|||
|
||||
if (!disallowChange) {
|
||||
try {
|
||||
await saveProjectSettings(projectId, { rootDoc_id: rootDocId })
|
||||
await saveProjectSettings({ projectId, rootDoc_id: rootDocId })
|
||||
setRootDocIdScope(rootDocId)
|
||||
} catch (err) {
|
||||
// TODO: retry mechanism (max 10x before failed completely and rollback the old value)
|
||||
|
|
|
@ -23,7 +23,7 @@ export default function useSetSpellCheckLanguage() {
|
|||
setSpellCheckLanguageScope(spellCheckLanguage)
|
||||
|
||||
// save to both project setting and user setting
|
||||
saveProjectSettings(projectId, { spellCheckLanguage })
|
||||
saveProjectSettings({ projectId, spellCheckLanguage })
|
||||
saveUserSettings({ spellCheckLanguage })
|
||||
}
|
||||
},
|
||||
|
|
|
@ -52,10 +52,14 @@ type ProjectSettingsRequestBody = Partial<
|
|||
}
|
||||
>
|
||||
|
||||
export const saveProjectSettings = async (
|
||||
projectId: string,
|
||||
data: Partial<ProjectSettingsScope>
|
||||
) => {
|
||||
type SaveProjectSettings = {
|
||||
projectId: string
|
||||
} & Partial<ProjectSettingsScope>
|
||||
|
||||
export const saveProjectSettings = async ({
|
||||
projectId,
|
||||
...data
|
||||
}: SaveProjectSettings) => {
|
||||
let reqData: ProjectSettingsRequestBody = {}
|
||||
|
||||
if (data.rootDoc_id) {
|
||||
|
|
Loading…
Reference in a new issue