Telegram Web K with changes to work inside I2P
https://web.telegram.i2p/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.1 KiB
51 lines
1.1 KiB
4 years ago
|
import {Storage as ConfigStorage, Modes} from './config';
|
||
|
|
||
|
class AppStorage {
|
||
|
public setPrefix(newPrefix: string) {
|
||
|
ConfigStorage.prefix(newPrefix);
|
||
|
}
|
||
|
|
||
|
public noPrefix() {
|
||
|
ConfigStorage.noPrefix();
|
||
|
}
|
||
|
|
||
|
private proxy<T>(methodName: string, ..._args: any[]) {
|
||
|
let args = Array.prototype.slice.call(_args);
|
||
|
|
||
|
let promise = new Promise<T>((resolve, reject) => {
|
||
|
args.push((result: T) => {
|
||
|
resolve(result);
|
||
|
});
|
||
|
|
||
|
ConfigStorage[methodName].apply(ConfigStorage, args);
|
||
|
});
|
||
|
|
||
|
return promise;
|
||
|
}
|
||
|
|
||
|
public get<T>(...args: any[]) {
|
||
|
return this.proxy<T>('get', ...args);
|
||
|
}
|
||
|
|
||
|
public set<T>(...args: any[]) {
|
||
|
//console.trace(...args);
|
||
|
return this.proxy<T>('set', ...args);
|
||
|
}
|
||
|
|
||
|
public remove<T>(...args: any[]) {
|
||
|
return this.proxy<T>('remove', ...args);
|
||
|
}
|
||
|
|
||
|
public clear<T>(...args: any[]) {
|
||
|
return this.proxy<T>('clear', ...args);
|
||
|
}
|
||
|
|
||
|
constructor() {
|
||
|
if(Modes.test) {
|
||
|
this.setPrefix('t_');
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default new AppStorage();
|