Skip to content

Commit

Permalink
refactored to call hint in element dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
KalliSfak committed Apr 25, 2024
1 parent 42d6ce0 commit d510998
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ import {
import { useBoardFocusHandler } from "@data-board";
import { mdiTextBoxEditOutline } from "@mdi/js";
import { ContentElementBar } from "@ui-board";
import { useBoardNotifier } from "@util-board";
import { useDebounceFn } from "@vueuse/core";
import { PropType, ref, toRef } from "vue";
import { useI18n } from "vue-i18n";
import CollaborativeTextEditorElementMenu from "./components/CollaborativeTextEditorElementMenu.vue";
import { useCollaborativeTextEditorApi } from "./composables/CollaborativeTextEditorApi.composable";
Expand Down Expand Up @@ -100,20 +97,4 @@ const onDelete = async (confirmation: Promise<boolean>) => {
const onMoveUp = () => emit("move-up:edit");
const onMoveDown = () => emit("move-down:edit");
const { showCustomNotifier } = useBoardNotifier();
const { t } = useI18n();
const setAlert = useDebounceFn(() => {
showCustomNotifier(
t(
"components.cardElement.collaborativeTextEditorElement.alert.info.visible"
),
"info"
);
}, 100);
const tenSeconsAgo = Date.now() - 10 * 1000;
if (new Date(element.value.timestamps.createdAt).getTime() > tenSeconsAgo) {
setAlert();
}
</script>
19 changes: 18 additions & 1 deletion src/modules/feature/board/shared/AddElementDialog.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
mdiTextBoxEditOutline,
mdiTrayArrowUp,
} from "@mdi/js";
import { useSharedLastCreatedElement } from "@util-board";
import { useBoardNotifier, useSharedLastCreatedElement } from "@util-board";
import { useI18n } from "vue-i18n";
import { useSharedElementTypeSelection } from "./SharedElementTypeSelection.composable";

type AddCardElement = (
Expand All @@ -20,6 +21,8 @@ type AddCardElement = (
export const useAddElementDialog = (addElementFunction: AddCardElement) => {
const envConfigModule = injectStrict(ENV_CONFIG_MODULE_KEY);
const { lastCreatedElementId } = useSharedLastCreatedElement();
const { showCustomNotifier } = useBoardNotifier();
const { t } = useI18n();

const { isDialogOpen, closeDialog, elementTypeOptions } =
useSharedElementTypeSelection();
Expand All @@ -29,6 +32,20 @@ export const useAddElementDialog = (addElementFunction: AddCardElement) => {

const elementData = await addElementFunction(elementType);
lastCreatedElementId.value = elementData?.id;
showCollaborativeTextEditorNotification(elementType);
};

const showCollaborativeTextEditorNotification = (
elementType: ContentElementType
) => {
if (elementType === ContentElementType.CollaborativeTextEditor) {
showCustomNotifier(
t(
"components.cardElement.collaborativeTextEditorElement.alert.info.visible"
),
"info"
);
}
};

const options = [
Expand Down

0 comments on commit d510998

Please sign in to comment.