Skip to content

Commit

Permalink
fix: returned previous naming
Browse files Browse the repository at this point in the history
  • Loading branch information
medvalna committed Nov 19, 2023
1 parent 664471f commit a834470
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
11 changes: 5 additions & 6 deletions src/application/services/useAppState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ interface UseAppStateComposable {
/**
* User editor tools that are used in notes creation
*/
editorTools: Ref<EditorTool[]>

userEditorTools: Ref<EditorTool[]>
}

/**
Expand All @@ -32,22 +31,22 @@ export const useAppState = createSharedComposable((): UseAppStateComposable => {
/**
* User editor tools that are used in notes creation
*/
const editorTools = ref<EditorTool[]>([]);
const userEditorTools = ref<EditorTool[]>([]);

/**
* Subscribe to user changes in the App State
*/
AppStateController.user((prop: 'user' | 'editorTools', value: User | EditorTool[] | null) => {
AppStateController.user((prop: 'user' | 'editorTools', value: User | EditorTool[] | null) => {
if (prop === 'user') {
user.value = value as User;
}
if (prop === 'editorTools') {
editorTools.value = value as EditorTool[];
userEditorTools.value = value as EditorTool[];
}
});

return {
user,
editorTools,
userEditorTools,
};
});
12 changes: 6 additions & 6 deletions src/presentation/components/editor/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import EditorTool from '@/domain/entities/EditorTool';
import { useAppState } from '@/application/services/useAppState';
const { editorTools } = useAppState();
const { userEditorTools } = useAppState();
/**
Expand Down Expand Up @@ -132,15 +132,15 @@ const mountEditorOnce = async () => {
console.log('mount');
isEditorMounted.value = true;
Promise.allSettled(editorTools.value.map((spec: EditorTool) => {
Promise.allSettled(userEditorTools.value.map((spec: EditorTool) => {
if (!spec.source.cdn) {
return;
}
return loadScript(spec.source.cdn);
})).then(async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const loadedTools: {[key: string]: any } = editorTools.value.reduce(
const loadedTools: {[key: string]: any } = userEditorTools.value.reduce(
(acc, spec: EditorTool) => {
// @ts-expect-error: we need to rewrite plugins to TS to get their types
const windowPlugin = window[spec.exportName];
Expand Down Expand Up @@ -193,10 +193,10 @@ const mountEditorOnce = async () => {
});
};
watch(editorTools, mountEditorOnce);
watch(userEditorTools, mountEditorOnce);
onMounted(() => {
console.log('mount', editorTools.value);
if (editorTools.value.length > 0) {
console.log('mount', userEditorTools.value);
if (userEditorTools.value.length > 0) {
mountEditorOnce();
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/presentation/pages/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<h1>{{ t("settings.title") }}</h1>
<h2>{{ t("settings.userEditorTools") }}:</h2>
<ul
v-for="tool in editorTools"
v-for="tool in userEditorTools"
:key="tool.id"
>
<li>
Expand Down Expand Up @@ -31,7 +31,7 @@ import ThemeButton from '@/presentation/components/theme/ThemeButton.vue';
import { useAppState } from '@/application/services/useAppState';
import { useUserSettings } from '@/application/services/useUserSettings';
const { editorTools } = useAppState();
const { userEditorTools } = useAppState();
const { t } = useI18n();
const { addTool: addToolToUser } = useUserSettings();
Expand Down

0 comments on commit a834470

Please sign in to comment.