Mercurial > addons > firefox-addons > tab-mover
comparison background.js @ 11:5d7914307782
Allow reopening tabs from normal windows in incognito windows
Moving a tab from a normal window to a window in incognito mode does not work,
it result in a new empty tab. Thus, allow reopening instead of moving such
tabs.
author | Guido Berhoerster <guido+tab-mover@berhoerster.name> |
---|---|
date | Mon, 20 Feb 2017 17:40:31 +0100 |
parents | 2a87d7a3863f |
children | e32b90567f39 |
comparison
equal
deleted
inserted
replaced
10:2a87d7a3863f | 11:5d7914307782 |
---|---|
180 | 180 |
181 let menuId = String(windowId); | 181 let menuId = String(windowId); |
182 let windowInfo = this.model.getWindow(windowId); | 182 let windowInfo = this.model.getWindow(windowId); |
183 let incognito = this.model.getWindow(focusedWindowId).incognito; | 183 let incognito = this.model.getWindow(focusedWindowId).incognito; |
184 | 184 |
185 if (incognito && !windowInfo.incognito) { | 185 if (incognito !== windowInfo.incognito) { |
186 this.reopenMenuIds.add(menuId); | 186 this.reopenMenuIds.add(menuId); |
187 } else { | 187 } else { |
188 this.moveMenuIds.add(menuId); | 188 this.moveMenuIds.add(menuId); |
189 } | 189 } |
190 | 190 |
191 createContextMenuItem({ | 191 createContextMenuItem({ |
192 id: menuId, | 192 id: menuId, |
193 title: windowInfo.title, | 193 title: windowInfo.title, |
194 contexts: this.menuContexts, | 194 contexts: this.menuContexts, |
195 parentId: (incognito && !windowInfo.incognito) ? | 195 parentId: (incognito !== windowInfo.incognito) ? |
196 'reopen-menu' : 'move-menu' | 196 'reopen-menu' : 'move-menu' |
197 }).then(() => { | 197 }).then(() => { |
198 return this.enableMenus(); | 198 return this.enableMenus(); |
199 }).catch(error => { | 199 }).catch(error => { |
200 console.log('Error:', error); | 200 console.log('Error:', error); |
253 // skip the currently focused window | 253 // skip the currently focused window |
254 continue; | 254 continue; |
255 } | 255 } |
256 | 256 |
257 let menuId = String(windowInfo.id); | 257 let menuId = String(windowInfo.id); |
258 if (incognito && !windowInfo.incognito) { | 258 if (incognito !== windowInfo.incognito) { |
259 this.reopenMenuIds.add(menuId); | 259 this.reopenMenuIds.add(menuId); |
260 } else { | 260 } else { |
261 this.moveMenuIds.add(menuId); | 261 this.moveMenuIds.add(menuId); |
262 } | 262 } |
263 | 263 |
264 // create menu item | 264 // create menu item |
265 promises.push(createContextMenuItem({ | 265 promises.push(createContextMenuItem({ |
266 id: menuId, | 266 id: menuId, |
267 title: windowInfo.title, | 267 title: windowInfo.title, |
268 contexts: this.menuContexts, | 268 contexts: this.menuContexts, |
269 parentId: (incognito && !windowInfo.incognito) ? | 269 parentId: (incognito !== windowInfo.incognito) ? |
270 'reopen-menu' : 'move-menu' | 270 'reopen-menu' : 'move-menu' |
271 })); | 271 })); |
272 } | 272 } |
273 | 273 |
274 return Promise.all(promises); | 274 return Promise.all(promises); |