| 706 | openLogPanel() { this.showLogModal = true; this.loadLogs(); this.errorBadge = 0; }, |
| 707 | |
| 708 | loadLogs(silentBadgeOnly) { |
| 709 | chrome.storage.local.get(PAGE_MONKEY_LOG_KEY, (resps) => { |
| 710 | let arr = []; |
| 711 | try { arr = JSON.parse((resps && resps[PAGE_MONKEY_LOG_KEY]) || '[]'); } catch (e) {} |
| 712 | if (silentBadgeOnly) { |
| 713 | let lastSeen = parseInt(localStorage.getItem('PMK_LOG_LAST_SEEN') || '0'); |
| 714 | let unread = arr.filter(l => (l.time || 0) > lastSeen && l.level === 'error').length; |
| 715 | this.errorBadge = unread; |
| 716 | } else { |
| 717 | this.logs = arr; |
| 718 | localStorage.setItem('PMK_LOG_LAST_SEEN', String(Date.now())); |
| 719 | this.errorBadge = 0; |
| 720 | } |
| 721 | }); |
| 722 | }, |
| 723 | async clearLogs() { |
| 724 | let ok = await this.confirmDialog({ |
| 725 | type: 'warning', |