-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added stub use cases for loading avatar config
- Loading branch information
1 parent
b3aa976
commit bf847dd
Showing
10 changed files
with
77 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/Components/Core/Application/Ports/AvatarPort/IAvatarAdapter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
src/Components/Core/Application/UseCases/LoadAvatar/ILoadAvatarUseCase.ts
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
src/Components/Core/Application/UseCases/LoadAvatar/LoadAvatarUseCase.ts
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
src/Components/Core/Application/UseCases/LoadAvatarConfig/ILoadAvatarConfigUseCase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { IAsyncUsecase } from "../../Abstract/IAsyncUsecase"; | ||
export default interface ILoadAvatarConfigUseCase | ||
extends IAsyncUsecase<void, void> {} |
45 changes: 45 additions & 0 deletions
45
src/Components/Core/Application/UseCases/LoadAvatarConfig/LoadAvatarConfigUseCase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { inject, injectable } from "inversify"; | ||
import PORT_TYPES from "../../../DependencyInjection/Ports/PORT_TYPES"; | ||
import type IAvatarPort from "../../Ports/Interfaces/IAvatarPort"; | ||
import ILoadAvatarConfigUseCase from "./ILoadAvatarConfigUseCase"; | ||
import CORE_TYPES from "~DependencyInjection/CoreTypes"; | ||
import type ILoggerPort from "../../Ports/Interfaces/ILoggerPort"; | ||
import { LogLevelTypes } from "../../../Domain/Types/LogLevelTypes"; | ||
import type IEntityContainer from "../../../Domain/EntityContainer/IEntityContainer"; | ||
import UserDataEntity from "../../../Domain/Entities/UserDataEntity"; | ||
import type IBackendPort from "../../Ports/Interfaces/IBackendPort"; | ||
import AvatarEntity from "src/Components/Core/Domain/Entities/AvatarEntity"; | ||
|
||
@injectable() | ||
export default class LoadAvatarConfigUseCase | ||
implements ILoadAvatarConfigUseCase | ||
{ | ||
constructor( | ||
@inject(CORE_TYPES.ILogger) private logger: ILoggerPort, | ||
@inject(PORT_TYPES.IAvatarPort) private avatarPort: IAvatarPort, | ||
@inject(CORE_TYPES.IEntityContainer) | ||
private entityContainer: IEntityContainer, | ||
@inject(CORE_TYPES.IBackendAdapter) | ||
private backend: IBackendPort, | ||
) {} | ||
|
||
async executeAsync(): Promise<void> { | ||
let userDataEntities = | ||
this.entityContainer.getEntitiesOfType(UserDataEntity); | ||
if (userDataEntities.length === 0) { | ||
this.logger.log(LogLevelTypes.ERROR, "No user data entity found"); | ||
return; | ||
} else if (userDataEntities.length > 1) { | ||
this.logger.log(LogLevelTypes.ERROR, "Multiple user data entities found"); | ||
return; | ||
} | ||
|
||
// TODO: actually load avatar config from backend | ||
if (!userDataEntities[0].avatar) { | ||
userDataEntities[0].avatar = new AvatarEntity(); | ||
// let avatarConfig = await this.backend.loadAvatarConfigAsync(); | ||
} | ||
|
||
this.avatarPort.onAvatarConfigLoaded(userDataEntities[0].avatar); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters