@vived/app 2.31.0 → 2.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,20 @@ export interface AssetMetaDTO {
4
4
  name: string;
5
5
  description: string;
6
6
  }
7
+ export interface ShowAlertDTO {
8
+ title: string;
9
+ message: string;
10
+ closeButtonLabel: string;
11
+ closeCallback: () => void;
12
+ }
13
+ export interface ShowConfirmDTO {
14
+ title: string;
15
+ message: string;
16
+ confirmButtonLabel: string;
17
+ cancelButtonLabel: string;
18
+ confirmCallback: () => void;
19
+ cancelCallback: () => void;
20
+ }
7
21
  export declare abstract class AppDispatcher {
8
22
  abstract registerHostHandler: (hostHandler: Handler) => void;
9
23
  abstract dispatch: (request: Request) => void;
@@ -29,5 +43,7 @@ export declare abstract class AppDispatcher {
29
43
  abstract getAssetsForOwner: (ownerID: string) => Promise<AssetMetaDTO[]>;
30
44
  abstract submitNewActivityAsset: (file: File) => Promise<string>;
31
45
  abstract stopZSpace: () => void;
46
+ abstract showAlert: (data: ShowAlertDTO) => void;
47
+ abstract showConfirm: (data: ShowConfirmDTO) => void;
32
48
  }
33
49
  export declare function makeAppDispatcher(): AppDispatcher;
@@ -269,6 +269,26 @@ class AppDistpatcherImp extends AppDispatcher {
269
269
  }
270
270
  });
271
271
  };
272
+ this.showAlert = (data) => {
273
+ const payload = {
274
+ title: data.title,
275
+ message: data.message,
276
+ closeButtonLabel: data.closeButtonLabel,
277
+ closeCallback: data.closeCallback,
278
+ };
279
+ this.formRequestAndDispatch("SHOW_ALERT", 1, payload);
280
+ };
281
+ this.showConfirm = (data) => {
282
+ const payload = {
283
+ title: data.title,
284
+ message: data.message,
285
+ confirmCallback: data.confirmCallback,
286
+ cancelButtonLabel: data.cancelButtonLabel,
287
+ cancelCallback: data.cancelCallback,
288
+ confirmButtonLabel: data.confirmButtonLabel,
289
+ };
290
+ this.formRequestAndDispatch("SHOW_CONFIRM", 1, payload);
291
+ };
272
292
  }
273
293
  formRequestAndDispatch(type, version, payload) {
274
294
  const request = {
@@ -1,14 +1,8 @@
1
- import { Result } from "../ValueObjects";
2
1
  export declare type MessageDataFile = {
3
2
  [key: string]: string;
4
3
  };
5
4
  export interface MessageSystem {
6
5
  setMessages: (messages: MessageDataFile) => void;
7
- getMessage: (keyword: string) => Result<string, Error>;
8
- }
9
- export declare class MessageSystemImp implements MessageSystem {
10
- private messages;
11
- setMessages: (messages: MessageDataFile) => void;
12
- getMessage: (keyword: string) => Result<string, Error>;
6
+ getMessage: (keyword: string, fallbackMessage?: string) => string | undefined;
13
7
  }
14
8
  export declare function makeMessageSystem(): MessageSystem;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeMessageSystem = exports.MessageSystemImp = void 0;
4
- const ValueObjects_1 = require("../ValueObjects");
3
+ exports.makeMessageSystem = void 0;
5
4
  class MessageSystemImp {
6
5
  constructor() {
7
6
  this.messages = new Map();
@@ -13,19 +12,15 @@ class MessageSystemImp {
13
12
  }
14
13
  }
15
14
  };
16
- this.getMessage = (keyword) => {
17
- const message = this.messages.get(keyword);
18
- if (message) {
19
- return new ValueObjects_1.Resolved(message);
20
- }
21
- else {
22
- const err = new Error("Message System cant find message from keyword: " + keyword);
23
- return new ValueObjects_1.Rejected(err);
15
+ this.getMessage = (keyword, fallbackMessage) => {
16
+ let msg = this.messages.get(keyword);
17
+ if (msg === undefined) {
18
+ msg = fallbackMessage;
24
19
  }
20
+ return msg;
25
21
  };
26
22
  }
27
23
  }
28
- exports.MessageSystemImp = MessageSystemImp;
29
24
  function makeMessageSystem() {
30
25
  return new MessageSystemImp();
31
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vived/app",
3
- "version": "2.31.0",
3
+ "version": "2.32.0",
4
4
  "description": "Public package for the VIVED Learning App system",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",