Many changes. See further for more details.
- Notification API - New Modal API - Vault JSON import and export - Improved Page Cache - Adding Context Menu API - Adding Vault Deletion - Fixing Sync Issues - Implementing Share Target API - Implementing Share To API
This commit is contained in:
34
src/notifications.ts
Normal file
34
src/notifications.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import Observable from "./helper/observable";
|
||||
|
||||
export enum MessageType {
|
||||
INFO,
|
||||
WARNING,
|
||||
ERROR,
|
||||
SUCCESS
|
||||
}
|
||||
|
||||
export default class Notifications {
|
||||
private static messageObservableServer = new Observable<{ message: string, type: MessageType }>(false)
|
||||
public static messageObservable = Notifications.messageObservableServer.getPublicApi()
|
||||
|
||||
|
||||
public static sendNotification(message: string, type: MessageType = MessageType.INFO) {
|
||||
Notifications.messageObservableServer.send({ message, type });
|
||||
}
|
||||
|
||||
public static sendInfo(message: string) {
|
||||
this.sendNotification(message, MessageType.INFO)
|
||||
}
|
||||
|
||||
public static sendWarning(message: string) {
|
||||
this.sendNotification(message, MessageType.WARNING)
|
||||
}
|
||||
|
||||
public static sendSuccess(message: string) {
|
||||
this.sendNotification(message, MessageType.SUCCESS)
|
||||
}
|
||||
|
||||
public static sendError(error: Error | string) {
|
||||
Notifications.messageObservableServer.send({ message: typeof error === "string" ? error : error.message, type: MessageType.ERROR })
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user