TheM.messages Reference
Constructor
The parent TheM class contains functionality enabling the initialization of any TheM subclass or submodule instance by simply calling TheM.doInit('subclassName'), where the input string is a case sensitive space-delimited string containing the names of all submodules that may be required in the current session. Most TheM subclasses also require the 'common' submodule. It is common to initialize the target submodule and any other submodule dependencies concurrently. The following example will initialize a new instance of the necessary submodules using a proxy constructor in TheM parent class.
Example
Properties
Property table for TheM.messages
Property | Description | Required | Schema |
---|---|---|---|
all | Gets (returns) an array with all the messages associated with the user. | Yes | { "title": "TheM.messages.all", "type": "array", "description": "Gets (returns) an array with all the messages associated with the user.", "$comment": "getter", "examples": [ [ { "AFiMessageId": "qwemsglyybyxkwpfxuoxmuuzzydyqhytrtqs", "category": null, "dedupCode": "nleqlaubxm", "dtsCreated": "2024-07-23T11:26:41.024Z", "fromAFiUserId": "qweaurlysmbdlsrf", "href": null, "isDelivered": true, "isRead": false, "messagePriorityCode": null, "text": "This is a message text", "title": null, "toAFiUserId": "AmpliFi Support" } ] ], "nullable": false } |
unread | Gets (returns) an array with all the messages associated with the user that are currently marked isRead: false. | Yes | { "title": "TheM.messages.unread", "type": "array", "description": "Gets (returns) an array with all the messages associated with the user that are currently marked isRead: false.", "$comment": "getter", "examples": [ [ { "AFiMessageId": "qwemsglyybyxkwpfxuoxmuuzzydyqhytrtqs", "category": null, "dedupCode": "nleqlaubxm", "dtsCreated": "2024-07-23T11:26:41.024Z", "fromAFiUserId": "qweaurlysmbdlsrf", "href": null, "isDelivered": true, "isRead": false, "messagePriorityCode": null, "text": "This is a message text", "title": null, "toAFiUserId": "AmpliFi Support" } ] ], "nullable": false } |
unreadIsImportant | Gets (returns) an array with all the messages associated with the user that are currently marked isRead: false and category: 'important'. | Yes | { "title": "TheM.messages.unreadIsImportant", "type": "array", "description": "Gets (returns) an array with all the messages associated with the user that are currently marked isRead: false and category: 'important'.", "$comment": "getter", "examples": [ [ { "AFiMessageId": "qwemsglyybyxkwpfxuoxmuuzzydyqhytrtqs", "category": "important", "dedupCode": "nleqlaubxm", "dtsCreated": "2024-07-23T11:26:41.024Z", "fromAFiUserId": "qweaurlysmbdlsrf", "href": null, "isDelivered": true, "isRead": false, "messagePriorityCode": 5, "text": "This is a message text", "title": null, "toAFiUserId": "AmpliFi Support" } ] ], "nullable": false } |
newMessage | Gets (returns) a new blank message object. | Yes | { "title": "TheM.messages.newMessage", "type": "object", "description": "Gets (returns) a new blank message object.", "$comment": "getter", "examples": [ { "text": "" } ], "nullable": false } |
isExpired | Gets (returns) true if the messages array date range starting value is greater than 10 minutes prior to the current date/time value. | Yes | { "title": "TheM.messages.isExpired", "type": "boolean", "description": "Gets (returns) true if the messages array date range starting value is greater than 10 minutes prior to the current date/time value.", "$comment": "getter", "examples": [ true, false ], "nullable": false } |
isWorking | Gets (returns) true if the messages array is currently being updated. | Yes | { "title": "TheM.messages.isWorking", "type": "boolean", "description": "Gets (returns) true if the messages array is currently being updated.", "$comment": "getter", "examples": [ true, false ], "nullable": false } |
length | Gets (returns) the length of the messages array. | Yes | { "title": "TheM.messages.length", "type": "number", "description": "Gets (returns) the length of the messages array.", "examples": [ 1 ], "default": 0, "nullable": false } |
Methods
Method Name | Parameter Descriptions | Description | Example |
---|---|---|---|
doSave | [] |
Saves messages data in local storage. Normally, there is no need to use this method as the framework knows automatically when to save and when to load the data to and from local storage. Returns true. | TheM.messages.doSave(); |
doLoad | [] |
Loads messages data from local storage and returns a boolean value to indicate success. Normally, there is no need to use this method as the framework knows automatically when to save and when to load the data to and from local storage. | TheM.messages.doLoad(); |
doUpdate | [ |
Causes framework to pull fresh messages data from the server. If the data is fresh enough, meaning an update has happened recently, the framework will ignore the suggestion. However, you can force the framework to update the data by sending true as an argument. On success, a(n) 'modelBank messages refreshed' event will occur. |
TheM.messages.doUpdate(true); |
doMarkRead | [ |
Returns a promise that marks the message specified by the givenAFiMessageId as read. | TheM.messages.doMarkRead("qwemsglyybyxkwpfxuoxmuuzzydyqhytrtqs"); |
doSubmit | [ |
Returns a promise that submits the given message to the server. Alternatively, givenMsg may be a string instead of an object. In such a case, the string will be used as the 'text' property of the message when submitted. If givenMsg is a string, the AFiUserId of the currently logged in user will be submitted as the fromAFiUserId, the current date will be used as the dtsCreated value, and a randomly generated string will be used as the dedupCode value. | TheM.messages.doSubmit({); |
message | [ |
Returns the message associated with the user specified by the givenAFiMessageId, if a match exists. | TheM.messages.message("qwemsglyybyxkwpfxuoxmuuzzydyqhytrtqs"); |