/
insert-prompt-result-to-deep.ts
37 lines (36 loc) · 1.19 KB
/
insert-prompt-result-to-deep.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { PromptResult } from "@capacitor/dialog";
import { DeepClient } from "@deep-foundation/deeplinks/imports/client";
import { DIALOG_PACKAGE_NAME } from "./package-name";
export async function insertPromptResultToDeep({ deep, deviceLinkId, notifyLinkId, promptResult }: { deep: DeepClient, deviceLinkId: number, notifyLinkId: number, promptResult: PromptResult }) {
const promptValueTypeLinkdId = await deep.id(DIALOG_PACKAGE_NAME, "PromptValue");
const containTypeLinkId = await deep.id("@deep-foundation/core", "Contain");
await deep.insert([
{
type_id: promptValueTypeLinkdId,
from_id: deviceLinkId,
to_id: notifyLinkId,
string: {
data: {
value: promptResult.value
}
},
in: {
data: {
type_id: containTypeLinkId,
from_id: deep.linkId,
}
}
},
{
type_id: promptResult.cancelled ? await deep.id(DIALOG_PACKAGE_NAME, "PromptIsCancelled") : await deep.id(DIALOG_PACKAGE_NAME, "PromptIsNotCancelled"),
from_id: deviceLinkId,
to_id: notifyLinkId,
in: {
data: {
type_id: containTypeLinkId,
from_id: deep.linkId
}
}
}
])
}