mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Remove multiple source of type imports; add type
on type imports.
GitOrigin-RevId: a6630bb284c456bfbe61901f7331cdd3c13c7f8b
This commit is contained in:
parent
12f5c845b4
commit
e3d0380e6f
6 changed files with 33 additions and 36 deletions
|
@ -1,5 +1,4 @@
|
|||
import { useCallback, useEffect } from 'react'
|
||||
import { ProjectCompiler } from '../../../../../types/project-settings'
|
||||
import { useIdeContext } from '../../../shared/context/ide-context'
|
||||
import useScopeValue from '../../../shared/hooks/use-scope-value'
|
||||
import type { ProjectSettingsScope } from '../utils/api'
|
||||
|
@ -12,7 +11,7 @@ export default function useProjectWideSettingsSocketListener() {
|
|||
>('project', true)
|
||||
|
||||
const setCompiler = useCallback(
|
||||
(compiler: ProjectCompiler) => {
|
||||
(compiler: ProjectSettingsScope['compiler']) => {
|
||||
if (projectScope) {
|
||||
setProjectScope({ ...projectScope, compiler })
|
||||
}
|
||||
|
@ -21,7 +20,7 @@ export default function useProjectWideSettingsSocketListener() {
|
|||
)
|
||||
|
||||
const setImageName = useCallback(
|
||||
(imageName: string) => {
|
||||
(imageName: ProjectSettingsScope['imageName']) => {
|
||||
if (projectScope) {
|
||||
setProjectScope({ ...projectScope, imageName })
|
||||
}
|
||||
|
@ -30,7 +29,7 @@ export default function useProjectWideSettingsSocketListener() {
|
|||
)
|
||||
|
||||
const setSpellCheckLanguage = useCallback(
|
||||
(spellCheckLanguage: string) => {
|
||||
(spellCheckLanguage: ProjectSettingsScope['spellCheckLanguage']) => {
|
||||
if (projectScope) {
|
||||
setProjectScope({ ...projectScope, spellCheckLanguage })
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { useCallback } from 'react'
|
||||
import { ProjectCompiler } from '../../../../../types/project-settings'
|
||||
import { useProjectContext } from '../../../shared/context/project-context'
|
||||
import useScopeValue from '../../../shared/hooks/use-scope-value'
|
||||
import { ProjectSettingsScope, saveProjectSettings } from '../utils/api'
|
||||
import { type ProjectSettingsScope, saveProjectSettings } from '../utils/api'
|
||||
import useSetRootDocId from './use-set-root-doc-id'
|
||||
import useSetSpellCheckLanguage from './use-set-spell-check-language'
|
||||
|
||||
|
@ -15,7 +14,7 @@ export default function useProjectWideSettings() {
|
|||
const { _id: projectId } = useProjectContext()
|
||||
|
||||
const setCompiler = useCallback(
|
||||
(compiler: ProjectCompiler) => {
|
||||
(compiler: ProjectSettingsScope['compiler']) => {
|
||||
const allowUpdate = project?.compiler
|
||||
|
||||
if (allowUpdate) {
|
||||
|
@ -27,7 +26,7 @@ export default function useProjectWideSettings() {
|
|||
)
|
||||
|
||||
const setImageName = useCallback(
|
||||
(imageName: string) => {
|
||||
(imageName: ProjectSettingsScope['imageName']) => {
|
||||
const allowUpdate = project?.imageName
|
||||
|
||||
if (allowUpdate) {
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
import { useCallback, useEffect, useState } from 'react'
|
||||
import _ from 'lodash'
|
||||
import { OverallTheme } from '../../../../../modules/source-editor/frontend/js/extensions/theme'
|
||||
import useScopeValue from '../../../shared/hooks/use-scope-value'
|
||||
import { OverallThemeMeta } from '../../../../../types/project-settings'
|
||||
import { saveUserSettings } from '../utils/api'
|
||||
import type { OverallThemeMeta } from '../../../../../types/project-settings'
|
||||
import { saveUserSettings, type UserSettingsScope } from '../utils/api'
|
||||
|
||||
export default function useSetOverallTheme() {
|
||||
const [chosenTheme, setChosenTheme] = useState<OverallThemeMeta | null>(null)
|
||||
const [loadingStyleSheet, setLoadingStyleSheet] = useScopeValue<boolean>(
|
||||
'ui.loadingStyleSheet'
|
||||
)
|
||||
const [overallThemeScope, setOverallThemeScope] = useScopeValue<OverallTheme>(
|
||||
'settings.overallTheme'
|
||||
)
|
||||
const [overallThemeScope, setOverallThemeScope] = useScopeValue<
|
||||
UserSettingsScope['overallTheme']
|
||||
>('settings.overallTheme')
|
||||
|
||||
useEffect(() => {
|
||||
const docHeadEl = document.querySelector('head')
|
||||
|
@ -45,7 +44,7 @@ export default function useSetOverallTheme() {
|
|||
}, [loadingStyleSheet, setLoadingStyleSheet, chosenTheme?.path])
|
||||
|
||||
const setOverallTheme = useCallback(
|
||||
(overallTheme: OverallTheme) => {
|
||||
(overallTheme: UserSettingsScope['overallTheme']) => {
|
||||
if (overallThemeScope !== overallTheme) {
|
||||
const chosenTheme = _.find(
|
||||
window.overallThemes,
|
||||
|
|
|
@ -2,16 +2,16 @@ import { useCallback } from 'react'
|
|||
import { useEditorContext } from '../../../shared/context/editor-context'
|
||||
import { useProjectContext } from '../../../shared/context/project-context'
|
||||
import useScopeValue from '../../../shared/hooks/use-scope-value'
|
||||
import { saveProjectSettings } from '../utils/api'
|
||||
import { type ProjectSettingsScope, saveProjectSettings } from '../utils/api'
|
||||
|
||||
export default function useSetRootDocId() {
|
||||
const [rootDocIdScope, setRootDocIdScope] =
|
||||
useScopeValue<string>('project.rootDoc_id')
|
||||
useScopeValue<ProjectSettingsScope['rootDoc_id']>('project.rootDoc_id')
|
||||
const { permissionsLevel } = useEditorContext()
|
||||
const { _id: projectId } = useProjectContext()
|
||||
|
||||
const setRootDocId = useCallback(
|
||||
async (rootDocId: string) => {
|
||||
async (rootDocId: ProjectSettingsScope['rootDoc_id']) => {
|
||||
const allowUpdate =
|
||||
typeof rootDocIdScope !== 'undefined' &&
|
||||
permissionsLevel !== 'readOnly' &&
|
||||
|
|
|
@ -2,15 +2,20 @@ import { useCallback } from 'react'
|
|||
import { sendMB } from '../../../infrastructure/event-tracking'
|
||||
import { useProjectContext } from '../../../shared/context/project-context'
|
||||
import useScopeValue from '../../../shared/hooks/use-scope-value'
|
||||
import { saveProjectSettings, saveUserSettings } from '../utils/api'
|
||||
import {
|
||||
type ProjectSettingsScope,
|
||||
saveProjectSettings,
|
||||
saveUserSettings,
|
||||
} from '../utils/api'
|
||||
|
||||
export default function useSetSpellCheckLanguage() {
|
||||
const [spellCheckLanguageScope, setSpellCheckLanguageScope] =
|
||||
useScopeValue<string>('project.spellCheckLanguage')
|
||||
const [spellCheckLanguageScope, setSpellCheckLanguageScope] = useScopeValue<
|
||||
ProjectSettingsScope['spellCheckLanguage']
|
||||
>('project.spellCheckLanguage')
|
||||
const { _id: projectId } = useProjectContext()
|
||||
|
||||
const setSpellCheckLanguage = useCallback(
|
||||
(spellCheckLanguage: string) => {
|
||||
(spellCheckLanguage: ProjectSettingsScope['spellCheckLanguage']) => {
|
||||
const allowUpdate =
|
||||
spellCheckLanguage && spellCheckLanguage !== spellCheckLanguageScope
|
||||
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
import { useCallback } from 'react'
|
||||
import {
|
||||
FontFamily,
|
||||
LineHeight,
|
||||
} from '../../../../../modules/source-editor/frontend/js/extensions/theme'
|
||||
import { Keybindings, PdfViewer } from '../../../../../types/project-settings'
|
||||
import useScopeValue from '../../../shared/hooks/use-scope-value'
|
||||
import useSetOverallTheme from './use-set-overall-theme'
|
||||
import useSaveUserSettings from './use-save-user-settings'
|
||||
|
@ -20,63 +15,63 @@ export default function useUserWideSettings() {
|
|||
|
||||
const setOverallTheme = useSetOverallTheme()
|
||||
const setAutoComplete = useCallback(
|
||||
(autoComplete: boolean) => {
|
||||
(autoComplete: UserSettingsScope['autoComplete']) => {
|
||||
saveUserSettings('autoComplete', autoComplete)
|
||||
},
|
||||
[saveUserSettings]
|
||||
)
|
||||
|
||||
const setAutoPairDelimiters = useCallback(
|
||||
(autoPairDelimiters: boolean) => {
|
||||
(autoPairDelimiters: UserSettingsScope['autoPairDelimiters']) => {
|
||||
saveUserSettings('autoPairDelimiters', autoPairDelimiters)
|
||||
},
|
||||
[saveUserSettings]
|
||||
)
|
||||
|
||||
const setSyntaxValidation = useCallback(
|
||||
(syntaxValidation: boolean) => {
|
||||
(syntaxValidation: UserSettingsScope['syntaxValidation']) => {
|
||||
saveUserSettings('syntaxValidation', syntaxValidation)
|
||||
},
|
||||
[saveUserSettings]
|
||||
)
|
||||
|
||||
const setEditorTheme = useCallback(
|
||||
(editorTheme: string) => {
|
||||
(editorTheme: UserSettingsScope['editorTheme']) => {
|
||||
saveUserSettings('editorTheme', editorTheme)
|
||||
},
|
||||
[saveUserSettings]
|
||||
)
|
||||
|
||||
const setMode = useCallback(
|
||||
(mode: Keybindings) => {
|
||||
(mode: UserSettingsScope['mode']) => {
|
||||
saveUserSettings('mode', mode)
|
||||
},
|
||||
[saveUserSettings]
|
||||
)
|
||||
|
||||
const setFontSize = useCallback(
|
||||
(fontSize: string) => {
|
||||
(fontSize: UserSettingsScope['fontSize']) => {
|
||||
saveUserSettings('fontSize', fontSize)
|
||||
},
|
||||
[saveUserSettings]
|
||||
)
|
||||
|
||||
const setFontFamily = useCallback(
|
||||
(fontFamily: FontFamily) => {
|
||||
(fontFamily: UserSettingsScope['fontFamily']) => {
|
||||
saveUserSettings('fontFamily', fontFamily)
|
||||
},
|
||||
[saveUserSettings]
|
||||
)
|
||||
|
||||
const setLineHeight = useCallback(
|
||||
(lineHeight: LineHeight) => {
|
||||
(lineHeight: UserSettingsScope['lineHeight']) => {
|
||||
saveUserSettings('lineHeight', lineHeight)
|
||||
},
|
||||
[saveUserSettings]
|
||||
)
|
||||
|
||||
const setPdfViewer = useCallback(
|
||||
(pdfViewer: PdfViewer) => {
|
||||
(pdfViewer: UserSettingsScope['pdfViewer']) => {
|
||||
saveUserSettings('pdfViewer', pdfViewer)
|
||||
},
|
||||
[saveUserSettings]
|
||||
|
|
Loading…
Reference in a new issue