I don't know
This commit is contained in:
parent
785a8a55e8
commit
88f8a33506
@ -5,5 +5,5 @@ import { sprintf } from "sprintf-js";
|
||||
|
||||
declare global {
|
||||
// const Hls: typeof Hls;
|
||||
var Sprintf: typeof sprintf;
|
||||
export var _sprintf: typeof sprintf;
|
||||
}
|
@ -21,7 +21,7 @@ import { FuseSearchService } from "./service/FuseSearchService";
|
||||
import { ChatMessageDTO } from "./dto/ChatMessageDTO";
|
||||
import { NotificationService } from "./service/NotificationService";
|
||||
import { AlertifyNotificationService } from "./service/AlertifyNotificationService";
|
||||
///<reference path="./SprintfTest.d.ts" />
|
||||
|
||||
// import "./SprintfTest.d.ts"
|
||||
// import { sprintf } from "sprintf-js";
|
||||
// import sprintf = require('sprintf-js');
|
||||
@ -29,12 +29,13 @@ import { TemplateFactory } from "./template/TemplateFactory";
|
||||
import { UserViewDeps } from "./view/UserViewDeps";
|
||||
import { ChatViewDeps } from "./view/ChatViewDeps";
|
||||
import { MarkDownItMarkDownService } from "./service/MarkDownItMarkDownService";
|
||||
import { Sprintf } from "./singleton/Sprintf";
|
||||
|
||||
const usersListElement = document.getElementById('contacts-box');
|
||||
const userSearchButton = document.getElementById('user-search');
|
||||
const userSearchInputElement = document.getElementById('user-search-term') as HTMLInputElement;
|
||||
const userSearchCancelButton = document.getElementById('user-search-cancel');
|
||||
const searchService: SearchService<ActiveUserViewModel> = new FuseSearchService(["userName"]);
|
||||
const activeUserSearchService: SearchService<ActiveUserViewModel> = new FuseSearchService(["userName"]);
|
||||
|
||||
log.setLevel("TRACE")
|
||||
|
||||
@ -53,7 +54,7 @@ const uvDeps: UserViewDeps = {
|
||||
userSearchButton: userSearchButton,
|
||||
// @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'.
|
||||
userSearchCancelButton: userSearchCancelButton,
|
||||
searchService: searchService,
|
||||
searchService: activeUserSearchService,
|
||||
userContactOnlineTemplate: TemplateFactory.getTemplate('user-contact-online-template'),
|
||||
userContactOfflineTemplate: TemplateFactory.getTemplate('user-contact-offline-template')
|
||||
}
|
||||
@ -119,9 +120,10 @@ const testList: ChatMessageDTO[] = [];
|
||||
|
||||
// @ts-ignore
|
||||
console.log()
|
||||
// @ts-ignore
|
||||
log.info(Sprintf("test sprintf"))
|
||||
// log.info(sprintf2.sprintf("test sprintf"))
|
||||
const ns: NotificationService = new AlertifyNotificationService();
|
||||
ns.success("Welcome");
|
||||
// ns.errorWithDelay("Hmm very long error notif", 10);
|
||||
|
||||
const ss = FuseSearchService.getInstance<ActiveUserViewModel>([""]);
|
@ -55,7 +55,6 @@ export class ChatModel implements Subject {
|
||||
|
||||
public someBusinessMethod(chatMessageList: ChatMessageViewModel[]): void {
|
||||
this.state = chatMessageList;
|
||||
this.helperMethod();
|
||||
console.log(`Subject: My state has just changed`);
|
||||
console.log(chatMessageList);
|
||||
this.notify("some user");
|
||||
@ -77,15 +76,4 @@ export class ChatModel implements Subject {
|
||||
|
||||
return cVMs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private helperMethod() { }
|
||||
|
||||
public populateMessages(): void {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -17,31 +17,10 @@ export class ChatModelHelper {
|
||||
public static async getMessages(userName: string, passphrase: string, lastMessageTime: string | null, chatModel: ChatModel): Promise<ChatMessageViewModel[]> {
|
||||
switch (lastMessageTime) {
|
||||
case null: {
|
||||
// this.getAllMessagesAjax(userName)
|
||||
// .then((data: ChatMessageDTO[]) => {
|
||||
// log.debug(`Subject: received all messages`);
|
||||
// // let userNames = data.map(ChatMessageViewModel => ChatMessageViewModel.fromUser)
|
||||
// // let sumt = data.map(chatMessageViewModel => { return this.encryptionService.decrypt(passphrase, chatMessageViewModel.messageCipher) });
|
||||
// return data.map(vm => this.toChatMessageVM(vm, passphrase));
|
||||
// // chatModel.setUserMessages(userName, chatMessageVMs);
|
||||
// // chatModel.notify();
|
||||
// })
|
||||
// break;
|
||||
|
||||
const data: ChatMessageDTO[] = await this.getAllMessagesAjax(userName);
|
||||
return data.map(vm => this.toChatMessageVM(vm, passphrase));
|
||||
|
||||
}
|
||||
default: {
|
||||
// this.getNewMessagesAjax(userName, lastMessageTime)
|
||||
// .then((data: ChatMessageDTO[]) => {
|
||||
// log.debug(`Subject: received new messages`);
|
||||
// return data.map(vm => this.toChatMessageVM(vm, passphrase));
|
||||
// // chatModel.setUserMessages(userName, chatMessageVMs);
|
||||
// // this.state = data;
|
||||
// // chatModel.notify();
|
||||
// })
|
||||
// break;
|
||||
const data: ChatMessageDTO[] = await this.getNewMessagesAjax(userName, lastMessageTime);
|
||||
return data.map(vm => this.toChatMessageVM(vm, passphrase));
|
||||
}
|
||||
|
@ -29,4 +29,20 @@ export class FuseSearchService<T> implements SearchService<T> {
|
||||
return this._fuse.search(searchTerm) as T[];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @static
|
||||
* @param keys
|
||||
* The keys that must be searched for in the given list
|
||||
* @template G
|
||||
* @returns {SearchService<G>}
|
||||
* @memberof FuseSearchService
|
||||
*/
|
||||
static getInstance<G>(keys: string[]): SearchService<G> {
|
||||
return new FuseSearchService<G>(keys);
|
||||
}
|
||||
|
||||
|
||||
}
|
5
chatto/src/main/javascript/ts/src/singleton/Sprintf.ts
Normal file
5
chatto/src/main/javascript/ts/src/singleton/Sprintf.ts
Normal file
@ -0,0 +1,5 @@
|
||||
// ///<reference path="../SprintfTest.d.ts" />
|
||||
export function Sprintf(message: string, ...args: any[]): string {
|
||||
// @ts-ignore
|
||||
return sprintf(message, ...args);
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import { sprintf } from "sprintf-js";
|
||||
import { NotificationService } from "../service/NotificationService";
|
||||
import { AlertifyNotificationService } from "../service/AlertifyNotificationService";
|
||||
import { Sprintf } from "../singleton/Sprintf";
|
||||
|
||||
export function fetchHandler(response: any) {
|
||||
const ns: NotificationService = new AlertifyNotificationService();
|
||||
@ -8,11 +8,11 @@ export function fetchHandler(response: any) {
|
||||
return response.json().then((json: any) => {
|
||||
// the status was ok and there is a json body
|
||||
// return Promise.resolve({ json: json, response: response });
|
||||
ns.success('Message sent succesfully' + sprintf(" (http code %d)", response.status));
|
||||
ns.success('Message sent succesfully' + Sprintf(" (http code %d)", response.status));
|
||||
}).catch((err: any) => {
|
||||
// the status was ok but there is no json body
|
||||
// return Promise.resolve({ response: response });
|
||||
ns.success('Message sent succesfully' + sprintf(" (http code %d)", response.status));
|
||||
ns.success('Message sent succesfully' + Sprintf(" (http code %d)", response.status));
|
||||
});
|
||||
|
||||
} else {
|
||||
@ -27,9 +27,9 @@ export function fetchHandler(response: any) {
|
||||
// alertify.set('notifier', 'delay', 30);
|
||||
let errorMessage = "";
|
||||
json.errors.forEach(function(data: any) {
|
||||
errorMessage += sprintf("Field Name: %s \n Rejected value: %s \n Reason: %s \n", data.field_name, data.rejected_value, data.error_message);
|
||||
errorMessage += Sprintf("Field Name: %s \n Rejected value: %s \n Reason: %s \n", data.field_name, data.rejected_value, data.error_message);
|
||||
});
|
||||
ns.errorWithDelay(sprintf('There were errors in your message - %s', errorMessage), 30);
|
||||
ns.errorWithDelay(Sprintf('There were errors in your message - %s', errorMessage), 30);
|
||||
// alertify.set('notifier', 'delay', delay);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user