You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-desktop/js/models/profile.js

36 lines
846 B
JavaScript

/* global storage, _ */
/* global storage: false */
/* eslint-disable more/no-then */
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
const PROFILE_ID = 'local-profile';
storage.getLocalProfile = () => {
const profile = storage.get(PROFILE_ID, null);
return profile;
}
storage.saveLocalProfile = async (profile) => {
const storedProfile = storage.get(PROFILE_ID, null);
// Only store the profile if we have a different object
if (storedProfile && _.isEqual(storedProfile, profile)) {
return;
}
window.log.info('saving local profile ', profile);
await storage.put(PROFILE_ID, profile);
}
storage.removeLocalProfile = async () => {
window.log.info('removing local profile');
await storage.remove(PROFILE_ID);
}
})();