This commit is contained in:
Dany LE 2021-11-24 22:37:49 +01:00
parent 3a24df169c
commit 3c67b1c134
6 changed files with 20 additions and 20 deletions

12
d.ts/antos.d.ts vendored
View File

@ -920,7 +920,7 @@ declare namespace OS {
* @export
* @interface AnnouncementDataType
*/
interface AnnouncementDataType {
interface AnnouncementDataType<T> {
/**
* message string
*
@ -962,7 +962,7 @@ declare namespace OS {
* @type {*}
* @memberof AppAnnouncementDataType
*/
u_data?: any;
u_data?: T;
}
/**
* Observable entry type definition
@ -1114,10 +1114,10 @@ declare namespace OS {
*
* @export
* @param {string} e event name
* @param {(d: API.AnnouncementDataType) => void} f event callback
* @param {(d: API.AnnouncementDataType<any>) => void} f event callback
* @param {GUI.BaseModel} a the process (Application/service) related to the callback
*/
function on(e: string, f: (d: API.AnnouncementDataType) => void, a: BaseModel): void;
function on(e: string, f: (d: API.AnnouncementDataType<any>) => void, a: BaseModel): void;
/**
* Trigger a global event
*
@ -4716,11 +4716,11 @@ declare namespace OS {
*
* @protected
* @param {string} e event name
* @param {(d: API.AnnouncementDataType) => void} f event callback
* @param {(d: API.AnnouncementDataType<any>) => void} f event callback
* @returns {void}
* @memberof BaseModel
*/
subscribe(e: string, f: (d: API.AnnouncementDataType) => void): void;
subscribe(e: string, f: (d: API.AnnouncementDataType<any>) => void): void;
/**
* Open a dialog
*

Binary file not shown.

View File

@ -25,7 +25,7 @@ namespace OS {
* @export
* @interface AnnouncementDataType
*/
export interface AnnouncementDataType {
export interface AnnouncementDataType<T> {
/**
* message string
@ -73,7 +73,7 @@ namespace OS {
* @type {*}
* @memberof AppAnnouncementDataType
*/
u_data?: any;
u_data?: T;
}
/**
* Observable entry type definition
@ -308,10 +308,10 @@ namespace OS {
*
* @export
* @param {string} e event name
* @param {(d: API.AnnouncementDataType) => void} f event callback
* @param {(d: API.AnnouncementDataType<any>) => void} f event callback
* @param {GUI.BaseModel} a the process (Application/service) related to the callback
*/
export function on(e: string, f: (d: API.AnnouncementDataType) => void, a: BaseModel): void {
export function on(e: string, f: (d: API.AnnouncementDataType<any>) => void, a: BaseModel): void {
if (!announcer.listeners[a.pid]) {
announcer.listeners[a.pid] = [];
}
@ -373,7 +373,7 @@ namespace OS {
* @param {*} [d] user data
*/
export function ostrigger(e: string, m: string| FormattedString, d?: any): void {
const aob: API.AnnouncementDataType = {} as API.AnnouncementDataType;
const aob: API.AnnouncementDataType<any> = {} as API.AnnouncementDataType<any>;
aob.id = 0;
aob.message = m;
aob.u_data = d;

View File

@ -525,11 +525,11 @@ namespace OS {
*
* @protected
* @param {string} e event name
* @param {(d: API.AnnouncementDataType) => void} f event callback
* @param {(d: API.AnnouncementDataType<any>) => void} f event callback
* @returns {void}
* @memberof BaseModel
*/
subscribe(e: string, f: (d: API.AnnouncementDataType) => void): void {
subscribe(e: string, f: (d: API.AnnouncementDataType<any>) => void): void {
return announcer.on(e, f, this);
}
@ -598,7 +598,7 @@ namespace OS {
u_data?: any
): void {
const mt = this.meta();
const data: API.AnnouncementDataType = {} as API.AnnouncementDataType;
const data: API.AnnouncementDataType<any> = {} as API.AnnouncementDataType<any>;
data.icon = undefined;
if (mt && mt.icon) {
data.icon = `${mt.path}/${mt.icon}`;

View File

@ -1058,13 +1058,13 @@ namespace OS {
};
dkfetch(desktop);
announcer.observable.on("VFS", function (d) {
if (["read", "publish", "download"].includes(d.data.m)) {
announcer.observable.on("VFS", function (d: API.AnnouncementDataType<API.VFS.BaseFileHandle>) {
if (["read", "publish", "download"].includes(d.message as string)) {
return;
}
if (
d.data.file.hash() === fp.hash() ||
d.data.file.parent().hash() === fp.hash()
d.u_data.hash() === fp.hash() ||
d.u_data.parent().hash() === fp.hash()
) {
return dkfetch(desktop);
}

View File

@ -115,7 +115,7 @@ namespace OS {
* @param {API.AnnouncementDataType} o
* @memberof PushNotification
*/
private addLog(s: string, o: API.AnnouncementDataType): void {
private addLog(s: string, o: API.AnnouncementDataType<any>): void {
const logtime = new Date();
const log = {
type: s,
@ -144,7 +144,7 @@ namespace OS {
* @param {API.AnnouncementDataType} o
* @memberof PushNotification
*/
private pushout(s: string, o: API.AnnouncementDataType): void {
private pushout(s: string, o: API.AnnouncementDataType<any>): void {
const d = {
text: `[${s}] ${o.name} (${o.id}): ${o.message}`,
icon: o.icon,