Skip to content

Commit

Permalink
Always re-read sites etc from storage
Browse files Browse the repository at this point in the history
As it's no real gain in keeping a copy in
memory.

might also help on Issue #24
  • Loading branch information
ttyridal committed Feb 25, 2016
1 parent 19ac394 commit a4cac0b
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions ext/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,7 @@ if (ss.storage.sites && (!ss.storage.version || ss.storage.version < 2)) {
if (ss.storage.version !== 2) ss.storage.version = 2;

var session_store = {
'username': ss.storage.username || null,
'masterkey': null,
'sites': ss.storage.sites || {},
'defaulttype': prefs.defaulttype,
'max_alg_version': global_prefs.get('extensions.' + self.id + '.max_alg_version', 3),
'key_id': ss.storage.key_id
};

if (system_password_manager) {
Expand All @@ -90,11 +85,26 @@ if (system_password_manager) {
});
}

function get_max_alg_version() {
return global_prefs.get('extensions.' + self.id + '.max_alg_version', 3);
}

function show_window() {
var panel = createPanel();
panel.show({position: button});
session_store.defaulttype = prefs.defaulttype;
panel.port.on('loaded' ,function(){ panel.port.emit("popup", session_store,false); });
panel.port.on('loaded' ,function(){
panel.port.emit(
"popup",
{
'username': ss.storage.username || null,
'masterkey': session_store.masterkey,
'sites': ss.storage.sites || {},
'defaulttype': prefs.defaulttype,
'max_alg_version': get_max_alg_version(),
'key_id': ss.storage.key_id
},
false);
});
}

var button = buttons.ToggleButton({
Expand Down Expand Up @@ -127,14 +137,13 @@ var pm_config_handler = pagemod.PageMod({
}
worker.port.on('configload', function(m) {
worker.port.emit('configload', {
sites:session_store.sites,
username:session_store.username,
key_id:session_store.key_id,
max_alg_version:session_store.max_alg_version
'username': ss.storage.username,
'sites': ss.storage.sites || {},
'key_id': ss.storage.key_id,
'max_alg_version': get_max_alg_version()
});
});
worker.port.on('configstore', function(d) {
session_store.sites = d;
ss.storage.sites = d;
});
}
Expand Down Expand Up @@ -189,7 +198,7 @@ function createPanel() {
}
for (let i of ['username', 'sites', 'key_id']) {
if (i in d)
ss.storage[i] = session_store[i] = d[i];
ss.storage[i] = d[i];
}
});
panel.port.on('openconfig', function(d){
Expand Down

0 comments on commit a4cac0b

Please sign in to comment.