CacheItems: don't delete when deleted, just mark as such.

This is needed for the change history to work properly.
master
Tom Hacohen 4 years ago
parent f2d051a4a6
commit da95830d9f

@ -31,7 +31,8 @@ export interface CachedItem {
content: string;
}
// FIXME: use the ones used by e.g. Contacts/Main so ew share the cache
// FIXME: use the ones used by e.g. Contacts/Main so ew share the cache.
// Only problem though is that we want the deleted items here and not there.
async function decryptItems(items: Map<string, Map<string, Etebase.Item>>) {
const entries: Map<string, Map<string, CachedItem>> = new Map();
for (const [colUid, col] of items.entries()) {

@ -58,6 +58,9 @@ export function getDecryptItemsFunction<T extends PimType>(_colType: string, par
const cur = new Map();
entries.set(colUid, cur);
for (const item of col.values()) {
if (item.isDeleted) {
continue;
}
try {
const contact = parseFunc(await item.getContent(Etebase.OutputFormat.String));
contact.collectionUid = colUid;

@ -93,20 +93,6 @@ export const setCacheItem = createAction(
}
);
export const unsetCacheItem = createAction(
"UNSET_CACHE_ITEM",
(_colUid: string, _itemMgr: Etebase.ItemManager, itemUid: string) => {
return itemUid;
},
(colUid: string, _itemMgr: Etebase.ItemManager, itemUid: string) => {
return {
colUid,
itemUid,
deleted: true,
};
}
);
export const setCacheItemMulti = createAction(
"SET_CACHE_ITEM_MULTI",
async (_colUid: string, itemMgr: Etebase.ItemManager, items: Etebase.Item[]) => {

@ -120,15 +120,10 @@ export const collections = handleActions(
export const items = handleActions(
{
[combineActions(
actions.setCacheItem,
actions.unsetCacheItem
actions.setCacheItem
).toString()]: (state: CacheItemsData, action: ActionMeta<CacheItem, { colUid: string, itemUid: string, deleted: boolean }>) => {
if (action.payload !== undefined) {
if (action.meta.deleted) {
return state.removeIn([action.meta.colUid, action.meta.itemUid]);
} else {
return state.setIn([action.meta.colUid, action.meta.itemUid], action.payload);
}
return state.setIn([action.meta.colUid, action.meta.itemUid], action.payload);
}
return state;
},
@ -142,11 +137,7 @@ export const items = handleActions(
return state.withMutations((state) => {
let i = 0;
for (const item of action.meta.items) {
if (item.isDeleted) {
state.removeIn([action.meta.colUid, item.uid]);
} else {
state.setIn([action.meta.colUid, item.uid], action.payload[i]);
}
state.setIn([action.meta.colUid, item.uid], action.payload[i]);
i++;
}
});

Loading…
Cancel
Save