diff --git a/features/stepDefinitions/wiki.ts b/features/stepDefinitions/wiki.ts index 5ee59454..bfba214f 100644 --- a/features/stepDefinitions/wiki.ts +++ b/features/stepDefinitions/wiki.ts @@ -146,7 +146,7 @@ Then('file {string} should exist in {string}', { timeout: 15000 }, async functio BACKOFF_OPTIONS, ); } catch { - // Get 1 levels up from actualPath + // Get 1 level up from actualPath const oneLevelsUp = path.resolve(directoryPath, '..'); const tree = await getDirectoryTree(oneLevelsUp); @@ -172,7 +172,7 @@ Then('file {string} should exist in {string}', { timeout: 15000 }, async functio throw new Error( `File "${fileName}" not found in directory: ${directoryPath}\n\n` + - `Directory tree (1 levels up from ${oneLevelsUp}):\n${tree}${tidFilesContent}`, + `Directory tree (1 level up from ${oneLevelsUp}):\n${tree}${tidFilesContent}`, ); } }); diff --git a/src/components/TokenForm/index.tsx b/src/components/TokenForm/index.tsx index 2107ffbe..f466ac9c 100644 --- a/src/components/TokenForm/index.tsx +++ b/src/components/TokenForm/index.tsx @@ -50,7 +50,7 @@ const Tab = styled(TabRaw)` interface Props { storageProvider?: SupportedStorageServices; - storageProviderSetter?: React.Dispatch>; + storageProviderSetter?: (value: SupportedStorageServices) => void; } /** * Create storage provider's token. @@ -58,12 +58,10 @@ interface Props { */ export function TokenForm({ storageProvider, storageProviderSetter }: Props): React.JSX.Element { const { t } = useTranslation(); - let [currentTab, currentTabSetter] = useState(SupportedStorageServices.github); + const [internalTab, internalTabSetter] = useState(SupportedStorageServices.github); // use external controls if provided - if (storageProvider !== undefined && typeof storageProviderSetter === 'function') { - currentTab = storageProvider; - currentTabSetter = storageProviderSetter; - } + const currentTab = storageProvider ?? internalTab; + const currentTabSetter = storageProviderSetter ?? internalTabSetter; // update storageProvider to be an online service, if this Component is opened useEffect(() => { if (storageProvider === SupportedStorageServices.local && typeof storageProviderSetter === 'function') { diff --git a/src/services/wiki/plugin/ipcSyncAdaptor/ipc-syncadaptor.ts b/src/services/wiki/plugin/ipcSyncAdaptor/ipc-syncadaptor.ts index 1259b82c..e5ad4a9f 100644 --- a/src/services/wiki/plugin/ipcSyncAdaptor/ipc-syncadaptor.ts +++ b/src/services/wiki/plugin/ipcSyncAdaptor/ipc-syncadaptor.ts @@ -40,7 +40,10 @@ class TidGiIPCSyncAdaptor { this.isReadOnly = false; this.logoutIsAvailable = true; const workspaceID = (window.meta() as WindowMeta[WindowNames.view]).workspace?.id; - this.workspaceID = workspaceID!; + if (workspaceID === undefined) { + throw new Error('TidGiIPCSyncAdaptor: workspaceID is undefined. Cannot initialize sync adaptor without a valid workspace ID.'); + } + this.workspaceID = workspaceID; if (window.observables?.wiki?.getWikiChangeObserver$ !== undefined) { // if install-electron-ipc-cat is faster than us, just subscribe to the observable. Otherwise we normally will wait for it to call us here. this.setupSSE(); diff --git a/src/windows/EditWorkspace/index.tsx b/src/windows/EditWorkspace/index.tsx index 331200a2..4da4eac1 100644 --- a/src/windows/EditWorkspace/index.tsx +++ b/src/windows/EditWorkspace/index.tsx @@ -319,9 +319,7 @@ export default function EditWorkspace(): React.JSX.Element { { - const actualStorageService = typeof nextStorageService === 'function' ? nextStorageService(storageService) : nextStorageService; - workspaceSetter({ ...workspace, storageService: actualStorageService }); - // requestRestartCountDown(); + workspaceSetter({ ...workspace, storageService: nextStorageService }); }} /> )}