|
1 | 1 | import * as SessionManager from "../core/SessionManager.js"; |
2 | 2 | import * as ActiveSessionManager from "../core/ActiveSessionManager.js"; |
| 3 | +import * as ClassicSessionManager from "../core/ClassicSessionManager.js"; |
3 | 4 | import { Tab, ContextMenuId, Bookmark, SessionId } from "../util/Types.js"; |
4 | 5 | import ActiveSession from "../core/ActiveSession.js"; |
5 | 6 | import TabData from "../core/TabData.js"; |
@@ -125,14 +126,14 @@ async function addToSessionMenu( |
125 | 126 | "16": "img/browserMenu/add.svg", |
126 | 127 | "32": "img/browserMenu/add.svg" |
127 | 128 | }, |
128 | | - onclick: () => SessionManager.createSessionFromTabs(tabs, false) |
| 129 | + onclick: () => ClassicSessionManager.createSession(tabs, false) |
129 | 130 | }); |
130 | 131 |
|
131 | 132 | if(sessions.length > 0) { |
132 | 133 | browser.menus.create({ |
133 | 134 | parentId: "add", |
134 | 135 | type: "separator" |
135 | | - }) |
| 136 | + }); |
136 | 137 | } |
137 | 138 |
|
138 | 139 | // add to existing session |
@@ -194,36 +195,50 @@ async function addAndSetAsideMenu( |
194 | 195 | activeSessions:Set<SessionId>, |
195 | 196 | tabs:Tab[] |
196 | 197 | ) { |
197 | | - if(sessions.length > 0) { |
198 | | - dynamicMenus.push( |
199 | | - browser.menus.create({ |
200 | | - parentId: "parent", |
201 | | - id: "add-n-close", |
202 | | - title: browser.i18n.getMessage("tab_contextmenu_add_and_set_aside"), |
203 | | - }) |
204 | | - ); |
205 | | - |
206 | | - sessions |
207 | | - // ignore active sessions as this operation does not make sense |
208 | | - .filter(session => !activeSessions.has(session.id)) |
209 | | - .forEach(session => browser.menus.create( |
210 | | - { |
211 | | - parentId: "add-n-close", |
212 | | - title: "&" + session.title.replace(/&/ig, "&&").trim(), |
213 | | - onclick: async (info) => { |
214 | | - for(let tab of tabs) { |
215 | | - const data = TabData.createFromTab(tab); |
216 | | - await browser.bookmarks.create( |
217 | | - data.getBookmarkCreateDetails(session.id) |
218 | | - ); |
| 198 | + dynamicMenus.push( |
| 199 | + browser.menus.create({ |
| 200 | + parentId: "parent", |
| 201 | + id: "add-n-close", |
| 202 | + title: browser.i18n.getMessage("tab_contextmenu_add_and_set_aside"), |
| 203 | + }) |
| 204 | + ); |
219 | 205 |
|
220 | | - browser.tabs.remove(tab.id); |
221 | | - } |
222 | | - |
223 | | - // update sidebar |
224 | | - SessionContentUpdate.send(session.id); |
225 | | - } |
226 | | - } |
227 | | - )); |
| 206 | + // ignore active sessions as this operation does not make sense |
| 207 | + sessions = sessions.filter(session => !activeSessions.has(session.id)); |
| 208 | + |
| 209 | + // create new session |
| 210 | + browser.menus.create({ |
| 211 | + parentId: "add-n-close", |
| 212 | + title: browser.i18n.getMessage("tab_contextmenu_create_new"), |
| 213 | + icons: { |
| 214 | + "16": "img/browserMenu/add.svg", |
| 215 | + "32": "img/browserMenu/add.svg" |
| 216 | + }, |
| 217 | + onclick: () => ClassicSessionManager.createSession(tabs, true) |
| 218 | + }); |
| 219 | + |
| 220 | + if(sessions.length > 0) { |
| 221 | + browser.menus.create({ |
| 222 | + parentId: "add-n-close", |
| 223 | + type: "separator" |
| 224 | + }); |
228 | 225 | } |
| 226 | + |
| 227 | + sessions.forEach(session => browser.menus.create({ |
| 228 | + parentId: "add-n-close", |
| 229 | + title: "&" + session.title.replace(/&/ig, "&&").trim(), |
| 230 | + onclick: async (info) => { |
| 231 | + for(let tab of tabs) { |
| 232 | + const data = TabData.createFromTab(tab); |
| 233 | + await browser.bookmarks.create( |
| 234 | + data.getBookmarkCreateDetails(session.id) |
| 235 | + ); |
| 236 | + |
| 237 | + browser.tabs.remove(tab.id); |
| 238 | + } |
| 239 | + |
| 240 | + // update sidebar |
| 241 | + SessionContentUpdate.send(session.id); |
| 242 | + } |
| 243 | + })); |
229 | 244 | } |
0 commit comments