Created
November 16, 2020 20:17
-
-
Save jasonLaster/1790cbd61b9c0a6e7704c6818cc91b9b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/dispatch/internal.js b/src/dispatch/internal.js | |
| index a09fc7bb..e3c3a87a 100644 | |
| --- a/src/dispatch/internal.js | |
| +++ b/src/dispatch/internal.js | |
| @@ -18,12 +18,48 @@ async function fetchGraphQL(query, name, variables = {}) { | |
| return await result.json(); | |
| } | |
| +async function fetchUserId(authId) { | |
| + const query = `query fetchUserId($auth_id: String) { | |
| + userIds(where: {auth_id: { _eq: $auth_id } }, limit: 1) { | |
| + id | |
| + } | |
| + } | |
| + `; | |
| + let response = await fetchGraphQL(query, "fetchUserId", { auth_id: authId }); | |
| + return response.userIds[0]; | |
| +} | |
| + | |
| const InternalMessageHandlers = { | |
| "Internal.echo": async function ({ str, count }) { | |
| const newStr = str.repeat(count); | |
| return { str: newStr }; | |
| }, | |
| + "Internal.saveRecording": async ({ recordingData, authId }) => { | |
| + const userId = await fetchUserId(authId); | |
| + | |
| + const name = `SaveRecording`; | |
| + const query = ` | |
| + mutation SaveRecording($data: recordings_insert_input!) { | |
| + insert_recordings_one(object: $data) { | |
| + id | |
| + recording_id | |
| + last_screen_data | |
| + last_screen_mime_type | |
| + duration | |
| + title | |
| + url | |
| + user_id | |
| + } | |
| + } | |
| + `; | |
| + | |
| + let response = await fetchGraphQL(query, name, { | |
| + data: { ...recordingData, user_id: userId }, | |
| + }); | |
| + return { recordings: response.data.insert_recordings_one }; | |
| + }, | |
| + | |
| "Internal.getRecordings": async function ({ authId }) { | |
| const name = `GetRecordings`; | |
| const query = ` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment