Skip to content

Commit c48eadb

Browse files
authored
Fix after test (#412)
* fix(frontend): clear draft after navigation completes When creating a conversation with seed opinions and clicking "Publier", the review page briefly flashed showing empty fields before unmounting. This occurred because the draft was being cleared before the component unmounted, causing a reactive re-render of the form with empty values. Previous fix (PR #411) kept the loading state active during navigation but still cleared the draft in the review page before navigation completed. Changes: - Remove draft clearing from review page (services/agora/src/pages/conversation/new/review/index.vue was already fixed in PR #411) - Add draft clearing to conversation page onMounted lifecycle - Check cameFromConversationCreation flag to only clear after successful creation - Use resetDraft() store method for proper cleanup Flow: 1. User clicks "Publier" - loading state activates, draft data intact 2. Navigation starts - review page stays rendered with data 3. Review page unmounts - no re-render because draft wasn't cleared 4. Conversation page mounts and renders 5. Conversation page onMounted checks flag and silently clears draft 6. Draft is now empty for next conversation creation This ensures the review page maintains its visual state during unmount, preventing any flash of empty form fields during the transition. * fix(frontend): translate "copied to clipboard" notifications The "Copied link to clipboard" notification was hardcoded in English in both PostDetails.vue and WebShare.ts. This change adds proper i18n support to ensure all clipboard copy notifications are translated across all 7 supported languages. Changes: - Created PostDetails.i18n.ts with copiedToClipboard translations - Updated PostDetails.vue to use translated notification in copyLinkCallback - Created WebShare.i18n.ts with copiedToClipboard translations - Updated WebShare.ts to use translated notification in fallback path - Removed Platform.is.mobile check from WebShare to support Web Share API on all browsers where available Now all "Copied link to clipboard" messages in the share flow are properly translated and will display in the user's selected language.
1 parent 762628a commit c48eadb

5 files changed

Lines changed: 99 additions & 6 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Internationalization translations for PostDetails component
3+
* Supports all languages configured in the application
4+
*/
5+
6+
import type { SupportedDisplayLanguageCodes } from "src/shared/languages";
7+
8+
export interface PostDetailsTranslations {
9+
copiedToClipboard: string;
10+
}
11+
12+
export const postDetailsTranslations: Record<
13+
SupportedDisplayLanguageCodes,
14+
PostDetailsTranslations
15+
> = {
16+
en: {
17+
copiedToClipboard: "Copied link to clipboard",
18+
},
19+
ar: {
20+
copiedToClipboard: "تم نسخ الرابط إلى الحافظة",
21+
},
22+
es: {
23+
copiedToClipboard: "Enlace copiado al portapapeles",
24+
},
25+
fr: {
26+
copiedToClipboard: "Lien copié dans le presse-papiers",
27+
},
28+
"zh-Hans": {
29+
copiedToClipboard: "已复制链接到剪贴板",
30+
},
31+
"zh-Hant": {
32+
copiedToClipboard: "已複製連結到剪貼簿",
33+
},
34+
ja: {
35+
copiedToClipboard: "リンクをクリップボードにコピーしました",
36+
},
37+
};

services/agora/src/components/post/PostDetails.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ import { storeToRefs } from "pinia";
110110
import { useUserStore } from "src/stores/user";
111111
import { useShareActions } from "src/composables/share/useShareActions";
112112
import { useNotify } from "src/utils/ui/notify";
113+
import { useComponentI18n } from "src/composables/ui/useComponentI18n";
114+
import {
115+
postDetailsTranslations,
116+
type PostDetailsTranslations,
117+
} from "./PostDetails.i18n";
113118
114119
const props = defineProps<{
115120
conversationData: ExtendedConversation;
@@ -129,6 +134,7 @@ const { invalidateAnalysis, forceRefreshAnalysis } =
129134
useInvalidateCommentQueries();
130135
const shareActions = useShareActions();
131136
const notify = useNotify();
137+
const { t } = useComponentI18n<PostDetailsTranslations>(postDetailsTranslations);
132138
133139
const participantCountLocal = ref(
134140
props.conversationData.metadata.participantCount
@@ -234,7 +240,7 @@ function shareClicked(): void {
234240
targetAuthor: props.conversationData.metadata.authorUsername,
235241
copyLinkCallback: async () => {
236242
await copyToClipboard(sharePostUrl);
237-
notify.showNotifyMessage("Copied link to clipboard");
243+
notify.showNotifyMessage(t("copiedToClipboard"));
238244
},
239245
openQrCodeCallback: () => {
240246
$q.dialog({

services/agora/src/pages/conversation/[postSlugId].vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ import WidthWrapper from "src/components/navigation/WidthWrapper.vue";
3131
import DrawerLayout from "src/layouts/DrawerLayout.vue";
3232
import PostDetails from "src/components/post/PostDetails.vue";
3333
import { useConversationData } from "src/composables/conversation/useConversationData";
34-
import { ref, onBeforeUnmount } from "vue";
34+
import { ref, onBeforeUnmount, onMounted } from "vue";
3535
import { useNavigationStore } from "src/stores/navigation";
36+
import { useNewPostDraftsStore } from "src/stores/newConversationDrafts";
3637
3738
const postDetailsRef = ref<InstanceType<typeof PostDetails>>();
3839
const { conversationData, hasConversationData, refreshConversation } =
3940
useConversationData();
4041
const navigationStore = useNavigationStore();
42+
const { resetDraft } = useNewPostDraftsStore();
4143
4244
function handleRefresh(done: () => void): void {
4345
refreshConversation(() => {
@@ -49,6 +51,13 @@ function handleRefresh(done: () => void): void {
4951
});
5052
}
5153
54+
// Clear draft only after successfully navigating from conversation creation
55+
onMounted(() => {
56+
if (navigationStore.cameFromConversationCreation) {
57+
resetDraft();
58+
}
59+
});
60+
5261
// Clear conversation creation context when leaving this page
5362
onBeforeUnmount(() => {
5463
navigationStore.clearConversationCreationContext();
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Internationalization translations for WebShare utility
3+
* Supports all languages configured in the application
4+
*/
5+
6+
import type { SupportedDisplayLanguageCodes } from "src/shared/languages";
7+
8+
export interface WebShareTranslations {
9+
copiedToClipboard: string;
10+
}
11+
12+
export const webShareTranslations: Record<
13+
SupportedDisplayLanguageCodes,
14+
WebShareTranslations
15+
> = {
16+
en: {
17+
copiedToClipboard: "Copied link to clipboard",
18+
},
19+
ar: {
20+
copiedToClipboard: "تم نسخ الرابط إلى الحافظة",
21+
},
22+
es: {
23+
copiedToClipboard: "Enlace copiado al portapapeles",
24+
},
25+
fr: {
26+
copiedToClipboard: "Lien copié dans le presse-papiers",
27+
},
28+
"zh-Hans": {
29+
copiedToClipboard: "已复制链接到剪贴板",
30+
},
31+
"zh-Hant": {
32+
copiedToClipboard: "已複製連結到剪貼簿",
33+
},
34+
ja: {
35+
copiedToClipboard: "リンクをクリップボードにコピーしました",
36+
},
37+
};

services/agora/src/utils/share/WebShare.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import { useShare } from "@vueuse/core";
2-
import { Platform } from "quasar";
32
import { useClipboard } from "@vueuse/core";
43
import { useDialog } from "../ui/dialog";
54
import { useNotify } from "../ui/notify";
5+
import { useComponentI18n } from "src/composables/ui/useComponentI18n";
6+
import {
7+
webShareTranslations,
8+
type WebShareTranslations,
9+
} from "./WebShare.i18n";
610

711
export function useWebShare() {
812
const webShare = useShare();
913
const clipBoard = useClipboard();
1014
const dialog = useDialog();
1115
const notify = useNotify();
16+
const { t } = useComponentI18n<WebShareTranslations>(webShareTranslations);
1217

1318
function isSupportedSharePlatform() {
14-
// Ignore desktop browsers
15-
if (webShare.isSupported && Platform.is.mobile) {
19+
if (webShare.isSupported) {
1620
return true;
1721
} else {
1822
console.log("Not a supported web share platform");
@@ -30,7 +34,7 @@ export function useWebShare() {
3034
} else {
3135
if (clipBoard.isSupported) {
3236
await clipBoard.copy(url);
33-
notify.showNotifyMessage("Copied link to clipboard");
37+
notify.showNotifyMessage(t("copiedToClipboard"));
3438
} else {
3539
console.log("Clipboard is not supported");
3640
dialog.showMessage("Share Link", url);

0 commit comments

Comments
 (0)