Add storage to web chat

This commit is contained in:
Eudes Inácio
2021-12-16 16:36:39 +01:00
parent 796143d7c4
commit e1b4ce8113
9 changed files with 513 additions and 157 deletions
+9 -6
View File
@@ -140,7 +140,9 @@ export class SqliteService {
Uids Text,
Usernames Text,
LastMessage Text,
UpdatedAt varchar(255)
UpdatedAt varchar(255),
customFields Text,
name varchar(255)
)`, [])
.then((res) => {
console.log("Sucess chat list room Table created: ", res)
@@ -170,7 +172,8 @@ export class SqliteService {
Rid varchar(255),
Ts varchar(255),
U Text,
UpdatedAt varchar(255)
UpdatedAt varchar(255),
image_url Text
)`, [])
.then((res) => {
console.log("Sucess chat msg Table created: ", res)
@@ -248,8 +251,8 @@ export class SqliteService {
public addChatListRoom(data) {
console.log('INSIDE DB CHAT LIST ROOM',data,)
this.dbInstance.executeSql(`
INSERT OR REPLACE INTO ${this.chatlistroom} (Id,Uids,Usernames,LastMessage,UpdatedAt)
VALUES ('${data.id}','${JSON.stringify(data.uids)}','${JSON.stringify(data.usernames)}','${JSON.stringify(data.lastMessage)}','${data.updatedat}')`, [])
INSERT OR REPLACE INTO ${this.chatlistroom} (Id,Uids,Usernames,LastMessage,UpdatedAt,customFields,name)
VALUES ('${data.id}','${JSON.stringify(data.uids)}','${JSON.stringify(data.usernames)}','${JSON.stringify(data.lastMessage)}','${data.updatedat}','${JSON.stringify(data.customFields)}','${data.name}')`, [])
.then(() => {
console.log("chat room add with Success");
@@ -276,8 +279,8 @@ export class SqliteService {
public addChatMSG(data) {
console.log('INSIDE DB CHAT MSG',data,)
this.dbInstance.executeSql(`
INSERT OR REPLACE INTO ${this.chatmsg} (Id,Attachments,Channels,File,Mentions,Msg,Rid, Ts ,U, UpdatedAt)
VALUES ('${data._id}','${JSON.stringify(data.attachments)}','${JSON.stringify(data.channels)}','${JSON.stringify(data.file)}','${JSON.stringify(data.mentions)}','${data.msg}','${data.rid}','${data.ts}','${JSON.stringify(data.u)}','${data._updatedAt}')`, [])
INSERT OR REPLACE INTO ${this.chatmsg} (Id,Attachments,Channels,File,Mentions,Msg,Rid, Ts ,U, UpdatedAt,image_url)
VALUES ('${data._id}','${JSON.stringify(data.attachments)}','${JSON.stringify(data.channels)}','${JSON.stringify(data.file)}','${JSON.stringify(data.mentions)}','${data.msg}','${data.rid}','${data.ts}','${JSON.stringify(data.u)}','${data._updatedAt}','${JSON.stringify(data.image_url)}')`, [])
.then(() => {
console.log("chat msg add with Success");