Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
mbnuqw committed Mar 28, 2019
2 parents 5f22c01 + 79ad1b9 commit 62de984
Show file tree
Hide file tree
Showing 22 changed files with 172 additions and 267 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ build/profile-ru/*
build/profile-en/*
!build/profile-en/__preserve-dir
build/profile-beta/*
!build/profile-beta/__preserve-dir
!build/profile-beta/__preserve-dir
build/profile-esr/*
!build/profile-esr/__preserve-dir
2 changes: 1 addition & 1 deletion addon/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"author": "mbnuqw",
"name": "__MSG_ExtName__",
"version": "2.2.1",
"version": "2.2.2",
"default_locale": "en",
"description": "__MSG_ExtDesc__",
"homepage_url": "https://github.com/mbnuqw/sidebery",
Expand Down
4 changes: 2 additions & 2 deletions build/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*eslint no-console: off*/
const { spawn, spawnSync } = require('child_process')
const { scripts } = require('../package.json')
const LANG = process.argv[process.argv.length - 1]
const VER = process.argv[process.argv.length - 1]

const colors = {
reset: '\x1b[0m',
Expand Down Expand Up @@ -36,7 +36,7 @@ const PERM_HIDE = scripts['dev.perm.hide'].split(' ')
const PERM_HIDE_CMD = PERM_HIDE[0]
const PERM_HIDE_OPT = PERM_HIDE.slice(1)

const EXT = scripts['dev.ext.' + LANG].split(' ')
const EXT = scripts['dev.ext.' + VER].split(' ')
const EXT_CMD = EXT[0]
const EXT_OPT = EXT.slice(1)

Expand Down
1 change: 1 addition & 0 deletions build/profile-esr/__preserve-dir
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
preserve-dir
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sidebery",
"version": "2.2.1",
"version": "2.2.2",
"description": "Manage your tabs and bookmarks in sidebar",
"main": "index.js",
"scripts": {
Expand All @@ -10,8 +10,10 @@
"dev.perm.hide": "parcel watch ./src/permissions/tab-hide.html -d ./addon/permissions/ --public-url ./ --no-autoinstall",
"dev.ext.en": "web-ext run --source-dir ./addon -f firefox-beta --keep-profile-changes --firefox-profile ./build/profile-beta",
"dev.ext.ru": "web-ext run --source-dir ./addon -f firefox --keep-profile-changes --firefox-profile ./build/profile-ru",
"dev.ext.esr": "web-ext run --source-dir ./addon -f firefox-esr --keep-profile-changes --firefox-profile ./build/profile-esr",
"dev": "node ./build/debug.js en",
"dev.ru": "node ./build/debug.js ru",
"dev.esr": "node ./build/debug.js esr",
"build.sidebar": "parcel build ./src/sidebar/index.html -d ./addon/sidebar/ --public-url ./ --no-autoinstall --no-source-maps",
"build.group": "parcel build ./src/group/group.html -d ./addon/group/ --public-url ./ --no-autoinstall --no-source-maps",
"build.perm.url": "parcel build ./src/permissions/all-urls.html -d ./addon/permissions/ --public-url ./ --no-autoinstall --no-source-maps",
Expand Down
5 changes: 3 additions & 2 deletions src/permissions/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Load settings and set theme
void(async function() {
void (async function() {
let ans = await browser.storage.local.get('settings')
let settings = ans.settings
let theme = settings ? settings.theme : 'dark'
Expand Down Expand Up @@ -36,7 +36,8 @@ void (async function() {

reqBtnEl.addEventListener('click', () => {
browser.permissions.request({ origins, permissions }).then(() => {
browser.runtime.reload()
browser.runtime.sendMessage({ action: 'reloadOptPermissions' })
browser.tabs.getCurrent().then(tab => browser.tabs.remove([tab.id]))
})
})
})()
18 changes: 8 additions & 10 deletions src/sidebar/actions/panels.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,13 @@ export default {
/**
* Update containers data
*/
async updateContainers({ state }, containers) {
async updateContainers({ state, dispatch }, containers) {
if (!containers) return

for (let localCtr of state.containers) {
const newCtr = containers.find(nc => nc.id === localCtr.id)
if (!newCtr) continue

localCtr.colorCode = newCtr.colorCode
localCtr.color = newCtr.color
localCtr.icon = newCtr.icon
localCtr.iconUrl = newCtr.iconUrl
localCtr.name = newCtr.name

localCtr.lockedTabs = newCtr.lockedTabs
localCtr.lockedPanel = newCtr.lockedPanel
localCtr.proxy = newCtr.proxy
Expand All @@ -107,6 +101,8 @@ export default {
localCtr.excludeHosts = newCtr.excludeHosts
localCtr.lastActiveTab = newCtr.lastActiveTab
}

dispatch('updateReqHandlerDebounced')
},

/**
Expand Down Expand Up @@ -273,7 +269,7 @@ export default {
rule = new RegExp(rule.slice(1, rule.length - 1))
}

state.includeHostsRules.push({ ctx: ctr.id, host: rule })
state.includeHostsRules.push({ ctx: ctr.id, value: rule })
}
}

Expand Down Expand Up @@ -316,7 +312,8 @@ export default {
/**
* Set request handler
*/
turnOnReqHandler() {
turnOnReqHandler({ state }) {
if (state.private) return
if (!browser.proxy.onRequest.hasListener(ReqHandler)) {
browser.proxy.onRequest.addListener(ReqHandler, { urls: ['<all_urls>'] })
}
Expand All @@ -325,7 +322,8 @@ export default {
/**
* Unset request handler
*/
turnOffReqHandler() {
turnOffReqHandler({ state }) {
if (state.private) return
if (browser.proxy.onRequest.hasListener(ReqHandler)) {
browser.proxy.onRequest.removeListener(ReqHandler)
}
Expand Down
5 changes: 3 additions & 2 deletions src/sidebar/actions/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export default {
}

state.customStyles = loadedStyles

setTimeout(() => EventBus.$emit('dynVarChange'), 256)
EventBus.$emit('dynVarChange')
},

/**
Expand Down Expand Up @@ -61,6 +60,7 @@ export default {
const rootEl = document.getElementById('root')
Vue.set(state.customStyles, key, val)
rootEl.style.setProperty(Utils.CSSVar(key), val)
setTimeout(() => EventBus.$emit('dynVarChange'), 256)
},

/**
Expand All @@ -70,5 +70,6 @@ export default {
const rootEl = document.getElementById('root')
Vue.set(state.customStyles, key, null)
rootEl.style.removeProperty(Utils.CSSVar(key))
setTimeout(() => EventBus.$emit('dynVarChange'), 256)
},
}
2 changes: 1 addition & 1 deletion src/sidebar/actions/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export default {
* ReSync panels from last loaded state.
*/
resyncPanels({ state, dispatch }) {
if (!state.windowFocused) return
if (state.lastSyncPanels) dispatch('updateSyncPanels', state.lastSyncPanels)
},

Expand All @@ -119,7 +120,6 @@ export default {
updateSyncPanels({ state, getters }, synced) {
if (!synced) return
if (synced.id === state.localID) return
// console.log('[DEBUG] SYNC ACTION updateSyncPanels');

// Check if this data already used
if (state.synced[synced.id] && state.synced[synced.id] >= synced.time) return
Expand Down
3 changes: 2 additions & 1 deletion src/sidebar/actions/sync.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ describe('loadSyncPanels', () => {
describe('resyncPanels', () => {
test('resync panels', async () => {
const state = {
lastSyncPanels: '123456789'
windowFocused: true,
lastSyncPanels: '123456789',
}
const dispatch = jest.fn()

Expand Down
66 changes: 39 additions & 27 deletions src/sidebar/actions/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export default {
t.parentId = -1
t.invisible = false
t.lvl = 0
t.host = t.url.split('/')[2] || ''
state.tabsMap[t.id] = t
if (!t.favIconUrl || t.favIconUrl.startsWith('chrome:')) t.favIconUrl = ''
})
state.tabs = tabs

Expand All @@ -58,14 +60,14 @@ export default {
let offset = 0
for (let i = 0; i < ans.tabsTreeState.length; i++) {
// Saved nodes
const t = ans.tabsTreeState[i]
const savedTab = ans.tabsTreeState[i]

// Current tab
let tab = state.tabs[t.index - offset]
let tab = state.tabs[savedTab.index - offset]
if (!tab) break

const sameUrl = t.url === tab.url
const isGroup = Utils.IsGroupUrl(t.url)
const sameUrl = savedTab.url === tab.url
const isGroup = Utils.IsGroupUrl(savedTab.url)
if (isGroup) {
let nextUrlOk = true

Expand All @@ -79,20 +81,20 @@ export default {

// Removed group
if (!sameUrl && nextUrlOk) {
const groupId = Utils.GetGroupId(t.url)
const parent = parents[t.parentId]
const groupId = Utils.GetGroupId(savedTab.url)
const parent = parents[savedTab.parentId]
const rTab = await browser.tabs.create({
windowId: state.windowId,
index: t.index,
index: savedTab.index,
url: browser.runtime.getURL('group/group.html') + `#${groupId}`,
cookieStoreId: t.ctx,
cookieStoreId: savedTab.ctx,
active: false,
})

tab = state.tabsMap[rTab.id]
tab.isParent = t.isParent
tab.folded = t.folded
if (t.isParent) parents[t.id] = tab
tab.isParent = savedTab.isParent
tab.folded = savedTab.folded
if (savedTab.isParent) parents[savedTab.id] = tab
if (parent) {
tab.invisible = parent.folded || parent.invisible
tab.parentId = parent.id
Expand All @@ -103,13 +105,13 @@ export default {

// Check if this is actual target tab
if (!sameUrl && tab.status === 'complete') break
if (tab.cookieStoreId !== t.ctx) break
if (tab.cookieStoreId !== savedTab.ctx) break

tab.isParent = t.isParent
tab.folded = t.folded
if (t.isParent) parents[t.id] = tab
if (parents[t.parentId]) {
const parentTab = parents[t.parentId]
tab.isParent = savedTab.isParent
tab.folded = savedTab.folded
if (savedTab.isParent) parents[savedTab.id] = tab
if (parents[savedTab.parentId]) {
const parentTab = parents[savedTab.parentId]
tab.invisible = parentTab.folded || parentTab.invisible
tab.parentId = parentTab.id
}
Expand Down Expand Up @@ -145,6 +147,19 @@ export default {
}, delay)
},

/**
* Scroll to active tab
*/
scrollToActiveTab({ state, getters }) {
const activePanel = getters.panels[state.panelIndex]
if (activePanel && activePanel.tabs) {
const activeTab = activePanel.tabs.find(t => t.active)
if (activeTab) {
EventBus.$emit('scrollToActiveTab', state.panelIndex, activeTab.id)
}
}
},

/**
* Create new tab in current window
*/
Expand Down Expand Up @@ -448,14 +463,9 @@ export default {
* Clear all cookies of tab urls
*/
async clearTabsCookies({ state }, tabIds) {
try {
const permitted = await browser.permissions.contains({ origins: ['<all_urls>'] })
if (!permitted) {
const url = browser.runtime.getURL('permissions/all-urls.html')
browser.tabs.create({ url })
return
}
} catch (err) {
if (!state.permAllUrls) {
const url = browser.runtime.getURL('permissions/all-urls.html')
browser.tabs.create({ url })
return
}

Expand Down Expand Up @@ -800,6 +810,9 @@ export default {
pinned: pin,
})
oldNewMap[node.id] = info.id
if (state.tabsMap[info.id] && opener) {
state.tabsMap[info.id].parentId = opener
}
}

// Remove source tabs
Expand Down Expand Up @@ -873,8 +886,7 @@ export default {
*/
async groupTabs({ state, dispatch }, tabIds) {
// Check permissions
const permitted = await browser.permissions.contains({ origins: ['<all_urls>'] })
if (!permitted) {
if (!state.permAllUrls) {
const url = browser.runtime.getURL('permissions/all-urls.html')
browser.tabs.create({ url })
return
Expand Down
1 change: 1 addition & 0 deletions src/sidebar/actions/tabs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ describe('bookmarkTabs', () => {
describe('clearTabsCookies', () => {
test('clear cookies', async () => {
const state = {
permAllUrls: true,
tabs: [
{ id: 1 },
{ id: 2, title: 'a', url: 'http://some.com' },
Expand Down
10 changes: 4 additions & 6 deletions src/sidebar/components/dashboards/containered-tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
<script>
import { mapGetters } from 'vuex'
import Store from '../../store'
import State from '../../store.state'
import TextInput from '../inputs/text'
import ScrollBox from '../scroll-box'
import ToggleField from '../fields/toggle'
Expand Down Expand Up @@ -447,8 +448,7 @@ export default {
async toggleIncludeHosts() {
if (!this.conf.includeHostsActive) {
const permitted = await browser.permissions.contains({ origins: ['<all_urls>'] })
if (!permitted) {
if (!State.permAllUrls) {
const permUrl = browser.runtime.getURL('permissions/all-urls.html')
this.$emit('close')
this.switchProxy('direct')
Expand Down Expand Up @@ -477,8 +477,7 @@ export default {
async toggleExcludeHosts() {
if (!this.conf.excludeHostsActive) {
const permitted = await browser.permissions.contains({ origins: ['<all_urls>'] })
if (!permitted) {
if (!State.permAllUrls) {
const permUrl = browser.runtime.getURL('permissions/all-urls.html')
this.$emit('close')
this.switchProxy('direct')
Expand Down Expand Up @@ -508,8 +507,7 @@ export default {
async switchProxy(type) {
// Check permissions
if (type !== 'direct') {
const permitted = await browser.permissions.contains({ origins: ['<all_urls>'] })
if (!permitted) {
if (!State.permAllUrls) {
this.$emit('close')
this.switchProxy('direct')
browser.tabs.create({
Expand Down
Loading

0 comments on commit 62de984

Please sign in to comment.