Skip to content

Commit

Permalink
last few bug fixes for 2.3.3
Browse files Browse the repository at this point in the history
rohanb10 committed Jan 18, 2021
1 parent 9b456de commit 7637aa8
Showing 7 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion docs/safari.md
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ If you want to build your own version of Snoozz for Safari, here's how you do it

### Instructions

1. In Terminal, navigate to the downloaded (unzipped) `Snoozz for Safari` directory and [convert the extension]((https://developer.apple.com/documentation/safariservices/safari_web_extensions/converting_a_web_extension_for_safari)) to an Xcode package using this command:
1. In Terminal, navigate into the downloaded (unzipped) `Snoozz for Safari` directory and [convert the extension]((https://developer.apple.com/documentation/safariservices/safari_web_extensions/converting_a_web_extension_for_safari)) to an Xcode package using this command:
```
xcrun safari-web-extension-converter . --app-name "snoozz_for_safari" --bundle-identifier com.snoozeman.snoozz --swift --force --no-open
```
2 changes: 1 addition & 1 deletion html/settings.html
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
<img class="snoozz-logo hoverable" src="../icons/main-icon.png">
<img class="snoozz-text" src="../icons/snoozz.png">
</div>
<div tabindex="0" class="dashboard" data-hover="See your sleeping tabs"><img src="../icons/sheep.png"></div>
<div tabindex="0" class="dashboard" data-href="/html/dashboard.html" data-hover="See your sleeping tabs"><img data-href="/html/dashboard.html" src="../icons/sheep.png"></div>
<div class="settings-container">
<h2><span>Settings</span></h2><br>
<div class="input-container flex">
7 changes: 3 additions & 4 deletions scripts/background.js
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ async function setNextAlarm(tabs) {
debounce = setTimeout(_ => wakeMeUp(tabs), 3000)
} else {
var oneHour = dayjs().add(1, 'h').valueOf();
bgLog(['Next tab waking up:', next.id, 'at', dayjs(next.wakeUpTime).format('HH:mm:ss D/M/YY')],['','green','','yellow'])
bgLog(['Next tab waking up:', next.id, 'at', dayjs(next.wakeUpTime).format('HH:mm:ss DD/MM/YY')],['','green','','yellow'])
await createAlarm(next.wakeUpTime < oneHour ? next.wakeUpTime : oneHour, next.wakeUpTime < oneHour);
}
}
@@ -115,7 +115,6 @@ async function snoozeInBackground(item, tab) {

var isHref = item.linkUrl && item.linkUrl.length;
var url = isHref ? item.linkUrl : item.pageUrl;
console.log(isHref, url, !isValid({url}));
if(!isValid({url})) return createNotification(null, `Can't snoozz that :(`, 'icons/main-icon.png', 'The link you are trying to snooze is invalid.');

var snoozeTime = c && c.time;
@@ -167,8 +166,8 @@ async function setUpExtension() {
}
function sendToLogs([which, p1]) {
try {
if (which === 'newtab') bgLog(['Snoozing a new tab', p1.id, 'till', dayjs(p1.wakeUpTime).format('HH:mm:ss D/M/YY')],['', 'green', '', 'yellow'],'green')
if (which === 'newwindow') bgLog(['Snoozing a new window', p1.id, 'till', dayjs(p1.wakeUpTime).format('HH:mm:ss D/M/YY')],['', 'green', '', 'yellow'],'green');
if (which === 'newtab') bgLog(['Snoozing a new tab', p1.id, 'till', dayjs(p1.wakeUpTime).format('HH:mm:ss DD/MM/YY')],['', 'green', '', 'yellow'],'green')
if (which === 'newwindow') bgLog(['Snoozing a new window', p1.id, 'till', dayjs(p1.wakeUpTime).format('HH:mm:ss DD/MM/YY')],['', 'green', '', 'yellow'],'green');
if (which === 'history') bgLog(['Sending tabs to history:', p1.join(', ')], ['', 'green'], 'blue');
if (which === 'manually') bgLog(['Waking up tabs manually:', p1.join(', ')], ['', 'green'], 'blue');
if (which === 'delete') bgLog(['Deleting tabs manually:', p1.join(', ')], ['', 'red'], 'red');
6 changes: 3 additions & 3 deletions scripts/common.js
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ async function getPrettyTab(tabId) {
var tab = await getSnoozedTabs([tabId])
Object.keys(tab).forEach(k => {
if (typeof tab[k] === 'string' && tab[k].length > 75) tab[k] = tab[k].substring(0,72) + '...';
if (!isNaN(tab[k])) tab[k] = dayjs(tab[k]).format('HH:mm:ss D/M/YY');
if (!isNaN(tab[k])) tab[k] = dayjs(tab[k]).format('HH:mm:ss DD/MM/YY');
})
return tab;
}
@@ -83,7 +83,7 @@ async function saveTabs(tabs) {
}
/* CREATE */
async function createAlarm(when, willWakeUpATab) {
bgLog(['Next Alarm at', dayjs(when).format('HH:mm:ss D/M/YY')], ['', willWakeUpATab ? 'yellow':'white'])
bgLog(['Next Alarm at', dayjs(when).format('HH:mm:ss DD/MM/YY')], ['', willWakeUpATab ? 'yellow':'white'])
await chrome.alarms.create('wakeUpTabs', {when});
}
async function createNotification(id, title, imgUrl, message) {
@@ -328,7 +328,7 @@ var clipboard = text => {
}

var bgLog = (logs, colors, timestampColor = 'grey') => {
var timestamp = dayjs().format('[%c]D/M/YY HH:mm:ss[%c] | ')
var timestamp = dayjs().format('[%c]DD/MM/YY HH:mm:ss[%c] | ')
logs = logs.map(l => '%c'+l+'%c').join(' ')
colors.unshift(timestampColor);
colors = colors.flatMap((v,i,a)=>i !== a.length ? [v, ''] : v).map(c => {
9 changes: 3 additions & 6 deletions scripts/dashboard.js
Original file line number Diff line number Diff line change
@@ -67,9 +67,7 @@ function updateTabs() {
// add any remaining tabs from cache
cachedTabIds.forEach(tid => {
var t = CACHED_TABS.find(ct => ct.id === tid)
console.log(t)
if (document.getElementById(tid)) {
console.log('ssss',document.getElementById(tid).closest(`#${getTimeGroup(t)}`))
if (!document.getElementById(tid).closest(`#${getTimeGroup(t)}`)) insertIntoCorrectPosition(t, true)
} else {
insertIntoCorrectPosition(t)
@@ -80,7 +78,6 @@ function updateTabs() {
function insertIntoCorrectPosition(t, alreadyExists = false) {
var tab = alreadyExists ? document.getElementById(t.id) : buildTab(t);
var allTabs, index = 0, group = document.getElementById(getTimeGroup(t));
console.log('tttt', group, group.querySelectorAll('.tab'));
if (t && group) allTabs = group.querySelectorAll('.tab');
if (allTabs && allTabs.length > 0) {
Array.from(allTabs).map(s => CACHED_TABS.find(ct => ct.id === s.id)).forEach(s => {
@@ -200,11 +197,11 @@ function buildTabActions(t, tabDiv) {
var wakeUpBtn = tabDiv.querySelector('img.wakeup-button');
var removeBtn = tabDiv.querySelector('img.remove-button');

if (!!t.opened) {
if (t.opened) {
if (!t.tabs) {
tabName.setAttribute('tabIndex', 0);
tabName.onclick = _ => openTab(t.url);
tabName.onkeyup = e => { if (e.which === 13) openTab(t.url)};
tabName.onclick = _ => openTab(t);
tabName.onkeyup = e => { if (e.which === 13) openTab(t)};
}
wakeUpBtn.remove();
removeBtn.remove();
2 changes: 1 addition & 1 deletion scripts/popup.js
Original file line number Diff line number Diff line change
@@ -135,7 +135,7 @@ async function generatePreviews() {

// Disable everything if both tabs and windows are unsnoozable.
if (validTabs.length === 0 || (windowPreview.classList.contains('disabled') && tabPreview.classList.contains('disabled'))) {
document.querySelectorAll('.choice, .custom-choice, h3').forEach(c => c.classList.add('disabled'));
document.querySelectorAll('.choice, .custom-choice, h3').forEach(c => {c.classList.add('disabled');c.setAttribute('tabindex','-1')});
}
}

5 changes: 3 additions & 2 deletions scripts/settings.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
async function initialize() {
document.querySelector('.dashboard').addEventListener('keyup', e => {if (e.which === 13) openExtensionTab('/html/dashboard.html')}, {once:true})
document.querySelector('.dashboard').addEventListener('click', _ => openExtensionTab('/html/dashboard.html'), {once:true});
document.querySelector('.dashboard').addEventListener('keyup', e => {if (e.which === 13) openExtensionTab('/html/dashboard.html')})
document.querySelector('.dashboard').addEventListener('click', _ => openExtensionTab('/html/dashboard.html'));
showIconOnScroll();

if (window.location.hash) {
@@ -173,6 +173,7 @@ async function resetSettings() {
}
await saveOptions(defaultOptions);
updateFormValues(defaultOptions);
await setTheme();
}

window.onload = initialize

0 comments on commit 7637aa8

Please sign in to comment.