Browse Source

Improved logging

master
Igor Zhukov 8 years ago
parent
commit
563077f69e
  1. 1
      app/js/controllers.js
  2. 4
      app/js/lib/ng_utils.js
  3. 6
      app/js/message_composer.js
  4. 2
      app/js/offline_manager.js
  5. 16
      app/js/services.js
  6. 1
      app/service_worker.js

1
app/js/controllers.js

@ -2541,7 +2541,6 @@ angular.module('myApp.controllers', ['myApp.i18n'])
draftDataPromise = DraftsManager.getDraft($scope.curDialog.peerID) draftDataPromise = DraftsManager.getDraft($scope.curDialog.peerID)
} }
draftDataPromise.then(function (draftData) { draftDataPromise.then(function (draftData) {
console.warn('draft', editMessageID, draftData)
$scope.draftMessage.type = editMessageID ? 'edit' : 'new' $scope.draftMessage.type = editMessageID ? 'edit' : 'new'
$scope.draftMessage.text = draftData ? draftData.text : '' $scope.draftMessage.text = draftData ? draftData.text : ''
$scope.draftMessage.isBroadcast = AppPeersManager.isBroadcast($scope.curDialog.peerID) $scope.draftMessage.isBroadcast = AppPeersManager.isBroadcast($scope.curDialog.peerID)

4
app/js/lib/ng_utils.js

@ -1238,7 +1238,7 @@ angular.module('izhukov.utils', [])
var soundcloudRegExp = /^https?:\/\/(?:soundcloud\.com|snd\.sc)\/([a-zA-Z0-9%\-\_]+)\/([a-zA-Z0-9%\-\_]+)/i var soundcloudRegExp = /^https?:\/\/(?:soundcloud\.com|snd\.sc)\/([a-zA-Z0-9%\-\_]+)\/([a-zA-Z0-9%\-\_]+)/i
var spotifyRegExp = /(https?:\/\/(open\.spotify\.com|play\.spotify\.com|spoti\.fi)\/(.+)|spotify:(.+))/i var spotifyRegExp = /(https?:\/\/(open\.spotify\.com|play\.spotify\.com|spoti\.fi)\/(.+)|spotify:(.+))/i
var markdownTestRegExp = /[`_*@]/; var markdownTestRegExp = /[`_*@]/
var markdownRegExp = /(^|\s)(````?)([\s\S]+?)(````?)([\s\n\.,:?!;]|$)|(^|\s)([`*_])([^\n]+?)\7([\s\.,:?!;]|$)|@(\d+)\s*\((.+?)\)/ var markdownRegExp = /(^|\s)(````?)([\s\S]+?)(````?)([\s\n\.,:?!;]|$)|(^|\s)([`*_])([^\n]+?)\7([\s\.,:?!;]|$)|@(\d+)\s*\((.+?)\)/
var siteHashtags = { var siteHashtags = {
@ -1877,7 +1877,7 @@ angular.module('izhukov.utils', [])
function replaceUrlEncodings(urlWithEncoded) { function replaceUrlEncodings(urlWithEncoded) {
return urlWithEncoded.replace(/(%[A-Z\d]{2})+/g, function (str) { return urlWithEncoded.replace(/(%[A-Z\d]{2})+/g, function (str) {
try { try {
return decodeURIComponent(str); return decodeURIComponent(str)
} catch (e) { } catch (e) {
return str return str
} }

6
app/js/message_composer.js

@ -943,8 +943,12 @@ MessageComposer.prototype.onKeyEvent = function (e) {
} }
} }
// Control keys when content is empty // Direction keys when content is empty
if ([33, 34, 35, 36, 38, 39].indexOf(e.keyCode) != -1 && if ([33, 34, 35, 36, 38, 39].indexOf(e.keyCode) != -1 &&
!e.shiftKey &&
!e.altKey &&
!e.ctrlKey &&
!e.metaKey &&
this.richTextareaEl && this.richTextareaEl &&
!this.richTextareaEl[0].textContent.length) { !this.richTextareaEl[0].textContent.length) {
return this.onDirectionKey(e) return this.onDirectionKey(e)

2
app/js/offline_manager.js

@ -34,7 +34,7 @@
if (navigator.serviceWorker) { if (navigator.serviceWorker) {
// If available, use a Service Worker to handle offlining. // If available, use a Service Worker to handle offlining.
navigator.serviceWorker.register('service_worker.js').then(function (registration) { navigator.serviceWorker.register('service_worker.js').then(function (registration) {
console.log('offline worker registered') console.log('Offline worker registered')
registration.addEventListener('updatefound', function () { registration.addEventListener('updatefound', function () {
var installingWorker = this.installing var installingWorker = this.installing

16
app/js/services.js

@ -4671,7 +4671,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
} }
function getDraft (peerID, unsyncOnly) { function getDraft (peerID, unsyncOnly) {
console.warn(dT(), 'get draft', peerID, unsyncOnly) // console.warn(dT(), 'get draft', peerID, unsyncOnly)
return Storage.get('draft' + peerID).then(function (draft) { return Storage.get('draft' + peerID).then(function (draft) {
if (typeof draft === 'string') { if (typeof draft === 'string') {
if (draft.length > 0) { if (draft.length > 0) {
@ -4684,9 +4684,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
} }
if (!draft && !unsyncOnly) { if (!draft && !unsyncOnly) {
draft = getServerDraft(peerID) draft = getServerDraft(peerID)
console.warn(dT(), 'server', draft) // console.warn(dT(), 'server', draft)
} else { } else {
console.warn(dT(), 'local', draft) // console.warn(dT(), 'local', draft)
} }
var replyToMsgID = draft && draft.replyToMsgID var replyToMsgID = draft && draft.replyToMsgID
if (replyToMsgID) { if (replyToMsgID) {
@ -4711,7 +4711,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
cachedServerDrafts[peerID] = draft cachedServerDrafts[peerID] = draft
if (options.notify) { if (options.notify) {
console.warn(dT(), 'save draft', peerID, apiDraft, options) // console.warn(dT(), 'save draft', peerID, apiDraft, options)
changeDraft(peerID, draft) changeDraft(peerID, draft)
$rootScope.$broadcast('draft_updated', { $rootScope.$broadcast('draft_updated', {
peerID: peerID, peerID: peerID,
@ -4724,7 +4724,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
} }
function changeDraft (peerID, draft) { function changeDraft (peerID, draft) {
console.warn(dT(), 'change draft', peerID, draft) // console.warn(dT(), 'change draft', peerID, draft)
if (!peerID) { if (!peerID) {
console.trace('empty peerID') console.trace('empty peerID')
} }
@ -4821,14 +4821,14 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
} }
function syncDraft (peerID) { function syncDraft (peerID) {
console.warn(dT(), 'sync draft', peerID) // console.warn(dT(), 'sync draft', peerID)
getDraft(peerID, true).then(function (localDraft) { getDraft(peerID, true).then(function (localDraft) {
var serverDraft = cachedServerDrafts[peerID] var serverDraft = cachedServerDrafts[peerID]
if (draftsAreEqual(serverDraft, localDraft)) { if (draftsAreEqual(serverDraft, localDraft)) {
console.warn(dT(), 'equal drafts', localDraft, serverDraft) // console.warn(dT(), 'equal drafts', localDraft, serverDraft)
return return
} }
console.warn(dT(), 'changed draft', localDraft, serverDraft) // console.warn(dT(), 'changed draft', localDraft, serverDraft)
var params = { var params = {
flags: 0, flags: 0,
peer: AppPeersManager.getInputPeerByID(peerID) peer: AppPeersManager.getInputPeerByID(peerID)

1
app/service_worker.js

@ -1,2 +1 @@
// 111
importScripts('js/lib/push_worker.js') importScripts('js/lib/push_worker.js')

Loading…
Cancel
Save