Skip to content

Commit

Permalink
Merge pull request #55 from codex-team/fix/app-state-types
Browse files Browse the repository at this point in the history
fix(build): pull fixes to main
  • Loading branch information
neSpecc authored Oct 18, 2023
2 parents c069fd8 + 00583b5 commit cf6b47f
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/domain/auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type AuthRepository from '@/domain/auth.repository.interface';
import type EventBus from '@/domain/event-bus';
import AuthCompletedEvent from './event-bus/events/AuthCompleted';
import { AuthCompletedEvent } from './event-bus/events/AuthCompleted';
import UnauthorizedError from './entities/errors/Unauthorized';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/domain/event-bus/events/AuthCompleted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const AUTH_COMPLETED_EVENT_NAME = 'auth-completed';
/**
* Use cross domain events to explicitly implement side effects of changes within of a domain
*/
export default class AuthCompletedEvent extends CustomEvent<AuthSession> {
export class AuthCompletedEvent extends CustomEvent<AuthSession> {
/**
* Constructor options
*
Expand Down
18 changes: 18 additions & 0 deletions src/domain/event-bus/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
import type { AUTH_COMPLETED_EVENT_NAME, AuthCompletedEvent } from './events/AuthCompleted';

/**
* Event Bus provides a loosely coupled communication way between Domain and some other layers
*
* Extends native event emitter called EventTarget
*/
export default class EventBus extends EventTarget {};

/**
* All cross domain events map
*/
export type CrossDomainEventMap = {
[AUTH_COMPLETED_EVENT_NAME]: AuthCompletedEvent;
};

/**
* Augment EventTarget's addEventListener method to accept CustomEvent
*/
declare global {
interface EventTarget {
addEventListener<T extends keyof CrossDomainEventMap>(type: T, listener: (event: CrossDomainEventMap[T]) => void): void;
}
}
3 changes: 1 addition & 2 deletions src/infrastructure/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import AuthStore from '@/infrastructure/storage/auth';
import UserRepository from '@/infrastructure/user.repository';
import { UserStore } from '@/infrastructure/storage/user';
import type EventBus from '@/domain/event-bus';
import type AuthCompletedEvent from '@/domain/event-bus/events/AuthCompleted';
import { AUTH_COMPLETED_EVENT_NAME } from '@/domain/event-bus/events/AuthCompleted';
import { AUTH_COMPLETED_EVENT_NAME, type AuthCompletedEvent } from '@/domain/event-bus/events/AuthCompleted';

/**
* Repositories
Expand Down
14 changes: 13 additions & 1 deletion src/presentation/components/editor/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,31 @@
import { onBeforeUnmount, onMounted, ref, watch } from 'vue';
import Editor, { type OutputData, type API } from '@editorjs/editorjs';
// @ts-expect-error: we need to rewrite plugins to TS to get their types
import Header from '@editorjs/header';
// @ts-expect-error: we need to rewrite plugins to TS to get their types
import Image from '@editorjs/image';
// @ts-expect-error: we need to rewrite plugins to TS to get their types
import CodeTool from '@editorjs/code';
// @ts-expect-error: we need to rewrite plugins to TS to get their types
import List from '@editorjs/list';
// @ts-expect-error: we need to rewrite plugins to TS to get their types
import Delimiter from '@editorjs/delimiter';
// @ts-expect-error: we need to rewrite plugins to TS to get their types
import Table from '@editorjs/table';
// @ts-expect-error: we need to rewrite plugins to TS to get their types
import Warning from '@editorjs/warning';
// @ts-expect-error: we need to rewrite plugins to TS to get their types
import Checklist from '@editorjs/checklist';
// @ts-expect-error: we need to rewrite plugins to TS to get their types
import LinkTool from '@editorjs/link';
// @ts-expect-error: we need to rewrite plugins to TS to get their types
import RawTool from '@editorjs/raw';
// @ts-expect-error: we need to rewrite plugins to TS to get their types
import Embed from '@editorjs/embed';
// @ts-expect-error: we need to rewrite plugins to TS to get their types
import InlineCode from '@editorjs/inline-code';
// @ts-expect-error: we need to rewrite plugins to TS to get their types
import Marker from '@editorjs/marker';
Expand Down
18 changes: 12 additions & 6 deletions src/presentation/pages/Landing.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
<template>
<div>
<div v-if="note">
<!-- <div v-if="note">
<Editor :data="note.content" />
</div>
<div v-else-if="isLoading">
Loading...
</div>
<div v-else>
Note not found
</div>
</div> -->
</div>
</template>

<script setup lang="ts">
import Editor from '@/presentation/components/editor/Editor.vue';
import useNote from '@/application/services/useNote';
// import Editor from '@/presentation/components/editor/Editor.vue';
// import useNote from '@/application/services/useNote';
const { note, resolveHostname, isLoading } = useNote();
/**
* @todo re-implement fetching note by hostname
* 1. Probably, it should use the same Note.vue component instead of Landing.vue
* 2. Probably, useNote() should accept not only id but also hostname as a parameter
* 3. Probably, you'll need to change onMounted() hook inside useNote() to make it work with the hostname as well
*/
// const { note, resolveHostname, isLoading } = useNote();
resolveHostname();
// resolveHostname();
</script>

<style lang="postcss" scoped>
Expand Down

0 comments on commit cf6b47f

Please sign in to comment.