Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed session buddy V4 import #1405

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 13 additions & 25 deletions src/options/components/ImportSessionsComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,10 @@ const parseSession = file => {
};

const isSessionBuddy = file => {
const currentKeys = ["generated", "type", "windows"]
const previousKeys = ["created", "generated", "gid", "id", "type", "windows"]
const savedKeys = ["created", "generated", "gid", "id", "modified", "name", "type", "windows"];
if(file.hasOwnProperty("sessions")) {
return file.sessions.every(session => {
if(session.type == "current") {
return currentKeys.every(key => session.hasOwnProperty(key))
}
if(session.type == "previous") {
return previousKeys.every(key => session.hasOwnProperty(key))
}
if(session.type == "saved") {
return savedKeys.every(key => session.hasOwnProperty(key))
}

return false
const savedKeys = ["id", "sourceType", "created", "pinned", "updated", "touched", "folders"];
if(file.hasOwnProperty("collections")) {
return file.collections.every(collection => {
return savedKeys.every(key => collection.hasOwnProperty(key))
})
} else {
return false
Expand All @@ -136,28 +124,28 @@ const isSessionBuddy = file => {

const convertSessionBuddy = file => {
let sessions = [];
for (const SBSession of file.sessions) {
for (const SBSession of file.collections) {
let session = {
windows: {},
windowsNumber: 0,
windowsInfo: {},
tabsNumber: 0,
name: SBSession?.name || "Unnamed Session",
name: SBSession?.title || "Unnamed Session",
date: moment(SBSession?.created || new Date()).valueOf(),
lastEditedTime: Date.now(),
tag: [],
sessionStartTime: moment(SBSession?.generated || new Date()).valueOf(),
sessionStartTime: moment(SBSession?.touched || new Date()).valueOf(),
id: uuidv4()
};

for (const window of SBSession.windows) {
session.windows[window.id] = {};
for (const tab of window.tabs) {
session.windows[window.id][tab.id] = tab;
for (const folder of SBSession.folders) {
session.windows[folder.id] = {};
for (const link of folder.links) {
session.windows[folder.id][link.id] = link;
session.tabsNumber++;
}
session.windowsInfo[window.id] = window;
delete session.windowsInfo[window.id].tabs;
session.windowsInfo[folder.id] = folder;
delete session.windowsInfo[folder.id].tabs;
session.windowsNumber++;
}

Expand Down