@prifina/messaging
Advanced tools
Comparing version 0.0.20 to 0.0.21
@@ -56,2 +56,7 @@ 'use strict'; | ||
var shortId = function shortId() { | ||
// this is unique enough... | ||
return Math.random().toString(36).slice(-10); | ||
}; | ||
var queryGetUnreadMessages = function queryGetUnreadMessages(_ref) { | ||
@@ -566,3 +571,4 @@ var stage = _ref.stage, | ||
variables: { | ||
receiver: uuid | ||
receiver: uuid, | ||
appHandler: variables.appHandler || shortId() | ||
}, | ||
@@ -577,5 +583,5 @@ appId: appID | ||
name = _ref10.name, | ||
createSubscription = _ref10.createSubscription; | ||
_ref10.variables; | ||
var uuid = _ref10.uuid; | ||
createSubscription = _ref10.createSubscription, | ||
variables = _ref10.variables, | ||
uuid = _ref10.uuid; | ||
@@ -590,3 +596,4 @@ if (stage === "dev") { | ||
variables: { | ||
receiver: uuid | ||
receiver: uuid, | ||
appHandler: variables.appHandler || shortId() | ||
}, | ||
@@ -593,0 +600,0 @@ appId: appID |
@@ -52,2 +52,7 @@ import { typeof as _typeof } from './_virtual/_rollupPluginBabelHelpers.js'; | ||
var shortId = function shortId() { | ||
// this is unique enough... | ||
return Math.random().toString(36).slice(-10); | ||
}; | ||
var queryGetUnreadMessages = function queryGetUnreadMessages(_ref) { | ||
@@ -562,3 +567,4 @@ var stage = _ref.stage, | ||
variables: { | ||
receiver: uuid | ||
receiver: uuid, | ||
appHandler: variables.appHandler || shortId() | ||
}, | ||
@@ -573,5 +579,5 @@ appId: appID | ||
name = _ref10.name, | ||
createSubscription = _ref10.createSubscription; | ||
_ref10.variables; | ||
var uuid = _ref10.uuid; | ||
createSubscription = _ref10.createSubscription, | ||
variables = _ref10.variables, | ||
uuid = _ref10.uuid; | ||
@@ -586,3 +592,4 @@ if (stage === "dev") { | ||
variables: { | ||
receiver: uuid | ||
receiver: uuid, | ||
appHandler: variables.appHandler || shortId() | ||
}, | ||
@@ -589,0 +596,0 @@ appId: appID |
{ | ||
"name": "@prifina/messaging", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"description": "Prifina Messaging Component", | ||
@@ -58,3 +58,3 @@ "author": "Tero <tero@prifina.com>", | ||
}, | ||
"gitHead": "f9069c7c965becda2f28a4009284a15c1911d850" | ||
"gitHead": "c2eb6e4bc96dcd6cd09ab5529287f56942ef8cfe" | ||
} |
@@ -90,3 +90,3 @@ export const getInfo = () => { | ||
}`; | ||
function randomID() { | ||
@@ -109,2 +109,7 @@ let chars = "qwertyuiopasdfghjklzxcvbnm"; | ||
const shortId = () => { | ||
// this is unique enough... | ||
return Math.random().toString(36).slice(-10); | ||
} | ||
export const queryGetUnreadMessages = ({ | ||
@@ -193,17 +198,17 @@ stage, | ||
if (stage === "dev") { | ||
const msgs = localStorage.getItem("prifinaMessaging"); | ||
console.log("GET MSGS ",msgs,filter); | ||
console.log("GET MSGS ", msgs, filter); | ||
let receiverMsgs = []; | ||
if (msgs !== null) { | ||
receiverMsgs = JSON.parse(msgs).filter((m) => { | ||
console.log("FILTER ",m) | ||
console.log("FILTER ", m) | ||
//console.log(uuid, m); | ||
const logicalOperators = Object.getOwnPropertySymbols(filter); | ||
console.log("MSG FILTER ", Object.keys(filter),logicalOperators); | ||
if (typeof filter!=="undefined" && logicalOperators.length===0 && Object.keys(filter).length>0) { | ||
console.log("MSG FILTER ", Object.keys(filter), logicalOperators); | ||
if (typeof filter !== "undefined" && logicalOperators.length === 0 && Object.keys(filter).length > 0) { | ||
// console.log("SIMPLE FILTER "); | ||
let filterMatch = false; | ||
Object.keys(filter).forEach((f) => { | ||
// console.log("FILTER KEY ",f); | ||
@@ -213,5 +218,5 @@ // console.log("FILTER OBJ ",m); | ||
// console.log("FILTER OBJ VAL ",m[f]); | ||
Object.getOwnPropertySymbols(filter[f]).forEach((e, i) => { | ||
//filter[logicalOP][k][e] | ||
@@ -226,4 +231,4 @@ // only eq is accepted... | ||
}); | ||
@@ -233,4 +238,4 @@ return filterMatch; | ||
} else if (typeof filter !== "undefined" && logicalOperators.length > 0) { | ||
let logicalOP = logicalOperators[0]; | ||
let logicalOP = logicalOperators[0]; | ||
// Object.keys(filter[logicalOP]).forEach((k, ii) => { | ||
@@ -241,12 +246,12 @@ //console.log("OP ",logicalOP); | ||
Object.getOwnPropertySymbols(filter[logicalOP][f]).forEach((e, i) => { | ||
//filter[logicalOP][k][e] | ||
// only eq is accepted... | ||
if (m.hasOwnProperty(f) && m[f] === filter[logicalOP][f][e]) { | ||
filterMatch = true; | ||
} else { | ||
filterMatch = false; | ||
} | ||
//filter[logicalOP][k][e] | ||
// only eq is accepted... | ||
if (m.hasOwnProperty(f) && m[f] === filter[logicalOP][f][e]) { | ||
filterMatch = true; | ||
} else { | ||
filterMatch = false; | ||
} | ||
}); | ||
}); | ||
}); | ||
return filterMatch; | ||
@@ -381,3 +386,3 @@ } else { | ||
chatId: variables.chatId, | ||
owner:uuid, | ||
owner: uuid, | ||
sender: uuid, | ||
@@ -451,3 +456,3 @@ receiver: variables.receiver, | ||
receiver: uuid, | ||
owner:uuid, | ||
owner: uuid, | ||
createdAt: new Date().getTime(), | ||
@@ -525,3 +530,3 @@ }; | ||
sender: uuid, | ||
owner:uuid, | ||
owner: uuid, | ||
receiver: variables.receiver, | ||
@@ -564,3 +569,3 @@ createdAt: new Date().getTime(), | ||
receiver: uuid, | ||
owner:uuid, | ||
owner: uuid, | ||
createdAt: new Date().getTime(), | ||
@@ -611,3 +616,3 @@ }; | ||
mutation: subscribeCreateMessage, | ||
variables: { receiver: uuid }, | ||
variables: { receiver: uuid, appHandler: variables.appHandler || shortId() }, | ||
appId: appID, | ||
@@ -633,3 +638,3 @@ }); | ||
mutation: subscribeCreateDataMessage, | ||
variables: { receiver: uuid }, | ||
variables: { receiver: uuid, appHandler: variables.appHandler || shortId() }, | ||
appId: appID, | ||
@@ -636,0 +641,0 @@ }); |
57006
1776