mirror of
https://github.com/bitwarden/browser
synced 2026-01-04 17:43:39 +00:00
Setup Webpack & TypeScript (#316)
* TypeScript and WebPack. * Minor cleanup. * Add background.js as entry point to webpack. * Use downloaded fonts for better performance. Remove google-fonts-webpack-plugin. * Add the remaining entry points and setup notification bar. * Update readme for webpack. * Convert CipherItems to TypeScript to demonstrate how a component looks in TS. * Fix edge requirering a custom angular version. * Rewrite gulp tasks for packaging releases. * Re-add the webpack gulp plugin. * Remove unessesary line in analytics.
This commit is contained in:
committed by
Kyle Spearrin
parent
e57f3fe5f0
commit
59754cd530
5
src/popup/app/services/services.module.js
Normal file
5
src/popup/app/services/services.module.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import StateService from './state.service';
|
||||
|
||||
angular
|
||||
.module('bit.services', ['toastr'])
|
||||
.service('stateService', StateService);
|
||||
@@ -1,2 +0,0 @@
|
||||
angular
|
||||
.module('bit.services', ['toastr']);
|
||||
36
src/popup/app/services/state.service.ts
Normal file
36
src/popup/app/services/state.service.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
class StateService {
|
||||
|
||||
private state: any = {};
|
||||
|
||||
constructor (private utilsService: any, private constantsService: any) {
|
||||
}
|
||||
|
||||
async init() {
|
||||
const faviconsDisabled = await this.utilsService
|
||||
.getObjFromStorage(this.constantsService.disableFaviconKey);
|
||||
|
||||
this.saveState('faviconEnabled', !faviconsDisabled);
|
||||
}
|
||||
|
||||
saveState(key: string, data: any) {
|
||||
this.state[key] = data;
|
||||
}
|
||||
|
||||
getState(key: string): any {
|
||||
if (key in this.state) {
|
||||
return this.state[key];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
removeState(key: string) {
|
||||
delete this.state[key];
|
||||
}
|
||||
|
||||
purgeState() {
|
||||
this.state = {};
|
||||
}
|
||||
}
|
||||
|
||||
export default StateService;
|
||||
@@ -1,35 +0,0 @@
|
||||
angular
|
||||
.module('bit.services')
|
||||
|
||||
.factory('stateService', function (utilsService, constantsService) {
|
||||
var _service = {},
|
||||
_state = {};
|
||||
|
||||
_service.init = function () {
|
||||
utilsService.getObjFromStorage(constantsService.disableFaviconKey).then(function (disabledFavicons) {
|
||||
_service.saveState('faviconEnabled', !disabledFavicons);
|
||||
});
|
||||
};
|
||||
|
||||
_service.saveState = function (key, data) {
|
||||
_state[key] = data;
|
||||
};
|
||||
|
||||
_service.getState = function (key) {
|
||||
if (key in _state) {
|
||||
return _state[key];
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
_service.removeState = function (key) {
|
||||
delete _state[key];
|
||||
};
|
||||
|
||||
_service.purgeState = function () {
|
||||
_state = {};
|
||||
};
|
||||
|
||||
return _service;
|
||||
});
|
||||
Reference in New Issue
Block a user