diff --git a/backend/FwLite/FwLiteShared/Events/JsEventListener.cs b/backend/FwLite/FwLiteShared/Events/JsEventListener.cs index 2c4ff0ccd0..f1455007f8 100644 --- a/backend/FwLite/FwLiteShared/Events/JsEventListener.cs +++ b/backend/FwLite/FwLiteShared/Events/JsEventListener.cs @@ -69,7 +69,6 @@ public JsEventListener(ILogger logger, GlobalEventBus globalEve } [JSInvokable] - [TsFunction(Type = "Promise")] public ValueTask LastEvent(FwEventType type) { return ValueTask.FromResult(_globalEventBus.GetLastEvent(type)); diff --git a/backend/FwLite/FwLiteShared/Services/IPreferencesService.cs b/backend/FwLite/FwLiteShared/Services/IPreferencesService.cs index e7143327c1..3fabaa31da 100644 --- a/backend/FwLite/FwLiteShared/Services/IPreferencesService.cs +++ b/backend/FwLite/FwLiteShared/Services/IPreferencesService.cs @@ -10,7 +10,6 @@ namespace FwLiteShared.Services; public interface IPreferencesService { [JSInvokable] - [TsFunction(Type = "Promise")] string? Get(string key); [JSInvokable] void Set(string key, string value); diff --git a/backend/FwLite/FwLiteShared/Services/MiniLcmJsInvokable.cs b/backend/FwLite/FwLiteShared/Services/MiniLcmJsInvokable.cs index 2be60072c2..9687162f34 100644 --- a/backend/FwLite/FwLiteShared/Services/MiniLcmJsInvokable.cs +++ b/backend/FwLite/FwLiteShared/Services/MiniLcmJsInvokable.cs @@ -86,14 +86,12 @@ public ValueTask GetCustomViews() } [JSInvokable] - [TsFunction(Type = "Promise")] public Task GetCustomView(Guid id) { return _wrappedApi.GetCustomView(id); } [JSInvokable] - [TsFunction(Type = "Promise")] public Task GetComplexFormType(Guid id) { return _wrappedApi.GetComplexFormType(id); @@ -139,35 +137,30 @@ public Task SearchEntries(string query, QueryOptions? options = null) } [JSInvokable] - [TsFunction(Type = "Promise")] public Task GetEntry(Guid id) { return Task.Run(async () => await _wrappedApi.GetEntry(id)); } [JSInvokable] - [TsFunction(Type = "Promise")] public Task GetSense(Guid entryId, Guid id) { return _wrappedApi.GetSense(entryId, id); } [JSInvokable] - [TsFunction(Type = "Promise")] public Task GetPartOfSpeech(Guid id) { return _wrappedApi.GetPartOfSpeech(id); } [JSInvokable] - [TsFunction(Type = "Promise")] public Task GetSemanticDomain(Guid id) { return _wrappedApi.GetSemanticDomain(id); } [JSInvokable] - [TsFunction(Type = "Promise")] public Task GetExampleSentence(Guid entryId, Guid senseId, Guid id) { return _wrappedApi.GetExampleSentence(entryId, senseId, id); @@ -286,7 +279,6 @@ public ValueTask GetCommentThreads(SubjectType subjectType, Gui } [JSInvokable] - [TsFunction(Type = "Promise")] public Task GetCommentThread(Guid id) { return _wrappedApi.GetCommentThread(id); @@ -299,7 +291,6 @@ public ValueTask GetUserComments(Guid threadId) } [JSInvokable] - [TsFunction(Type = "Promise")] public Task GetUserComment(Guid id) { return _wrappedApi.GetUserComment(id); @@ -531,7 +522,7 @@ public async Task DeletePicture(Guid entryId, Guid senseId, Guid pictureId) } [JSInvokable] - public async Task GetFileStream(string mediaUri, bool downloadIfMissing) + public async Task GetFileStream(string mediaUri, bool downloadIfMissing) { var result = await _wrappedApi.GetFileStream(new MediaUri(mediaUri), downloadIfMissing); var stream = result.Stream is null ? null : new DotNetStreamReference(result.Stream); diff --git a/backend/FwLite/FwLiteShared/Services/ProjectServicesProvider.cs b/backend/FwLite/FwLiteShared/Services/ProjectServicesProvider.cs index ef8b52806f..dbb2108782 100644 --- a/backend/FwLite/FwLiteShared/Services/ProjectServicesProvider.cs +++ b/backend/FwLite/FwLiteShared/Services/ProjectServicesProvider.cs @@ -39,10 +39,10 @@ public async Task DisposeService(DotNetObjectReference service } [JSInvokable] - public Task TryGetCrdtProjectName(string code) + public string? TryGetCrdtProjectName(string code) { var crdtProject = crdtProjectsService.GetProject(code); - return Task.FromResult(crdtProject?.Data?.Name); + return crdtProject?.Data?.Name; } [JSInvokable] diff --git a/backend/FwLite/FwLiteShared/Services/UpdateService.cs b/backend/FwLite/FwLiteShared/Services/UpdateService.cs index 00f9995ea1..c8841f1853 100644 --- a/backend/FwLite/FwLiteShared/Services/UpdateService.cs +++ b/backend/FwLite/FwLiteShared/Services/UpdateService.cs @@ -7,7 +7,6 @@ namespace FwLiteShared.Services; public class UpdateService(UpdateChecker updateChecker) { [JSInvokable] - [TsFunction(Type = "Promise")] public Task CheckForUpdates() { return Task.Run(async () => await updateChecker.CheckForUpdate()); diff --git a/backend/FwLite/FwLiteShared/TypeGen/ReinforcedFwLiteTypingConfig.cs b/backend/FwLite/FwLiteShared/TypeGen/ReinforcedFwLiteTypingConfig.cs index ac12543e8d..18fc07218e 100644 --- a/backend/FwLite/FwLiteShared/TypeGen/ReinforcedFwLiteTypingConfig.cs +++ b/backend/FwLite/FwLiteShared/TypeGen/ReinforcedFwLiteTypingConfig.cs @@ -28,6 +28,7 @@ using MiniLcm.Media; using MediaFile = MiniLcm.Media.MediaFile; using Microsoft.Extensions.Logging; +using Reinforced.Typings.Generators; using SIL.Harmony.Changes; using SIL.Harmony.Resource; @@ -228,6 +229,7 @@ private static void ConfigureFwLiteSharedTypes(ConfigurationBuilder builder) private static MethodExportBuilder AlwaysReturnPromise(this MethodExportBuilder exportBuilder) { + exportBuilder.WithCodeGenerator(); var isUpdatePatchMethod = exportBuilder.Member.GetParameters() .Any(p => p.ParameterType.IsGenericType && p.ParameterType.GetGenericTypeDefinition() == typeof(UpdateObjectInput<>)); @@ -310,4 +312,40 @@ public override void Visit(RtImport node) base.Visit(node); } } + + /// + /// introspects the return type of a method to determine if it is nullable and modifies the return type to be T | undefined + /// before Task -> Promise after Promise + /// + internal class NullableMethodReturnBuilder : MethodCodeGenerator + { + private static NullabilityInfoContext _nullabilityInfoContext = new(); + protected override void GetFunctionNameAndReturnType(MethodInfo element, TypeResolver resolver, out string name, out RtTypeName type) + { + base.GetFunctionNameAndReturnType(element, resolver, out name, out type); + if (type is RtAsyncType {TypeNameOfAsync: RtSimpleTypeName asyncResolveType}) + { + var nullabilityInfo = _nullabilityInfoContext.Create(element.ReturnParameter); + var mayBeNull = false; + //some methods return Task but some just return T and we force them to always show as Promise + //but here we need to know which as we're looking at the underlying type + if (element.ReturnType.IsGenericType && + (element.ReturnType.GetGenericTypeDefinition() == typeof(Task<>) + || element.ReturnType.GetGenericTypeDefinition() == typeof(ValueTask<>))) + { + mayBeNull = (nullabilityInfo.GenericTypeArguments.FirstOrDefault()?.ReadState ?? NullabilityState.Nullable) == NullabilityState.Nullable; + } + else + { + mayBeNull = nullabilityInfo.ReadState == NullabilityState.Nullable; + } + + if (mayBeNull) + { + type = new RtAsyncType(new RtSimpleTypeName(asyncResolveType.TypeName + " | undefined")); + } + } + + } + } } diff --git a/frontend/viewer/src/home/ServersList.svelte b/frontend/viewer/src/home/ServersList.svelte index ba6ab29909..8822123512 100644 --- a/frontend/viewer/src/home/ServersList.svelte +++ b/frontend/viewer/src/home/ServersList.svelte @@ -29,7 +29,8 @@ async function refreshServerProjects(server: ILexboxServer, force: boolean = false) { loadingServerProjects = server.id; - remoteProjects[server.id] = await projectsService.serverProjects(server.id, force); + const projects = await projectsService.serverProjects(server.id, force); + if (projects) remoteProjects[server.id] = projects; remoteProjects = remoteProjects; loadingServerProjects = undefined; } diff --git a/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Events/IJsEventListener.ts b/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Events/IJsEventListener.ts index 4512d173ae..c9a1d9b8de 100644 --- a/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Events/IJsEventListener.ts +++ b/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Events/IJsEventListener.ts @@ -8,7 +8,7 @@ import type {FwEventType} from './FwEventType'; export interface IJsEventListener { - nextEventAsync() : Promise; - lastEvent(type: FwEventType) : Promise; + nextEventAsync() : Promise; + lastEvent(type: FwEventType) : Promise; } /* eslint-enable */ diff --git a/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Projects/ICombinedProjectsService.ts b/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Projects/ICombinedProjectsService.ts index 5052eb3e06..57144fc545 100644 --- a/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Projects/ICombinedProjectsService.ts +++ b/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Projects/ICombinedProjectsService.ts @@ -13,7 +13,7 @@ export interface ICombinedProjectsService { supportsFwData() : Promise; remoteProjects() : Promise; - serverProjects(serverId: string, forceRefresh: boolean) : Promise; + serverProjects(serverId: string, forceRefresh: boolean) : Promise; localProjects() : Promise; downloadProjectByCode(code: string, server: ILexboxServer, userRole?: UserProjectRole) : Promise; downloadProject(project: IProjectModel) : Promise; diff --git a/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/IHistoryServiceJsInvokable.ts b/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/IHistoryServiceJsInvokable.ts index 0c4ed16372..fb5d193892 100644 --- a/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/IHistoryServiceJsInvokable.ts +++ b/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/IHistoryServiceJsInvokable.ts @@ -18,7 +18,7 @@ export interface IHistoryServiceJsInvokable projectActivity(skip: number, take: number, authorFilterKeys?: string[], changeTypeKeys?: string[], sort?: ActivitySort) : Promise; listActivityAuthors() : Promise; listActivityChangeTypes() : Promise; - getSnapshot(snapshotId: string) : Promise; + getSnapshot(snapshotId: string) : Promise; getHistory(entityId: string) : Promise; loadChangeContext(commitId: string, changeIndex: number) : Promise; } diff --git a/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/IMiniLcmJsInvokable.ts b/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/IMiniLcmJsInvokable.ts index 776c72af30..ce2798b8bb 100644 --- a/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/IMiniLcmJsInvokable.ts +++ b/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/IMiniLcmJsInvokable.ts @@ -15,6 +15,8 @@ import type {IFilterQueryOptions} from '../../MiniLcm/IFilterQueryOptions'; import type {IIndexQueryOptions} from '../../MiniLcm/IIndexQueryOptions'; import type {IEntry} from '../../MiniLcm/Models/IEntry'; import type {IQueryOptions} from '../../MiniLcm/IQueryOptions'; +import type {ISense} from '../../MiniLcm/Models/ISense'; +import type {IExampleSentence} from '../../MiniLcm/Models/IExampleSentence'; import type {IWritingSystem} from '../../MiniLcm/Models/IWritingSystem'; import type {WritingSystemType} from '../../MiniLcm/Models/WritingSystemType'; import type {ICommentThread} from '../../MiniLcm/Models/ICommentThread'; @@ -23,8 +25,6 @@ import type {IUserComment} from '../../MiniLcm/Models/IUserComment'; import type {ThreadStatus} from '../../MiniLcm/Models/ThreadStatus'; import type {ICreateEntryOptions} from '../../MiniLcm/ICreateEntryOptions'; import type {IComplexFormComponent} from '../../MiniLcm/Models/IComplexFormComponent'; -import type {ISense} from '../../MiniLcm/Models/ISense'; -import type {IExampleSentence} from '../../MiniLcm/Models/IExampleSentence'; import type {IPicture} from '../../MiniLcm/Models/IPicture'; import type {IReadFileResponseJs} from './IReadFileResponseJs'; import type {IUploadFileResponse} from '../../MiniLcm/Media/IUploadFileResponse'; @@ -39,18 +39,18 @@ export interface IMiniLcmJsInvokable getSemanticDomains() : Promise; getComplexFormTypes() : Promise; getCustomViews() : Promise; - getCustomView(id: string) : Promise; - getComplexFormType(id: string) : Promise; + getCustomView(id: string) : Promise; + getComplexFormType(id: string) : Promise; getMorphTypes() : Promise; countEntries(query?: string, options?: IFilterQueryOptions) : Promise; getEntryIndex(id: string, query?: string, options?: IIndexQueryOptions) : Promise; getEntries(options?: IQueryOptions) : Promise; searchEntries(query: string, options?: IQueryOptions) : Promise; - getEntry(id: string) : Promise; - getSense(entryId: string, id: string) : Promise; - getPartOfSpeech(id: string) : Promise; - getSemanticDomain(id: string) : Promise; - getExampleSentence(entryId: string, senseId: string, id: string) : Promise; + getEntry(id: string) : Promise; + getSense(entryId: string, id: string) : Promise; + getPartOfSpeech(id: string) : Promise; + getSemanticDomain(id: string) : Promise; + getExampleSentence(entryId: string, senseId: string, id: string) : Promise; createWritingSystem(type: WritingSystemType, writingSystem: IWritingSystem) : Promise; updateWritingSystem(before: IWritingSystem, after: IWritingSystem) : Promise; createPartOfSpeech(partOfSpeech: IPartOfSpeech) : Promise; @@ -66,9 +66,9 @@ export interface IMiniLcmJsInvokable updateCustomView(customView: ICustomView) : Promise; deleteCustomView(id: string) : Promise; getCommentThreads(subjectType: SubjectType, subjectId: string, includeComments?: boolean) : Promise; - getCommentThread(id: string) : Promise; + getCommentThread(id: string) : Promise; getUserComments(threadId: string) : Promise; - getUserComment(id: string) : Promise; + getUserComment(id: string) : Promise; getUnreadComments(threadId?: string) : Promise; getUnreadCommentsForSubject(subjectType: SubjectType, subjectId: string) : Promise; countUnreadComments(threadId?: string) : Promise; diff --git a/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/IPreferencesService.ts b/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/IPreferencesService.ts index ed4d587398..66b662d84c 100644 --- a/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/IPreferencesService.ts +++ b/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/IPreferencesService.ts @@ -5,7 +5,7 @@ export interface IPreferencesService { - get(key: string) : Promise; + get(key: string) : Promise; set(key: string, value: string) : Promise; remove(key: string) : Promise; } diff --git a/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/IProjectServicesProvider.ts b/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/IProjectServicesProvider.ts index 8eaae06407..d338f53ce1 100644 --- a/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/IProjectServicesProvider.ts +++ b/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/IProjectServicesProvider.ts @@ -10,7 +10,7 @@ import type {IProjectScope} from './IProjectScope'; export interface IProjectServicesProvider extends IAsyncDisposable { disposeService(service: DotNet.DotNetObject) : Promise; - tryGetCrdtProjectName(code: string) : Promise; + tryGetCrdtProjectName(code: string) : Promise; openCrdtProject(code: string) : Promise; openFwDataProject(projectName: string) : Promise; } diff --git a/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/ISyncServiceJsInvokable.ts b/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/ISyncServiceJsInvokable.ts index d24728e027..93edd49c5e 100644 --- a/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/ISyncServiceJsInvokable.ts +++ b/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/ISyncServiceJsInvokable.ts @@ -13,9 +13,9 @@ export interface ISyncServiceJsInvokable { getSyncStatus() : Promise; triggerFwHeadlessSync() : Promise; - countPendingCrdtCommits() : Promise; - getLatestSyncedCommitDate() : Promise; + countPendingCrdtCommits() : Promise; + getLatestSyncedCommitDate() : Promise; executeSync(skipNotifications: boolean) : Promise; - getCurrentServer() : Promise; + getCurrentServer() : Promise; } /* eslint-enable */ diff --git a/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/IUpdateService.ts b/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/IUpdateService.ts index a04dcbae42..cd81871733 100644 --- a/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/IUpdateService.ts +++ b/frontend/viewer/src/lib/dotnet-types/generated-types/FwLiteShared/Services/IUpdateService.ts @@ -3,12 +3,12 @@ // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. -import type {UpdateResult} from '../AppUpdate/UpdateResult'; import type {IAvailableUpdate} from '../AppUpdate/IAvailableUpdate'; +import type {UpdateResult} from '../AppUpdate/UpdateResult'; export interface IUpdateService { - checkForUpdates() : Promise; + checkForUpdates() : Promise; applyUpdate(update: IAvailableUpdate) : Promise; } /* eslint-enable */ diff --git a/frontend/viewer/src/lib/services/browser-app-services.ts b/frontend/viewer/src/lib/services/browser-app-services.ts index 9ac83dbebe..f7bf914d45 100644 --- a/frontend/viewer/src/lib/services/browser-app-services.ts +++ b/frontend/viewer/src/lib/services/browser-app-services.ts @@ -4,8 +4,8 @@ import type {IJsEventListener} from '$lib/dotnet-types/generated-types/FwLiteSha import type {IPreferencesService} from '$lib/dotnet-types/generated-types/FwLiteShared/Services/IPreferencesService'; const localStoragePreferencesService: IPreferencesService = { - get(key: string): Promise { - return Promise.resolve(localStorage.getItem(key)); + get(key: string): Promise { + return Promise.resolve(localStorage.getItem(key) ?? undefined); }, set(key: string, value: string): Promise { localStorage.setItem(key, value); @@ -22,8 +22,8 @@ const noopJsEventListener: IJsEventListener = { // Never resolves — no events to deliver in a browser-only context return new Promise(() => {}); }, - lastEvent(): Promise { - return Promise.resolve(null); + lastEvent(): Promise { + return Promise.resolve(undefined); }, }; diff --git a/frontend/viewer/src/lib/services/event-bus.ts b/frontend/viewer/src/lib/services/event-bus.ts index 26a2a8d074..161103f7f9 100644 --- a/frontend/viewer/src/lib/services/event-bus.ts +++ b/frontend/viewer/src/lib/services/event-bus.ts @@ -36,7 +36,7 @@ export class EventBus { } private async eventLoop(jsEventListener: IJsEventListener) { - let event: IFwEvent; + let event: IFwEvent | undefined; while (true) { event = await jsEventListener.nextEventAsync(); if (!event) return; diff --git a/frontend/viewer/src/lib/services/service-provider-dotnet.ts b/frontend/viewer/src/lib/services/service-provider-dotnet.ts index 3aa4cec5c9..4b3755c5f8 100644 --- a/frontend/viewer/src/lib/services/service-provider-dotnet.ts +++ b/frontend/viewer/src/lib/services/service-provider-dotnet.ts @@ -66,7 +66,8 @@ export function wrapInProxy(dotnetObject: DotNet.DotNetObj console.debug(`[Dotnet Proxy] Calling ${serviceName} method ${dotnetMethodName}`, args); args = transformArgs(args); try { - const result = await target.invokeMethodAsync(dotnetMethodName, ...args); + let result = await target.invokeMethodAsync(dotnetMethodName, ...args); + if (result === null) result = undefined;//ensure that if the return is null rewrite it to undefined to match the contract console.debug(`[Dotnet Proxy] ${serviceName} method ${dotnetMethodName} returned`, result); return result; } catch (error) { diff --git a/frontend/viewer/src/lib/updates/UpdateDialog.svelte b/frontend/viewer/src/lib/updates/UpdateDialog.svelte index 2165a019dd..e491e6e9da 100644 --- a/frontend/viewer/src/lib/updates/UpdateDialog.svelte +++ b/frontend/viewer/src/lib/updates/UpdateDialog.svelte @@ -16,7 +16,7 @@ const config = useFwLiteConfig(); const updateService = useUpdateService(); - let checkPromise = $state>(); + let checkPromise = $state>(); let installPromise = $state>(); const eventBus = useEventBus(); diff --git a/frontend/viewer/src/lib/updates/UpdateDialogContent.svelte b/frontend/viewer/src/lib/updates/UpdateDialogContent.svelte index 7616c20c15..1bea64e2ee 100644 --- a/frontend/viewer/src/lib/updates/UpdateDialogContent.svelte +++ b/frontend/viewer/src/lib/updates/UpdateDialogContent.svelte @@ -7,7 +7,7 @@ import {getReleaseUrl} from './utils'; type Props = { - checkPromise?: Promise; + checkPromise?: Promise; installPromise?: Promise; installUpdate: (update: IAvailableUpdate) => Promise; installProgress?: number; diff --git a/frontend/viewer/src/project/browse/EntryView.svelte b/frontend/viewer/src/project/browse/EntryView.svelte index 9dac3923d5..0d1fc2e476 100644 --- a/frontend/viewer/src/project/browse/EntryView.svelte +++ b/frontend/viewer/src/project/browse/EntryView.svelte @@ -66,7 +66,7 @@ }, ); - function snapshotEntry(entry: IEntry | null): IEntry | null { + function snapshotEntry(entry: IEntry | undefined): IEntry | undefined { // IMMEDIATELY take a snapshot to ensure it doesn't get mutated by the editor before EntryPersistence gets it. // (dirty fields immediately push their current dirty value into the entry object, which can corrupt the update diff.) latestPersistedSnapshot = entry ? Object.freeze(copy(entry)) : undefined; @@ -76,7 +76,7 @@ // For entry updates that arrive OUTSIDE the resource fetcher (event bus, restore), we must // push the new value into the resource ourselves via mutate(). - function setEntry(entry: IEntry | null): IEntry | null { + function setEntry(entry: IEntry | undefined): IEntry | undefined { snapshotEntry(entry); entryResource.mutate(entry); return entry; diff --git a/frontend/viewer/src/project/demo/in-memory-demo-api.ts b/frontend/viewer/src/project/demo/in-memory-demo-api.ts index 07962c8edb..58e0517757 100644 --- a/frontend/viewer/src/project/demo/in-memory-demo-api.ts +++ b/frontend/viewer/src/project/demo/in-memory-demo-api.ts @@ -76,7 +76,7 @@ export const mockFwLiteConfig: IFwLiteConfig = { }; export const mockUpdateService: IUpdateService = { - checkForUpdates(): Promise { + checkForUpdates(): Promise { return Promise.resolve({ supportsAutoUpdate: true, release: { @@ -92,8 +92,8 @@ export const mockUpdateService: IUpdateService = { }; const mockJsEventListener: IJsEventListener = { - nextEventAsync: () => Promise.resolve(null!), - lastEvent: () => Promise.resolve(null) + nextEventAsync: () => Promise.resolve(undefined!), + lastEvent: () => Promise.resolve(undefined) }; export class InMemoryDemoApi implements IMiniLcmJsInvokable { @@ -239,9 +239,9 @@ export class InMemoryDemoApi implements IMiniLcmJsInvokable { }))); } - getCommentThread(id: string): Promise { + getCommentThread(id: string): Promise { const thread = this._commentThreads.find(thread => thread.id === id && !thread.deletedAt); - return Promise.resolve(thread ? {...thread} : null); + return Promise.resolve(thread ? {...thread} : undefined); } getUserComments(threadId: string): Promise { @@ -250,9 +250,9 @@ export class InMemoryDemoApi implements IMiniLcmJsInvokable { .map(comment => ({...comment}))); } - getUserComment(id: string): Promise { + getUserComment(id: string): Promise { const comment = this._userComments.find(comment => comment.id === id && !comment.deletedAt); - return Promise.resolve(comment ? {...comment} : null); + return Promise.resolve(comment ? {...comment} : undefined); } getUnreadComments(_threadId?: string): Promise { @@ -378,9 +378,9 @@ export class InMemoryDemoApi implements IMiniLcmJsInvokable { return Promise.resolve(JSON.parse(JSON.stringify(this._customViews)) as ICustomView[]); } - getCustomView(id: string): Promise { - const found = this._customViews.find(v => v.id === id) ?? null; - return Promise.resolve(found ? (JSON.parse(JSON.stringify(found)) as ICustomView) : null); + getCustomView(id: string): Promise { + const found = this._customViews.find(v => v.id === id); + return Promise.resolve(found ? (JSON.parse(JSON.stringify(found)) as ICustomView) : undefined); } private _entries = entries; diff --git a/frontend/viewer/src/stories/updates/update-dialog-content.stories.svelte b/frontend/viewer/src/stories/updates/update-dialog-content.stories.svelte index 1d72721045..003335e8fd 100644 --- a/frontend/viewer/src/stories/updates/update-dialog-content.stories.svelte +++ b/frontend/viewer/src/stories/updates/update-dialog-content.stories.svelte @@ -32,7 +32,7 @@ supportsAutoUpdate: false, }; - function pendingCheck(): Promise { + function pendingCheck(): Promise { return new Promise(() => {}); } @@ -40,7 +40,7 @@ return Promise.reject(new DemoStoryError(message)); } - function completedCheck(update: IAvailableUpdate | null): Promise { + function completedCheck(update: IAvailableUpdate | undefined): Promise { return Promise.resolve(update); } @@ -80,7 +80,7 @@ {#snippet template(args)}
- +
{/snippet}