INNER CODE UNIT · TypeScript
isDelete
open-source-labs/obsidian · src/invalidateCacheCheck.ts:104
export function isDelete(queryString: string) {
// Because we check if response object from delete mutation equals to cached object to determine if it's a delete mutation
// but there may be instances that the object is evicted from cache or never cached previously which would be treated as add or update mutation
// if we find any keywords we're looking for in the mutation query that infer deletion we force the deletion
const deleteKeywords: Array<string> = ['delete', 'remove'];
let isDeleteFlag: boolean = false;
for (const keyword of deleteKeywords) {
const regex = new RegExp(keyword);
// if query string contains any of the keywords in the deleteKeywords array we set the flag to true and break out of the loop
if (queryString.search(regex) !== -1) {
isDeleteFlag = true;
break;
}
}
return isDeleteFlag;
}