Compare commits

...
3 changed files with 17 additions and 1 deletions
@@ -66,7 +66,12 @@ class Api::V1::Accounts::InboxesController < Api::V1::Accounts::BaseController
end
def destroy
::DeleteObjectJob.perform_later(@inbox, Current.user, request.ip) if @inbox.present?
if @inbox.present?
# Invalidate cache immediately so frontends don't serve stale data
# while the async DeleteObjectJob is still in the queue.
Current.account.update_cache_key('inbox')
::DeleteObjectJob.perform_later(@inbox, Current.user, request.ip)
end
render status: :ok, json: { message: I18n.t('messages.inbox_deletetion_response') }
end
@@ -84,6 +84,15 @@ class CacheEnabledApiClient extends ApiClient {
return response;
}
async clearDataInCache() {
try {
await this.dataManager.initDb();
await this.dataManager.db.clear(this.cacheModelName);
} catch {
// Ignore error
}
}
async validateCacheKey(cacheKeyFromApi) {
if (!this.dataManager.db) {
await this.dataManager.initDb();
@@ -324,6 +324,8 @@ export const actions = {
try {
await InboxesAPI.delete(inboxId);
commit(types.default.DELETE_INBOXES, inboxId);
// Clear IndexedDB so stale inbox data isn't served on page refresh
await InboxesAPI.clearDataInCache();
commit(types.default.SET_INBOXES_UI_FLAG, { isDeleting: false });
} catch (error) {
commit(types.default.SET_INBOXES_UI_FLAG, { isDeleting: false });