@meetelise/chat
Advanced tools
Comparing version 1.0.0-rc.17 to 1.0.0-rc.18
@@ -6,6 +6,6 @@ /** | ||
*/ | ||
export declare function getChatID(): string; | ||
export declare function getChatID(buildingId: number): string; | ||
/** | ||
* Create a new chat ID and discard any old one. | ||
*/ | ||
export declare function createChatID(): string; | ||
export declare function createChatID(buildingId: number): string; |
import { v4 as uuid } from "uuid"; | ||
const key = "com.meetelise.chatID"; | ||
const keyPrefix = "com.meetelise.chatID"; | ||
function generateFullKey(buildingId) { | ||
return `${keyPrefix}-${buildingId}`; | ||
} | ||
/** | ||
@@ -8,3 +11,4 @@ * Get or create a UUID that is the same between browser sessions. | ||
*/ | ||
export function getChatID() { | ||
export function getChatID(buildingId) { | ||
const key = generateFullKey(buildingId); | ||
const existingID = localStorage.getItem(key); | ||
@@ -14,3 +18,3 @@ if (existingID) | ||
else | ||
return createChatID(); | ||
return createChatID(buildingId); | ||
} | ||
@@ -20,4 +24,5 @@ /** | ||
*/ | ||
export function createChatID() { | ||
export function createChatID(buildingId) { | ||
const id = uuid(); | ||
const key = generateFullKey(buildingId); | ||
localStorage.setItem(key, id); | ||
@@ -24,0 +29,0 @@ return id; |
@@ -24,10 +24,10 @@ import Talk from "talkjs"; | ||
export function createTalkJSPopup(building, theme) { | ||
const popup = session.createPopup(createConversation(building, theme, getChatID())); | ||
const popup = session.createPopup(createConversation(building, theme, getChatID(building.id))); | ||
return popup; | ||
} | ||
export function restartConversation(popup, building, theme) { | ||
popup.select(createConversation(building, theme, createChatID())); | ||
popup.select(createConversation(building, theme, createChatID(building.id))); | ||
} | ||
export function updateTheme(popup, building, theme) { | ||
popup.select(createConversation(building, theme, getChatID())); | ||
popup.select(createConversation(building, theme, getChatID(building.id))); | ||
} | ||
@@ -34,0 +34,0 @@ function createConversation(building, theme, chatID) { |
{ | ||
"name": "@meetelise/chat", | ||
"version": "1.0.0-rc.17", | ||
"version": "1.0.0-rc.18", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "type": "module", |
import { v4 as uuid } from "uuid"; | ||
const key = "com.meetelise.chatID"; | ||
const keyPrefix = "com.meetelise.chatID"; | ||
function generateFullKey(buildingId: number): string { | ||
return `${keyPrefix}-${buildingId}`; | ||
} | ||
/** | ||
@@ -10,6 +14,7 @@ * Get or create a UUID that is the same between browser sessions. | ||
*/ | ||
export function getChatID(): string { | ||
export function getChatID(buildingId: number): string { | ||
const key = generateFullKey(buildingId); | ||
const existingID = localStorage.getItem(key); | ||
if (existingID) return existingID; | ||
else return createChatID(); | ||
else return createChatID(buildingId); | ||
} | ||
@@ -20,6 +25,7 @@ | ||
*/ | ||
export function createChatID(): string { | ||
export function createChatID(buildingId: number): string { | ||
const id = uuid(); | ||
const key = generateFullKey(buildingId); | ||
localStorage.setItem(key, id); | ||
return id; | ||
} |
@@ -33,3 +33,3 @@ import Talk from "talkjs"; | ||
const popup = session.createPopup( | ||
createConversation(building, theme, getChatID()) | ||
createConversation(building, theme, getChatID(building.id)) | ||
); | ||
@@ -44,3 +44,3 @@ return popup; | ||
): void { | ||
popup.select(createConversation(building, theme, createChatID())); | ||
popup.select(createConversation(building, theme, createChatID(building.id))); | ||
} | ||
@@ -53,3 +53,3 @@ | ||
): void { | ||
popup.select(createConversation(building, theme, getChatID())); | ||
popup.select(createConversation(building, theme, getChatID(building.id))); | ||
} | ||
@@ -56,0 +56,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
58977
1058
2