mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
add loadHistory method
This commit is contained in:
@@ -17,7 +17,6 @@ import { File } from '@ionic-native/file/ngx';
|
||||
/* import { WebNotificationPopupService } from '../services/notification/web-notification-popup.service'; */
|
||||
import { DocumentCounterService } from '../services/worker/document-counter.service';
|
||||
import { PermissionService } from '../services/worker/permission.service';
|
||||
import { Network } from '@ionic-native/network/ngx';
|
||||
import { BackgroundService } from 'src/app/services/background.service';
|
||||
import { OfflineManagerService } from 'src/app/services/offline-manager.service';
|
||||
import { Storage } from '@ionic/storage';
|
||||
@@ -30,7 +29,6 @@ import { RouteService } from 'src/app/services/route.service';
|
||||
import { RocketChatClientService } from 'src/app/services/socket/rocket-chat-client.service';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { RealTimeAPI } from "rocket.chat.realtime.api.rxjs";
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
@@ -74,8 +72,6 @@ export class HomePage implements OnInit {
|
||||
status: string = "";
|
||||
audioName: string = "";
|
||||
|
||||
RocketChatClientService = RocketChatClientService
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
public modalCtrl: AlertController,
|
||||
@@ -96,7 +92,8 @@ export class HomePage implements OnInit {
|
||||
private processservice: ProcessesService,
|
||||
private screenOrientation: ScreenOrientation,
|
||||
private sqliteservice: SqliteService,
|
||||
private RouteService: RouteService) {
|
||||
private RouteService: RouteService,
|
||||
private RocketChatClientService: RocketChatClientService) {
|
||||
|
||||
this.RocketChatClientService.connect(()=>{
|
||||
|
||||
|
||||
@@ -5,7 +5,10 @@ import { wsCallbacksParams, msgQueue } from 'src/app/models/rochet-chat-cliente-
|
||||
/**
|
||||
* Use this class to interact with rocketChat realtime API
|
||||
*/
|
||||
class _RocketChatClientService {
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class RocketChatClientService {
|
||||
|
||||
private hasPing = false
|
||||
private firstPingFunx: Function
|
||||
@@ -163,6 +166,37 @@ class _RocketChatClientService {
|
||||
});
|
||||
}
|
||||
|
||||
loadHistory(roomId, limit: number = 50) {
|
||||
const conditions = this.attemptRequestQueue({...roomId, limit}, {methodName:'loadHistory'})
|
||||
if(conditions == false) { return new Promise((resolve, reject) => { reject('no error')}); }
|
||||
|
||||
const requestId = uuidv4()
|
||||
|
||||
const request = {
|
||||
msg: "method",
|
||||
method: "loadHistory",
|
||||
id: requestId,
|
||||
params: [
|
||||
roomId,
|
||||
null,
|
||||
limit,
|
||||
{
|
||||
"$date": 1480377601
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
this.ws.send(request, requestId)
|
||||
|
||||
|
||||
// return new Promise((resolve, reject) => {
|
||||
// this.ws.registerCallback({type:'Onmessage', requestId, runOnces: true, funx:(message)=>{
|
||||
// if(message.id == requestId || message.result.id == requestId) { // same request send
|
||||
// resolve(message)
|
||||
// }
|
||||
// }})
|
||||
// });
|
||||
}
|
||||
|
||||
subscribe(roomId : string) {
|
||||
|
||||
@@ -281,7 +315,7 @@ class _RocketChatClientService {
|
||||
|
||||
private ws = {
|
||||
connected: false,
|
||||
registerCallback:(params: wsCallbacksParams) =>{
|
||||
registerCallback:(params: wsCallbacksParams) => {
|
||||
|
||||
if(!params.requestId) {
|
||||
params.requestId = uuidv4()
|
||||
@@ -363,7 +397,4 @@ class _RocketChatClientService {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export const RocketChatClientService = new _RocketChatClientService()
|
||||
}
|
||||
Reference in New Issue
Block a user