Skip to content

Commit

Permalink
chore(build): eslint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
neSpecc committed Oct 16, 2023
1 parent f0a0a2e commit 3a127ce
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 74 deletions.
26 changes: 15 additions & 11 deletions src/application/services/useLayout.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
import { shallowRef, type ShallowRef } from 'vue';
import { useRouter } from 'vue-router';
import { shallowRef, type ShallowRef, type Component } from 'vue';
import { useRoute } from 'vue-router';
import Default from '@/presentation/layouts/Default.vue';

const layouts = {
Default,
/**
* Layouts available in application.
*
* Layout — is page wrapper. You can use it to create different layouts for different pages, e.g.: multiple sidebars, etc.
*/
export const layouts = {
default: Default,
};

/**
* useLayout hook is setting current Layout
*
* @returns { ShallowRef<string> } - Layout template was got by meta
*/
export default function (): ShallowRef<string> {
const layout = shallowRef('div');
const router = useRouter();

export default function (): ShallowRef<Component> {
const layout = shallowRef(layouts.default);
const route = useRoute();

router.beforeEach((to) => {
layout.value = layouts[to.meta.layout] || Default;
});
if (route.meta.layout !== undefined) {
layout.value = layouts[route.meta.layout];
}

return layout;
}
Expand Down
9 changes: 4 additions & 5 deletions src/domain/note.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ export default class NoteService {
}

/**
* Get note
* Returns a note by its id
*
* @param publicId - Note publicId
* @returns Note data
* @param id - Note id
* @throws NotFoundError
*/
public async getNoteById(publicId: string): Promise<Note> {
return await this.noteRepository.getNoteById(publicId);
public async getNoteById(id: string): Promise<Note> {
return await this.noteRepository.getNoteById(id);
}

/**
Expand Down
56 changes: 2 additions & 54 deletions src/infrastructure/note.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,9 @@ export default class NoteRepository implements NoteRepositoryInterface {
* Get note by id
*
* @param id - Note identifier
* @returns Note instance
* @throws NotFoundError
*/
public async getNoteById(id: string): Promise<Note> {
const noteData = await this.noteStorage.getNoteById(id);

/**
* If note data in storage exists
*/
if (noteData !== null) {
return noteData;
}

/**
* Get note data from API
*/
Expand All @@ -60,31 +50,10 @@ export default class NoteRepository implements NoteRepositoryInterface {
* @returns { Note | null } - Note instance
*/
public async getNoteByHostname(hostname: string): Promise<Note | null> {
const noteData = await this.noteStorage.getNoteByHostname(hostname);

/**
* If note data in storage exists
*/
if (noteData) {
return noteData;
}

/**
* Get note data from API
*/
const note = await this.transport.get<GetNoteResponsePayload>('/note/resolve-hostname/' + encodeURIComponent(hostname));

/**
* If note data in API payload exists
*/
if (note) {
/**
* Insert note to storage
*/
await this.noteStorage.insertNote(note);
}

return note;
return await this.transport.get<GetNoteResponsePayload>('/note/resolve-hostname/' + encodeURIComponent(hostname));
}

/**
Expand All @@ -94,31 +63,10 @@ export default class NoteRepository implements NoteRepositoryInterface {
* @returns { NotesSettings | null } - NotesSettings instance
*/
public async getNotesSettingsById(publicId: string): Promise<NotesSettings | null> {
const notesSettingsData = await this.noteStorage.getNotesSettingsById(publicId);

/**
* If notesSettings data in storage exists
*/
if (notesSettingsData) {
return notesSettingsData;
}

/**
* Get notesSettingsData data from API
*/
const notesSettings = await this.transport.get<GetNotesSettingsResponsePayload>('/note/' + publicId + '/settings');

/**
* If note data in API payload exists
*/
if (notesSettings) {
/**
* Insert note to storage
*/
await this.noteStorage.updateNotesSettings(notesSettings);
}

return notesSettings;
return await this.transport.get<GetNotesSettingsResponsePayload>('/note/' + publicId + '/settings');
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/infrastructure/transport/notes-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default class NotesApiTransport extends AuthorizableTransport {
*
* @param status - HTTP status
* @param payload - Response JSON payload
* @param endpoint - API endpoint we requested
*/
errorFormatter(status, payload) {
const { message, code } = (payload as ApiErrorResponse);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type Note from '@/domain/entities/Note';
import type { Note } from '@/domain/entities/Note';
import type NotesSettings from '@/domain/entities/NotesSettings';

/**
Expand Down
6 changes: 4 additions & 2 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ export {};

declare module '*.vue'

import type { layouts } from '@/application/services/useLayout';

declare module 'vue-router' {
interface RouteMeta {
/**
* Layout like component wrapper
*/
layout?: string
layout?: keyof typeof layouts;
}
}
}

0 comments on commit 3a127ce

Please sign in to comment.