docs: function(threadId, active, callback) {
                  if (active) {
                      if (hasCache && typeof queueDb == 'object') {
                          queueDb.waitQ.where('threadId')
                              .equals(threadId)
                              .and(function(item) {
                                  return item.owner == parseInt(userInfo.id);
                              })
                              .toArray()
                              .then(function(waitQueueOnCache) {
                                  var uniqueIds = [];
  
                                  for (var i = 0; i < waitQueueOnCache.length; i++) {
                                      uniqueIds.push(waitQueueOnCache[i].uniqueId);
                                  }
  
                                  if (uniqueIds.length && chatState) {
                                      sendMessage({
                                          chatMessageVOType: chatMessageVOTypes.GET_HISTORY,
                                          content: {
                                              uniqueIds: uniqueIds
                                          },
                                          subjectId: threadId
                                      }, {
                                          onResult: function(result) {
                                              if (!result.hasError) {
                                                  var messageContent = result.result;
  
                                                  /**
                                                   * Delete those messages from wait
                                                   * queue which are already on the
                                                   * server databases
                                                   */
                                                  for (var i = 0; i < messageContent.length; i++) {
                                                      for (var j = 0; j < uniqueIds.length; j++) {
                                                          if (uniqueIds[j] == messageContent[i].uniqueId) {
                                                              deleteFromChatWaitQueue(messageContent[i], function() {
                                                              });
                                                              uniqueIds.splice(j, 1);
                                                              waitQueueOnCache.splice(j, 1);
                                                          }
                                                      }
                                                  }
  
                                                  /**
                                                   * Delete those messages from wait
                                                   * queue which are in the send
                                                   * queue and are going to be sent
                                                   */
                                                  for (var i = 0; i < chatSendQueue.length; i++) {
                                                      for (var j = 0; j < uniqueIds.length; j++) {
                                                          if (uniqueIds[j] == chatSendQueue[i].message.uniqueId) {
                                                              deleteFromChatWaitQueue(chatSendQueue[i].message, function() {
                                                              });
                                                              uniqueIds.splice(j, 1);
                                                              waitQueueOnCache.splice(j, 1);
                                                          }
                                                      }
                                                  }
  
                                                  callback && callback(waitQueueOnCache);
                                              }
                                          }
                                      });
                                  }
                                  else {
                                      callback && callback(waitQueueOnCache);
                                  }
                              })
                              .catch(function(error) {
                                  fireEvent('error', {
                                      code: error.code,
                                      message: error.message,
                                      error: error
                                  });
                              });
                      }
                      else {
                          var uniqueIds = [];
  
                          for (var i = 0; i < chatWaitQueue.length; i++) {
                              uniqueIds.push(chatWaitQueue[i].uniqueId);
                          }
  
                          if (uniqueIds.length) {
                              sendMessage({
                                  chatMessageVOType: chatMessageVOTypes.GET_HISTORY,
                                  content: {
                                      uniqueIds: uniqueIds
                                  },
                                  subjectId: threadId
                              }, {
                                  onResult: function(result) {
                                      if (!result.hasError) {
                                          var messageContent = result.result;
  
                                          for (var i = 0; i < messageContent.length; i++) {
                                              for (var j = 0; j < uniqueIds.length; j++) {
                                                  if (uniqueIds[j] == messageContent[i].uniqueId) {
                                                      uniqueIds.splice(j, 1);
                                                      chatWaitQueue.splice(j, 1);
                                                  }
                                              }
                                          }
                                          callback && callback(chatWaitQueue);
                                      }
                                  }
                              });
                          }
                          else {
                              callback && callback([]);
                          }
                      }
                  }
                  else {
                      callback && callback([]);
                  }
              }