mirror of
https://github.com/status-im/consul.git
synced 2025-02-03 17:34:08 +00:00
c450183b4c
Use local-storage service, prototyped here https://github.com/LevelbossMike/local-storage-service, to manage local storage usage in an octane way. Does not write to local storage in tests by default and is easy to stub out.
25 lines
482 B
JavaScript
25 lines
482 B
JavaScript
import { TrackedArray } from 'tracked-built-ins';
|
|
import Storage from './base';
|
|
|
|
export default class Notices extends Storage {
|
|
initState() {
|
|
const { key, storage } = this;
|
|
|
|
const persisted = storage.getItem(key);
|
|
|
|
if (persisted) {
|
|
return new TrackedArray(persisted.split(','));
|
|
} else {
|
|
return new TrackedArray();
|
|
}
|
|
}
|
|
|
|
add(value) {
|
|
const { key, storage, state } = this;
|
|
|
|
state.push(value);
|
|
|
|
storage.setItem(key, [...state]);
|
|
}
|
|
}
|