Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
syncChromeWindow (chromeWindow) {
const prevTabWindow = this.windowIdMap.get(chromeWindow.id)
/*
if (!prevTabWindow) {
log.log("syncChromeWindow: detected new chromeWindow: ", chromeWindow)
}
*/
const tabWindow = prevTabWindow ? TabWindow.updateWindow(prevTabWindow, chromeWindow) : TabWindow.makeChromeTabWindow(chromeWindow)
const stReg = this.registerTabWindow(tabWindow)
// if window has focus and is a 'normal' window, update current window id:
const updCurrent = chromeWindow.focused && validChromeWindow(chromeWindow, true)
const st = updCurrent ? stReg.set('currentWindowId', chromeWindow.id) : stReg
if (updCurrent) {
log.log('syncChromeWindow: updated current window to: ', chromeWindow.id)
}
return st
}
function returnFileName(sessions) {
log.log(logDir, "returnFileName()", sessions);
const sessionLabel = browser.i18n.getMessage("sessionLabel").toLowerCase();
const sessionsLabel = browser.i18n.getMessage("sessionsLabel").toLowerCase();
let fileName = `${moment().format(getSettings("dateFormat"))} (${sessions.length} ${
sessions.length == 1 ? sessionLabel : sessionsLabel
})`;
const pattern = /\\|\/|\:|\?|\.|"|<|>|\|/g;
fileName = fileName.replace(pattern, "-");
return fileName;
}
const onUpdatePreferences = (storeRef, newPrefs) => {
log.log('update preferences: ', newPrefs.toJS())
actions.savePreferences(newPrefs, storeRef)
onClose()
}
export async function saveSession(session, isSendResponce = true) {
log.log(logDir, "saveSession()", session, isSendResponce);
try {
await Sessions.put(session);
if (isSendResponce) sendMessage("saveSession", { session: session });
return session;
} catch (e) {
log.error(logDir, "saveSession()", e);
return Promise.reject(e);
}
}
export const sendSessionUpdateMessage = async session => {
log.log(logDir, "sendSessionUpdateMessage()", session);
return await browser.runtime.sendMessage({
message: "update",
session: session,
isSendResponce: true
});
};
async function isChangedAutoSaveSession(session) {
log.log(logDir, "isChangedAutoSaveSession()");
const regularSessions = await getSessionsByTag("regular", ["id", "tag", "date", "windows"]);
if (regularSessions.length == 0) return true;
const tabsToString = session => {
let retArray = [];
for (let windowNo in session.windows) {
retArray.push(windowNo);
for (let tabNo in session.windows[windowNo]) {
const tab = session.windows[windowNo][tabNo];
retArray.push(tab.id, tab.url);
}
}
return retArray.toString();
};
//前回保存時とタブが異なればtrue
handleClick = (event) => {
log.log('FlatButton.handleClick: ', this.props)
event.stopPropagation()
event.preventDefault()
if (this.props.onClick) {
this.props.onClick(event)
}
log.log('FlatButton.handleClick: returning false')
return false
};
const onClose = async () => {
log.log('onClose')
const tab = await chromep.tabs.getCurrent()
log.log('onClose tab: ', tab)
chrome.tabs.remove(tab.id)
}
handleTabClosed (tabWindow, tabId) {
log.log('handleTabClosed: closing tab id ', tabId)
var updWindow = TabWindow.closeTab(tabWindow, tabId)
log.log('handleTabClosed: updWindow: ', updWindow.toJS())
return this.registerTabWindow(updWindow)
}