persistentStorage.ets
802 Bytes
// PersistentStorage.persistProp('clickedIds', []);
//
// function persistentStorage(id: string | number, type: 'add' | 'remove' | undefined = 'add') {
// let clickedIds = AppStorage.get<string>('clickedIds')?.split(',') || [];
// let index = clickedIds.indexOf(id.toString())
// if (type === 'add') {
// if (index >= 0) return;
// clickedIds.push(id.toString());
// } else if (type === 'remove') {
// clickedIds.splice(index, 1);
// }
// AppStorage.set('clickedIds', clickedIds.join(','));
// }
//
// function hasClicked(id: string | number) {
// let clickedIds = AppStorage.get<string>('clickedIds')?.split(',') || [];
// let index = clickedIds.indexOf(id.toString())
// if (index >= 0) return true;
// return false;
// }
//
// export { persistentStorage, hasClicked }