mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
add headers to options
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { localstoreService } from './localstore.service'
|
||||
import { localstoreService } from '../localstore.service'
|
||||
import { SHA1 } from 'crypto-js'
|
||||
|
||||
@Injectable({
|
||||
@@ -13,7 +13,7 @@ export class ChatMessageService {
|
||||
|
||||
constructor() {
|
||||
|
||||
this.keyName = (SHA1(this.constructor.name)).toString()
|
||||
this.keyName = ('chat'+SHA1(this.constructor.name)).toString()
|
||||
|
||||
setTimeout(()=> {
|
||||
let restore = localstoreService.get(this.keyName, {})
|
||||
@@ -22,18 +22,22 @@ export class ChatMessageService {
|
||||
|
||||
}
|
||||
|
||||
get message() {
|
||||
return this._message
|
||||
}
|
||||
|
||||
getMessages(roomId) {
|
||||
return this._message[roomId] || []
|
||||
}
|
||||
|
||||
add(roomId, message) {
|
||||
add(roomId:string, message: any[]) {
|
||||
this._message[roomId] = message
|
||||
|
||||
setTimeout(()=> {
|
||||
localstoreService.set(this.keyName, {
|
||||
message: this._message
|
||||
})
|
||||
}, 5000)
|
||||
}, 10)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ChatUserService } from './chat-user.service';
|
||||
|
||||
describe('ChatUserService', () => {
|
||||
let service: ChatUserService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(ChatUserService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { localstoreService } from '../localstore.service'
|
||||
import { SHA1 } from 'crypto-js'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ChatUserService {
|
||||
|
||||
// main data
|
||||
private _userList = []
|
||||
// local storage keyName
|
||||
private keyName: string;
|
||||
|
||||
constructor() {
|
||||
|
||||
this.keyName = ('chat'+SHA1(this.constructor.name)).toString()
|
||||
|
||||
setTimeout(()=>{
|
||||
let restore = localstoreService.get(this.keyName, [])
|
||||
this._userList = restore.userList
|
||||
}, 10)
|
||||
|
||||
}
|
||||
|
||||
get userList() {
|
||||
return this._userList
|
||||
}
|
||||
|
||||
reset(userList: any[]) {
|
||||
this._userList = userList
|
||||
|
||||
this.save()
|
||||
}
|
||||
|
||||
private save() {
|
||||
setTimeout(()=> {
|
||||
localstoreService.set(this.keyName, {
|
||||
userList: this._userList
|
||||
})
|
||||
}, 10)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ChatUserStorage = new ChatUserService()
|
||||
Reference in New Issue
Block a user