2021-12-09 12:53:40 +00:00
|
|
|
import QtQuick 2.13
|
2021-12-14 14:19:55 +00:00
|
|
|
import utils 1.0
|
2021-12-09 12:53:40 +00:00
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property var messageModule
|
|
|
|
|
|
|
|
function getMessageByIdAsJson (id) {
|
|
|
|
if(!messageModule)
|
|
|
|
return false
|
|
|
|
|
|
|
|
let jsonObj = messageModule.getMessageByIdAsJson(id)
|
|
|
|
let obj = JSON.parse(jsonObj)
|
|
|
|
if (obj.error) {
|
2021-12-17 12:53:10 +00:00
|
|
|
// This log is available only in debug mode, if it's annoying we can remove it
|
2021-12-09 12:53:40 +00:00
|
|
|
console.debug("error parsing message for index: ", id, " error: ", obj.error)
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return obj
|
|
|
|
}
|
|
|
|
|
|
|
|
function getMessageByIndexAsJson (index) {
|
|
|
|
if(!messageModule)
|
|
|
|
return false
|
|
|
|
|
|
|
|
let jsonObj = messageModule.getMessageByIndexAsJson(index)
|
|
|
|
let obj = JSON.parse(jsonObj)
|
|
|
|
if (obj.error) {
|
2021-12-17 12:53:10 +00:00
|
|
|
// This log is available only in debug mode, if it's annoying we can remove it
|
2021-12-09 12:53:40 +00:00
|
|
|
console.debug("error parsing message for index: ", index, " error: ", obj.error)
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return obj
|
|
|
|
}
|
2021-12-14 14:19:55 +00:00
|
|
|
|
|
|
|
function getChatType () {
|
|
|
|
if(!messageModule)
|
|
|
|
return Constants.chatType.unknown
|
|
|
|
|
|
|
|
return messageModule.getChatType()
|
|
|
|
}
|
|
|
|
|
|
|
|
function getChatColor () {
|
|
|
|
if(!messageModule)
|
|
|
|
return Style.current.blue
|
|
|
|
|
|
|
|
return messageModule.getChatColor()
|
|
|
|
}
|
|
|
|
|
|
|
|
function amIChatAdmin () {
|
|
|
|
if(!messageModule)
|
|
|
|
return false
|
|
|
|
|
|
|
|
return messageModule.amIChatAdmin()
|
|
|
|
}
|
|
|
|
|
|
|
|
function getNumberOfPinnedMessages () {
|
|
|
|
if(!messageModule)
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return messageModule.getNumberOfPinnedMessages()
|
|
|
|
}
|
|
|
|
|
|
|
|
function pinMessage (messageId) {
|
|
|
|
if(!messageModule)
|
|
|
|
return
|
|
|
|
|
|
|
|
return messageModule.pinMessage(messageId)
|
|
|
|
}
|
|
|
|
|
|
|
|
function unpinMessage (messageId) {
|
|
|
|
if(!messageModule)
|
|
|
|
return
|
|
|
|
|
|
|
|
return messageModule.unpinMessage(messageId)
|
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|