2023-03-14 14:18:55 +01:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
2023-08-11 09:12:13 -04:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-03-14 14:18:55 +01:00
|
|
|
*/
|
|
|
|
|
2022-10-18 09:40:47 -06:00
|
|
|
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]);
|
|
|
|
}
|
|
|
|
}
|