mirror of
https://github.com/sky-systems/sky_phone.git
synced 2026-09-04 09:13:24 +00:00
FIX - suggest compatible EasyShare destinations
This commit is contained in:
@@ -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>): 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',
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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<EasyShareKind>([
|
||||
'document',
|
||||
'link',
|
||||
'location',
|
||||
'note',
|
||||
'text',
|
||||
])
|
||||
|
||||
const schemeRoutes: Record<string, string> = {
|
||||
location: '/apps/map',
|
||||
@@ -9,6 +26,16 @@ const schemeRoutes: Record<string, string> = {
|
||||
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<string, string>
|
||||
|
||||
Reference in New Issue
Block a user