@prifina/messaging
Advanced tools
Comparing version 0.0.14 to 0.0.15
@@ -27,3 +27,6 @@ 'use strict'; | ||
}]; | ||
var createMessageMutation = "mutation newMessage($input:MessageInput!) {\n createMessage(input: $input) {\n messageId\n receiver\n sender\n role\n createdAt\n body\n }\n }"; | ||
var unreadMsgsQuery = "query unreadMsgs($input:DataObjectInput!) {\n getUnreadMsgs(input:$input) {\n result\n }\n}"; | ||
var getMsgsQuery = "query getMsgs($input:DataObjectInput!) {\n getMsgs(input:$input) {\n result\n }\n}"; | ||
var getAddressBookQuery = "query getAddressBook($input:DataObjectInput!) {\n getAddressBook(input:$input) {\n result\n }\n}"; | ||
var createMessageMutation = "mutation newMessage($input:MessageInput!) {\n createMessage(input: $input) {\n messageId\n receiver\n chatId\n sender\n createdAt\n body\n }\n }"; | ||
var updateMessageStatusMutation = "mutation updateMessage($input:MessageInput!) {\n createMessage(input: $input) {\n messageId\n status\n }\n }"; | ||
@@ -51,65 +54,14 @@ | ||
var mutationUpdateMessageStatus = function mutationUpdateMessageStatus(_ref) { | ||
var queryGetUnreadMessages = function queryGetUnreadMessages(_ref) { | ||
var stage = _ref.stage, | ||
appID = _ref.appID, | ||
createMutation = _ref.createMutation, | ||
callbacks = _ref.callbacks, | ||
uuid = _ref.uuid, | ||
variables = _ref.variables; | ||
console.log("UPD MSG STATUS ", stage); | ||
console.log("UPD MSG STATUS ", appID); | ||
console.log("UPD MSG STATUS ", uuid); | ||
console.log("UPD MSG STATUS ", callbacks); | ||
console.log("UPD MSG STATUS ", variables); | ||
name = _ref.name, | ||
createQuery = _ref.createQuery, | ||
fields = _ref.fields, | ||
filter = _ref.filter, | ||
next = _ref.next, | ||
fieldsList = _ref.fieldsList, | ||
uuid = _ref.uuid; | ||
if (stage === "dev") { | ||
var msgs = localStorage.getItem("prifinaMessagingStatuses"); | ||
var msg = { | ||
uuid: uuid, | ||
messageId: variables.messageId, | ||
status: variables.status | ||
}; | ||
if (msgs !== null) { | ||
//console.log("MSG STORAGE ", msgs); | ||
var msgQueue = JSON.parse(msgs); | ||
var msgIdx = msgQueue.findIndex(function (m) { | ||
return m.messageId === variables.messageId; | ||
}); | ||
msgQueue[msgIdx].status = variables.status; | ||
localStorage.setItem("prifinaMessagingStatuses", JSON.stringify(msgQueue)); | ||
} | ||
return Promise.resolve({ | ||
data: { | ||
updateMessage: msg | ||
} | ||
}); | ||
} else { | ||
return createMutation({ | ||
name: "updateMessage", | ||
mutation: updateMessageStatusMutation, | ||
variables: { | ||
input: { | ||
uuid: uuid, | ||
messageId: variables.messageId, | ||
status: variables.status | ||
} | ||
}, | ||
appId: appID | ||
}); | ||
} | ||
}; | ||
var queryGetUnreadMessages = function queryGetUnreadMessages(_ref2) { | ||
var stage = _ref2.stage; | ||
_ref2.appID; | ||
_ref2.name; | ||
_ref2.createQuery; | ||
_ref2.fields; | ||
var filter = _ref2.filter; | ||
_ref2.next; | ||
_ref2.fieldsList; | ||
var uuid = _ref2.uuid; | ||
if (stage === "dev") { | ||
var _ret = function () { | ||
@@ -180,15 +132,23 @@ var msgStatuses = localStorage.getItem("prifinaMessagingStatuses"); | ||
} else { | ||
console.log("GET UNREAD MSG QUERY"); | ||
return createQuery({ | ||
query: unreadMsgsQuery, | ||
name: name, | ||
fields: fields, | ||
filter: filter, | ||
next: next, | ||
appId: appID, | ||
fieldsList: fieldsList | ||
}); | ||
} | ||
}; | ||
var queryGetMessages = function queryGetMessages(_ref3) { | ||
var stage = _ref3.stage; | ||
_ref3.appID; | ||
_ref3.name; | ||
_ref3.createQuery; | ||
_ref3.fields; | ||
var filter = _ref3.filter; | ||
_ref3.next; | ||
_ref3.fieldsList; | ||
var uuid = _ref3.uuid; | ||
var queryGetMessages = function queryGetMessages(_ref2) { | ||
var stage = _ref2.stage, | ||
appID = _ref2.appID, | ||
name = _ref2.name, | ||
createQuery = _ref2.createQuery, | ||
fields = _ref2.fields, | ||
filter = _ref2.filter, | ||
next = _ref2.next, | ||
fieldsList = _ref2.fieldsList, | ||
uuid = _ref2.uuid; | ||
@@ -230,14 +190,22 @@ if (stage === "dev") { | ||
} else { | ||
console.log("GET MSG QUERY"); | ||
return createQuery({ | ||
query: getMsgsQuery, | ||
name: name, | ||
fields: fields, | ||
filter: filter, | ||
next: next, | ||
appId: appID, | ||
fieldsList: fieldsList | ||
}); | ||
} | ||
}; | ||
var queryUserAddressBook = function queryUserAddressBook(_ref4) { | ||
var stage = _ref4.stage; | ||
_ref4.appID; | ||
_ref4.name; | ||
_ref4.createQuery; | ||
_ref4.fields; | ||
_ref4.filter; | ||
_ref4.next; | ||
_ref4.fieldsList; | ||
var queryUserAddressBook = function queryUserAddressBook(_ref3) { | ||
var stage = _ref3.stage, | ||
appID = _ref3.appID, | ||
name = _ref3.name, | ||
createQuery = _ref3.createQuery, | ||
fields = _ref3.fields, | ||
filter = _ref3.filter, | ||
next = _ref3.next, | ||
fieldsList = _ref3.fieldsList; | ||
@@ -251,8 +219,69 @@ if (stage === "dev") { | ||
} else { | ||
console.log("GET ADDRESS BOOK QUERY"); | ||
return createQuery({ | ||
query: getAddressBookQuery, | ||
name: name, | ||
fields: fields, | ||
filter: filter, | ||
next: next, | ||
appId: appID, | ||
fieldsList: fieldsList | ||
}); | ||
} | ||
}; | ||
var mutationUpdateMessageStatus = function mutationUpdateMessageStatus(_ref4) { | ||
var stage = _ref4.stage, | ||
appID = _ref4.appID, | ||
name = _ref4.name, | ||
createMutation = _ref4.createMutation, | ||
callbacks = _ref4.callbacks, | ||
uuid = _ref4.uuid, | ||
variables = _ref4.variables; | ||
console.log("UPD MSG STATUS ", stage); | ||
console.log("UPD MSG STATUS ", appID); | ||
console.log("UPD MSG STATUS ", uuid); | ||
console.log("UPD MSG STATUS ", callbacks); | ||
console.log("UPD MSG STATUS ", variables); | ||
if (stage === "dev") { | ||
var msgs = localStorage.getItem("prifinaMessagingStatuses"); | ||
var msg = { | ||
uuid: uuid, | ||
messageId: variables.messageId, | ||
status: variables.status | ||
}; | ||
if (msgs !== null) { | ||
//console.log("MSG STORAGE ", msgs); | ||
var msgQueue = JSON.parse(msgs); | ||
var msgIdx = msgQueue.findIndex(function (m) { | ||
return m.messageId === variables.messageId; | ||
}); | ||
msgQueue[msgIdx].status = variables.status; | ||
localStorage.setItem("prifinaMessagingStatuses", JSON.stringify(msgQueue)); | ||
} | ||
return Promise.resolve({ | ||
data: { | ||
updateMessage: msg | ||
} | ||
}); | ||
} else { | ||
return createMutation({ | ||
name: name, | ||
mutation: updateMessageStatusMutation, | ||
variables: { | ||
content: { | ||
uuid: uuid, | ||
messageId: variables.messageId, | ||
status: variables.status | ||
} | ||
}, | ||
appId: appID | ||
}); | ||
} | ||
}; | ||
var mutationCreateMessage = function mutationCreateMessage(_ref5) { | ||
var stage = _ref5.stage, | ||
appID = _ref5.appID, | ||
name = _ref5.name, | ||
createMutation = _ref5.createMutation, | ||
@@ -306,7 +335,8 @@ callbacks = _ref5.callbacks, | ||
} else { | ||
variables.sender = uuid; | ||
return createMutation({ | ||
name: "createMessage", | ||
name: name, | ||
mutation: createMessageMutation, | ||
variables: { | ||
input: variables | ||
content: variables | ||
}, | ||
@@ -320,2 +350,3 @@ appId: appID | ||
appID = _ref6.appID, | ||
name = _ref6.name, | ||
createMutation = _ref6.createMutation, | ||
@@ -393,6 +424,6 @@ callbacks = _ref6.callbacks, | ||
return createMutation({ | ||
name: "createMessage", | ||
name: name, | ||
mutation: createMessageMutation, | ||
variables: { | ||
input: variables | ||
content: variables | ||
}, | ||
@@ -404,5 +435,5 @@ appId: appID | ||
var subscribeMessagingStatus = function subscribeMessagingStatus(_ref7) { | ||
var stage = _ref7.stage; | ||
_ref7.appID; | ||
_ref7.name; | ||
var stage = _ref7.stage, | ||
appID = _ref7.appID, | ||
name = _ref7.name; | ||
_ref7.createSubscription; | ||
@@ -425,2 +456,10 @@ var variables = _ref7.variables; | ||
console.log("SUBS "); | ||
return createMutation({ | ||
name: name, | ||
mutation: createMessageMutation, | ||
variables: { | ||
input: variables | ||
}, | ||
appId: appID | ||
}); | ||
} | ||
@@ -443,22 +482,3 @@ }; | ||
}; | ||
/* | ||
return createQuery({ | ||
query: dataQuery, | ||
name: name, | ||
fields, | ||
filter, | ||
next, | ||
appId: appID, | ||
fieldsList: fieldsList, | ||
}); | ||
const dataQuery = `query dataObject($input:DataObjectInput!) { | ||
getDataObject(input:$input) { | ||
result | ||
} | ||
}`; | ||
*/ | ||
exports.getFields = getFields; | ||
@@ -465,0 +485,0 @@ exports.getInfo = getInfo; |
@@ -23,3 +23,6 @@ import { typeof as _typeof } from './_virtual/_rollupPluginBabelHelpers.js'; | ||
}]; | ||
var createMessageMutation = "mutation newMessage($input:MessageInput!) {\n createMessage(input: $input) {\n messageId\n receiver\n sender\n role\n createdAt\n body\n }\n }"; | ||
var unreadMsgsQuery = "query unreadMsgs($input:DataObjectInput!) {\n getUnreadMsgs(input:$input) {\n result\n }\n}"; | ||
var getMsgsQuery = "query getMsgs($input:DataObjectInput!) {\n getMsgs(input:$input) {\n result\n }\n}"; | ||
var getAddressBookQuery = "query getAddressBook($input:DataObjectInput!) {\n getAddressBook(input:$input) {\n result\n }\n}"; | ||
var createMessageMutation = "mutation newMessage($input:MessageInput!) {\n createMessage(input: $input) {\n messageId\n receiver\n chatId\n sender\n createdAt\n body\n }\n }"; | ||
var updateMessageStatusMutation = "mutation updateMessage($input:MessageInput!) {\n createMessage(input: $input) {\n messageId\n status\n }\n }"; | ||
@@ -47,65 +50,14 @@ | ||
var mutationUpdateMessageStatus = function mutationUpdateMessageStatus(_ref) { | ||
var queryGetUnreadMessages = function queryGetUnreadMessages(_ref) { | ||
var stage = _ref.stage, | ||
appID = _ref.appID, | ||
createMutation = _ref.createMutation, | ||
callbacks = _ref.callbacks, | ||
uuid = _ref.uuid, | ||
variables = _ref.variables; | ||
console.log("UPD MSG STATUS ", stage); | ||
console.log("UPD MSG STATUS ", appID); | ||
console.log("UPD MSG STATUS ", uuid); | ||
console.log("UPD MSG STATUS ", callbacks); | ||
console.log("UPD MSG STATUS ", variables); | ||
name = _ref.name, | ||
createQuery = _ref.createQuery, | ||
fields = _ref.fields, | ||
filter = _ref.filter, | ||
next = _ref.next, | ||
fieldsList = _ref.fieldsList, | ||
uuid = _ref.uuid; | ||
if (stage === "dev") { | ||
var msgs = localStorage.getItem("prifinaMessagingStatuses"); | ||
var msg = { | ||
uuid: uuid, | ||
messageId: variables.messageId, | ||
status: variables.status | ||
}; | ||
if (msgs !== null) { | ||
//console.log("MSG STORAGE ", msgs); | ||
var msgQueue = JSON.parse(msgs); | ||
var msgIdx = msgQueue.findIndex(function (m) { | ||
return m.messageId === variables.messageId; | ||
}); | ||
msgQueue[msgIdx].status = variables.status; | ||
localStorage.setItem("prifinaMessagingStatuses", JSON.stringify(msgQueue)); | ||
} | ||
return Promise.resolve({ | ||
data: { | ||
updateMessage: msg | ||
} | ||
}); | ||
} else { | ||
return createMutation({ | ||
name: "updateMessage", | ||
mutation: updateMessageStatusMutation, | ||
variables: { | ||
input: { | ||
uuid: uuid, | ||
messageId: variables.messageId, | ||
status: variables.status | ||
} | ||
}, | ||
appId: appID | ||
}); | ||
} | ||
}; | ||
var queryGetUnreadMessages = function queryGetUnreadMessages(_ref2) { | ||
var stage = _ref2.stage; | ||
_ref2.appID; | ||
_ref2.name; | ||
_ref2.createQuery; | ||
_ref2.fields; | ||
var filter = _ref2.filter; | ||
_ref2.next; | ||
_ref2.fieldsList; | ||
var uuid = _ref2.uuid; | ||
if (stage === "dev") { | ||
var _ret = function () { | ||
@@ -176,15 +128,23 @@ var msgStatuses = localStorage.getItem("prifinaMessagingStatuses"); | ||
} else { | ||
console.log("GET UNREAD MSG QUERY"); | ||
return createQuery({ | ||
query: unreadMsgsQuery, | ||
name: name, | ||
fields: fields, | ||
filter: filter, | ||
next: next, | ||
appId: appID, | ||
fieldsList: fieldsList | ||
}); | ||
} | ||
}; | ||
var queryGetMessages = function queryGetMessages(_ref3) { | ||
var stage = _ref3.stage; | ||
_ref3.appID; | ||
_ref3.name; | ||
_ref3.createQuery; | ||
_ref3.fields; | ||
var filter = _ref3.filter; | ||
_ref3.next; | ||
_ref3.fieldsList; | ||
var uuid = _ref3.uuid; | ||
var queryGetMessages = function queryGetMessages(_ref2) { | ||
var stage = _ref2.stage, | ||
appID = _ref2.appID, | ||
name = _ref2.name, | ||
createQuery = _ref2.createQuery, | ||
fields = _ref2.fields, | ||
filter = _ref2.filter, | ||
next = _ref2.next, | ||
fieldsList = _ref2.fieldsList, | ||
uuid = _ref2.uuid; | ||
@@ -226,14 +186,22 @@ if (stage === "dev") { | ||
} else { | ||
console.log("GET MSG QUERY"); | ||
return createQuery({ | ||
query: getMsgsQuery, | ||
name: name, | ||
fields: fields, | ||
filter: filter, | ||
next: next, | ||
appId: appID, | ||
fieldsList: fieldsList | ||
}); | ||
} | ||
}; | ||
var queryUserAddressBook = function queryUserAddressBook(_ref4) { | ||
var stage = _ref4.stage; | ||
_ref4.appID; | ||
_ref4.name; | ||
_ref4.createQuery; | ||
_ref4.fields; | ||
_ref4.filter; | ||
_ref4.next; | ||
_ref4.fieldsList; | ||
var queryUserAddressBook = function queryUserAddressBook(_ref3) { | ||
var stage = _ref3.stage, | ||
appID = _ref3.appID, | ||
name = _ref3.name, | ||
createQuery = _ref3.createQuery, | ||
fields = _ref3.fields, | ||
filter = _ref3.filter, | ||
next = _ref3.next, | ||
fieldsList = _ref3.fieldsList; | ||
@@ -247,8 +215,69 @@ if (stage === "dev") { | ||
} else { | ||
console.log("GET ADDRESS BOOK QUERY"); | ||
return createQuery({ | ||
query: getAddressBookQuery, | ||
name: name, | ||
fields: fields, | ||
filter: filter, | ||
next: next, | ||
appId: appID, | ||
fieldsList: fieldsList | ||
}); | ||
} | ||
}; | ||
var mutationUpdateMessageStatus = function mutationUpdateMessageStatus(_ref4) { | ||
var stage = _ref4.stage, | ||
appID = _ref4.appID, | ||
name = _ref4.name, | ||
createMutation = _ref4.createMutation, | ||
callbacks = _ref4.callbacks, | ||
uuid = _ref4.uuid, | ||
variables = _ref4.variables; | ||
console.log("UPD MSG STATUS ", stage); | ||
console.log("UPD MSG STATUS ", appID); | ||
console.log("UPD MSG STATUS ", uuid); | ||
console.log("UPD MSG STATUS ", callbacks); | ||
console.log("UPD MSG STATUS ", variables); | ||
if (stage === "dev") { | ||
var msgs = localStorage.getItem("prifinaMessagingStatuses"); | ||
var msg = { | ||
uuid: uuid, | ||
messageId: variables.messageId, | ||
status: variables.status | ||
}; | ||
if (msgs !== null) { | ||
//console.log("MSG STORAGE ", msgs); | ||
var msgQueue = JSON.parse(msgs); | ||
var msgIdx = msgQueue.findIndex(function (m) { | ||
return m.messageId === variables.messageId; | ||
}); | ||
msgQueue[msgIdx].status = variables.status; | ||
localStorage.setItem("prifinaMessagingStatuses", JSON.stringify(msgQueue)); | ||
} | ||
return Promise.resolve({ | ||
data: { | ||
updateMessage: msg | ||
} | ||
}); | ||
} else { | ||
return createMutation({ | ||
name: name, | ||
mutation: updateMessageStatusMutation, | ||
variables: { | ||
content: { | ||
uuid: uuid, | ||
messageId: variables.messageId, | ||
status: variables.status | ||
} | ||
}, | ||
appId: appID | ||
}); | ||
} | ||
}; | ||
var mutationCreateMessage = function mutationCreateMessage(_ref5) { | ||
var stage = _ref5.stage, | ||
appID = _ref5.appID, | ||
name = _ref5.name, | ||
createMutation = _ref5.createMutation, | ||
@@ -302,7 +331,8 @@ callbacks = _ref5.callbacks, | ||
} else { | ||
variables.sender = uuid; | ||
return createMutation({ | ||
name: "createMessage", | ||
name: name, | ||
mutation: createMessageMutation, | ||
variables: { | ||
input: variables | ||
content: variables | ||
}, | ||
@@ -316,2 +346,3 @@ appId: appID | ||
appID = _ref6.appID, | ||
name = _ref6.name, | ||
createMutation = _ref6.createMutation, | ||
@@ -389,6 +420,6 @@ callbacks = _ref6.callbacks, | ||
return createMutation({ | ||
name: "createMessage", | ||
name: name, | ||
mutation: createMessageMutation, | ||
variables: { | ||
input: variables | ||
content: variables | ||
}, | ||
@@ -400,5 +431,5 @@ appId: appID | ||
var subscribeMessagingStatus = function subscribeMessagingStatus(_ref7) { | ||
var stage = _ref7.stage; | ||
_ref7.appID; | ||
_ref7.name; | ||
var stage = _ref7.stage, | ||
appID = _ref7.appID, | ||
name = _ref7.name; | ||
_ref7.createSubscription; | ||
@@ -421,2 +452,10 @@ var variables = _ref7.variables; | ||
console.log("SUBS "); | ||
return createMutation({ | ||
name: name, | ||
mutation: createMessageMutation, | ||
variables: { | ||
input: variables | ||
}, | ||
appId: appID | ||
}); | ||
} | ||
@@ -439,22 +478,3 @@ }; | ||
}; | ||
/* | ||
return createQuery({ | ||
query: dataQuery, | ||
name: name, | ||
fields, | ||
filter, | ||
next, | ||
appId: appID, | ||
fieldsList: fieldsList, | ||
}); | ||
const dataQuery = `query dataObject($input:DataObjectInput!) { | ||
getDataObject(input:$input) { | ||
result | ||
} | ||
}`; | ||
*/ | ||
export { getFields, getInfo, getModuleName, mutationCreateMessage, mutationCreateTestMessage, mutationUpdateMessageStatus, queryGetMessages, queryGetUnreadMessages, queryUserAddressBook, subscribeMessagingData, subscribeMessagingStatus }; |
{ | ||
"name": "@prifina/messaging", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "Prifina Messaging Component", | ||
@@ -28,2 +28,3 @@ "author": "Tero <tero@prifina.com>", | ||
"devDependencies": { | ||
"@aws-sdk/client-cognito-identity": "^3.80.0", | ||
"@babel/cli": "^7.16.8", | ||
@@ -38,2 +39,7 @@ "@babel/core": "^7.16.12", | ||
"@storybook/react": "^6.0.16", | ||
"apollo-link": "^1.2.14", | ||
"apollo-link-context": "^1.0.20", | ||
"apollo-link-http": "^1.5.17", | ||
"aws-amplify": "^4.3.20", | ||
"aws-appsync": "^4.1.5", | ||
"babel-eslint": "^10.1.0", | ||
@@ -44,2 +50,3 @@ "babel-jest": "^27.5.1", | ||
"cross-env": "^7.0.3", | ||
"graphql-tag": "^2.12.6", | ||
"jest": "^27.5.1", | ||
@@ -54,3 +61,3 @@ "react": "^17.0.2", | ||
}, | ||
"gitHead": "2e0f6712e635fcc3fec61157171eab434a873354" | ||
"gitHead": "fa3d0fbbdf99d31e80f71b0f315a26f5248762a9" | ||
} |
216
src/Data.js
@@ -29,17 +29,35 @@ export const getInfo = () => { | ||
const unreadMsgsQuery = `query unreadMsgs($input:DataObjectInput!) { | ||
getUnreadMsgs(input:$input) { | ||
result | ||
} | ||
}`; | ||
const getMsgsQuery = `query getMsgs($input:DataObjectInput!) { | ||
getMsgs(input:$input) { | ||
result | ||
} | ||
}`; | ||
const getAddressBookQuery = `query getAddressBook($input:DataObjectInput!) { | ||
getAddressBook(input:$input) { | ||
result | ||
} | ||
}`; | ||
const createMessageMutation = `mutation newMessage($input:MessageInput!) { | ||
createMessage(input: $input) { | ||
messageId | ||
receiver | ||
sender | ||
role | ||
createdAt | ||
body | ||
result | ||
receiver | ||
} | ||
}`; | ||
const updateMessageStatusMutation = `mutation updateMessage($input:MessageInput!) { | ||
createMessage(input: $input) { | ||
messageId | ||
status | ||
const updateMessageStatusMutation = `mutation updateMessage($input:DataObjectInput!) { | ||
updateMessageStatus(input: $input) | ||
}`; | ||
const subscribeCreateMessage = `subscription MySubscription($receiver: String!) { | ||
addMessage(receiver: $receiver) { | ||
receiver | ||
result | ||
} | ||
@@ -64,56 +82,2 @@ }`; | ||
export const mutationUpdateMessageStatus = ({ | ||
stage, | ||
appID, | ||
createMutation, | ||
callbacks, | ||
uuid, | ||
variables, | ||
}) => { | ||
console.log("UPD MSG STATUS ", stage); | ||
console.log("UPD MSG STATUS ", appID); | ||
console.log("UPD MSG STATUS ", uuid); | ||
console.log("UPD MSG STATUS ", callbacks); | ||
console.log("UPD MSG STATUS ", variables); | ||
if (stage === "dev") { | ||
const msgs = localStorage.getItem("prifinaMessagingStatuses"); | ||
let msg = { | ||
uuid: uuid, | ||
messageId: variables.messageId, | ||
status: variables.status, | ||
}; | ||
if (msgs !== null) { | ||
//console.log("MSG STORAGE ", msgs); | ||
let msgQueue = JSON.parse(msgs); | ||
const msgIdx = msgQueue.findIndex((m) => { | ||
return m.messageId === variables.messageId; | ||
}); | ||
msgQueue[msgIdx].status = variables.status; | ||
localStorage.setItem( | ||
"prifinaMessagingStatuses", | ||
JSON.stringify(msgQueue) | ||
); | ||
} | ||
return Promise.resolve({ | ||
data: { | ||
updateMessage: msg, | ||
}, | ||
}); | ||
} else { | ||
return createMutation({ | ||
name: "updateMessage", | ||
mutation: updateMessageStatusMutation, | ||
variables: { | ||
input: { | ||
uuid: uuid, | ||
messageId: variables.messageId, | ||
status: variables.status, | ||
}, | ||
}, | ||
appId: appID, | ||
}); | ||
} | ||
}; | ||
export const queryGetUnreadMessages = ({ | ||
@@ -178,3 +142,11 @@ stage, | ||
} else { | ||
console.log("GET UNREAD MSG QUERY"); | ||
return createQuery({ | ||
query: unreadMsgsQuery, | ||
name: name, | ||
fields, | ||
filter, | ||
next, | ||
appId: appID, | ||
fieldsList: fieldsList, | ||
}); | ||
} | ||
@@ -227,3 +199,11 @@ }; | ||
} else { | ||
console.log("GET MSG QUERY"); | ||
return createQuery({ | ||
query: getMsgsQuery, | ||
name: name, | ||
fields, | ||
filter, | ||
next, | ||
appId: appID, | ||
fieldsList: fieldsList, | ||
}); | ||
} | ||
@@ -248,9 +228,74 @@ }; | ||
} else { | ||
console.log("GET ADDRESS BOOK QUERY"); | ||
return createQuery({ | ||
query: getAddressBookQuery, | ||
name: name, | ||
fields, | ||
filter, | ||
next, | ||
appId: appID, | ||
fieldsList: fieldsList, | ||
}); | ||
} | ||
}; | ||
export const mutationUpdateMessageStatus = ({ | ||
stage, | ||
appID, | ||
name, | ||
createMutation, | ||
callbacks, | ||
uuid, | ||
variables, | ||
}) => { | ||
console.log("UPD MSG STATUS ", stage); | ||
console.log("UPD MSG STATUS ", appID); | ||
console.log("UPD MSG STATUS ", uuid); | ||
console.log("UPD MSG STATUS ", callbacks); | ||
console.log("UPD MSG STATUS ", variables); | ||
if (stage === "dev") { | ||
const msgs = localStorage.getItem("prifinaMessagingStatuses"); | ||
let msg = { | ||
uuid: uuid, | ||
messageId: variables.messageId, | ||
status: variables.status, | ||
}; | ||
if (msgs !== null) { | ||
//console.log("MSG STORAGE ", msgs); | ||
let msgQueue = JSON.parse(msgs); | ||
const msgIdx = msgQueue.findIndex((m) => { | ||
return m.messageId === variables.messageId; | ||
}); | ||
msgQueue[msgIdx].status = variables.status; | ||
localStorage.setItem( | ||
"prifinaMessagingStatuses", | ||
JSON.stringify(msgQueue) | ||
); | ||
} | ||
return Promise.resolve({ | ||
data: { | ||
updateMessage: true, | ||
}, | ||
}); | ||
} else { | ||
return createMutation({ | ||
name: name, | ||
mutation: updateMessageStatusMutation, | ||
variables: { | ||
options: { | ||
input: JSON.stringify({ | ||
uuid: uuid, | ||
messageId: variables.messageId, | ||
}), | ||
}, | ||
}, | ||
appId: appID, | ||
}); | ||
} | ||
}; | ||
export const mutationCreateMessage = ({ | ||
stage, | ||
appID, | ||
name, | ||
createMutation, | ||
@@ -302,6 +347,7 @@ callbacks, | ||
} else { | ||
variables.sender = uuid; | ||
return createMutation({ | ||
name: "createMessage", | ||
name: name, | ||
mutation: createMessageMutation, | ||
variables: { input: variables }, | ||
variables: { content: variables }, | ||
appId: appID, | ||
@@ -315,2 +361,3 @@ }); | ||
appID, | ||
name, | ||
createMutation, | ||
@@ -384,6 +431,7 @@ callbacks, | ||
} else { | ||
variables.receiver = uuid; | ||
return createMutation({ | ||
name: "createMessage", | ||
name: name, | ||
mutation: createMessageMutation, | ||
variables: { input: variables }, | ||
variables: { content: variables }, | ||
appId: appID, | ||
@@ -413,2 +461,8 @@ }); | ||
console.log("SUBS "); | ||
return createSubscription({ | ||
name: name, | ||
mutation: subscribeCreateMessage, | ||
variables: { receiver: uuid }, | ||
appId: appID, | ||
}); | ||
} | ||
@@ -432,21 +486,1 @@ }; | ||
}; | ||
/* | ||
return createQuery({ | ||
query: dataQuery, | ||
name: name, | ||
fields, | ||
filter, | ||
next, | ||
appId: appID, | ||
fieldsList: fieldsList, | ||
}); | ||
const dataQuery = `query dataObject($input:DataObjectInput!) { | ||
getDataObject(input:$input) { | ||
result | ||
} | ||
}`; | ||
*/ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44263
1380
25