From 4255a90d2edf4c571bf5a378210fc916478cbda2 Mon Sep 17 00:00:00 2001 From: "smx.pusha" <139338836+smxpusha@users.noreply.github.com> Date: Wed, 12 Aug 2026 08:25:36 +0200 Subject: [PATCH] FIX - suggest compatible EasyShare destinations --- frontend/src/components/EasyShareSheet.vue | 23 ++++++------ frontend/src/types/easyshare.ts | 1 + frontend/src/utils/easyshare.test.ts | 43 +++++++++++++++++++++- frontend/src/utils/easyshare.ts | 29 ++++++++++++++- 4 files changed, 83 insertions(+), 13 deletions(-) diff --git a/frontend/src/components/EasyShareSheet.vue b/frontend/src/components/EasyShareSheet.vue index f316806..1d24ad2 100644 --- a/frontend/src/components/EasyShareSheet.vue +++ b/frontend/src/components/EasyShareSheet.vue @@ -24,10 +24,14 @@ import { useNotesStore } from '@/stores/notes' import { usePhoneStore } from '@/stores/phone' import type { EasyShareChatApp, + EasyShareDestinationApp, EasyShareTransfer, EasyShareVisibility, } from '@/types/easyshare' -import { openEasySharePayload } from '@/utils/easyshare' +import { + easyShareDestinationAppIds, + openEasySharePayload, +} from '@/utils/easyshare' const phone = usePhoneStore() const appStore = useAppStoreStore() @@ -45,7 +49,6 @@ let dragPointerId: number | null = null let dragStartTime = 0 let dragStartY = 0 const visibilityOptions: EasyShareVisibility[] = ['everyone', 'contacts', 'hidden'] -type EasyShareDestinationAppId = 'darkchat' | 'flare' | 'messages' | 'notes' const app = computed(() => easyShare.payload ? getPhoneApp(easyShare.payload.appId) : undefined, ) @@ -105,14 +108,8 @@ const sharePeople = computed(() => { return people }) -const shareAppIds: EasyShareDestinationAppId[] = [ - 'messages', - 'darkchat', - 'flare', - 'notes', -] const shareApps = computed(() => - shareAppIds + (easyShare.payload ? easyShareDestinationAppIds(easyShare.payload) : []) .filter((id) => !appStore.homeLayout.hidden.includes(id)) .flatMap((id) => { const app = getPhoneApp(id) @@ -201,7 +198,7 @@ function openChatApp(kind: EasyShareChatApp): void { void router.push(`/apps/${kind}`) } -function openShareApp(appId: EasyShareDestinationAppId): void { +function openShareApp(appId: EasyShareDestinationApp): void { if (appId === 'messages' || appId === 'darkchat' || appId === 'flare') { openChatApp(appId) return @@ -211,8 +208,12 @@ function openShareApp(appId: EasyShareDestinationAppId): void { function saveAsNote(): void { if (!easyShare.payload) return + const body = [easyShare.payload.copyText.trim(), easyShare.payload.link?.trim()] + .filter((part): part is string => Boolean(part)) + .filter((part, index, parts) => parts.indexOf(part) === index) + .join('\n') notes.createNote({ - body: easyShare.payload.copyText, + body, title: easyShare.payload.title, }) feedback.value = label('savedToNotes') diff --git a/frontend/src/types/easyshare.ts b/frontend/src/types/easyshare.ts index 368883c..8b9665d 100644 --- a/frontend/src/types/easyshare.ts +++ b/frontend/src/types/easyshare.ts @@ -16,6 +16,7 @@ export type EasyShareKind = export type EasyShareVisibility = 'contacts' | 'everyone' | 'hidden' export type EasyShareChatApp = 'darkchat' | 'flare' | 'messages' +export type EasyShareDestinationApp = EasyShareChatApp | 'notes' export type EasyShareChatDraft = { appId: EasyShareChatApp body: string diff --git a/frontend/src/utils/easyshare.test.ts b/frontend/src/utils/easyshare.test.ts index f3fc67c..37fc749 100644 --- a/frontend/src/utils/easyshare.test.ts +++ b/frontend/src/utils/easyshare.test.ts @@ -1,7 +1,10 @@ import { describe, expect, it } from 'vitest' import type { EasySharePayload } from '@/types/easyshare' -import { easyShareRoute } from '@/utils/easyshare' +import { + easyShareDestinationAppIds, + easyShareRoute, +} from '@/utils/easyshare' function payload(overrides: Partial): EasySharePayload { return { @@ -72,3 +75,41 @@ describe('EasyShare deep links', () => { }) }) }) + +describe('EasyShare destination suggestions', () => { + it.each([ + 'document', + 'link', + 'location', + 'note', + 'text', + ] as const)('offers Notes for %s content from another app', (kind) => { + expect( + easyShareDestinationAppIds(payload({ appId: 'calendar', kind })), + ).toEqual(['messages', 'darkchat', 'flare', 'notes']) + }) + + it.each([ + 'contact', + 'photo', + 'playlist', + 'post', + 'profile', + 'track', + 'video', + ] as const)('does not suggest lossy Notes conversion for %s content', (kind) => { + expect(easyShareDestinationAppIds(payload({ kind }))).toEqual([ + 'messages', + 'darkchat', + 'flare', + ]) + }) + + it('does not suggest saving a Notes item back into Notes', () => { + expect(easyShareDestinationAppIds(payload({}))).toEqual([ + 'messages', + 'darkchat', + 'flare', + ]) + }) +}) diff --git a/frontend/src/utils/easyshare.ts b/frontend/src/utils/easyshare.ts index 44f4fad..059572a 100644 --- a/frontend/src/utils/easyshare.ts +++ b/frontend/src/utils/easyshare.ts @@ -1,7 +1,24 @@ import type { Router } from 'vue-router' import { getPhoneApp } from '@/config/apps' -import type { EasySharePayload } from '@/types/easyshare' +import type { + EasyShareDestinationApp, + EasyShareKind, + EasySharePayload, +} from '@/types/easyshare' + +const chatDestinations: EasyShareDestinationApp[] = [ + 'messages', + 'darkchat', + 'flare', +] +const noteCompatibleKinds = new Set([ + 'document', + 'link', + 'location', + 'note', + 'text', +]) const schemeRoutes: Record = { location: '/apps/map', @@ -9,6 +26,16 @@ const schemeRoutes: Record = { phone: '/apps/phone', } +export function easyShareDestinationAppIds( + payload: EasySharePayload, +): EasyShareDestinationApp[] { + const destinations = [...chatDestinations] + if (payload.appId !== 'notes' && noteCompatibleKinds.has(payload.kind)) { + destinations.push('notes') + } + return destinations +} + export function easyShareRoute(payload: EasySharePayload): { path: string query: Record