Add StoryDb::delete_active_stories.
This commit is contained in:
parent
6685bcfd7a
commit
b0510432a5
@ -102,6 +102,9 @@ class StoryDbImpl final : public StoryDbSyncInterface {
|
||||
TRY_RESULT_ASSIGN(add_active_stories_stmt_,
|
||||
db_.get_statement("INSERT OR REPLACE INTO active_stories VALUES(?1, ?2, ?3, ?4)"));
|
||||
|
||||
TRY_RESULT_ASSIGN(delete_active_stories_stmt_,
|
||||
db_.get_statement("DELETE FROM active_stories WHERE dialog_id = ?1"));
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
@ -222,6 +225,14 @@ class StoryDbImpl final : public StoryDbSyncInterface {
|
||||
add_active_stories_stmt_.step().ensure();
|
||||
}
|
||||
|
||||
void delete_active_stories(DialogId dialog_id) final {
|
||||
SCOPE_EXIT {
|
||||
delete_active_stories_stmt_.reset();
|
||||
};
|
||||
delete_active_stories_stmt_.bind_int64(1, dialog_id.get()).ensure();
|
||||
delete_active_stories_stmt_.step().ensure();
|
||||
}
|
||||
|
||||
Status begin_write_transaction() final {
|
||||
return db_.begin_write_transaction();
|
||||
}
|
||||
@ -239,6 +250,7 @@ class StoryDbImpl final : public StoryDbSyncInterface {
|
||||
SqliteStatement get_stories_from_notification_id_stmt_;
|
||||
|
||||
SqliteStatement add_active_stories_stmt_;
|
||||
SqliteStatement delete_active_stories_stmt_;
|
||||
};
|
||||
|
||||
std::shared_ptr<StoryDbSyncSafeInterface> create_story_db_sync(
|
||||
@ -296,6 +308,10 @@ class StoryDbAsync final : public StoryDbAsyncInterface {
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void delete_active_stories(DialogId dialog_id, Promise<Unit> promise) final {
|
||||
send_closure_later(impl_, &Impl::delete_active_stories, dialog_id, std::move(promise));
|
||||
}
|
||||
|
||||
void close(Promise<Unit> promise) final {
|
||||
send_closure_later(impl_, &Impl::close, std::move(promise));
|
||||
}
|
||||
@ -355,6 +371,13 @@ class StoryDbAsync final : public StoryDbAsyncInterface {
|
||||
});
|
||||
}
|
||||
|
||||
void delete_active_stories(DialogId dialog_id, Promise<Unit> promise) {
|
||||
add_write_query([this, dialog_id, promise = std::move(promise)](Unit) mutable {
|
||||
sync_db_->delete_active_stories(dialog_id);
|
||||
on_write_result(std::move(promise));
|
||||
});
|
||||
}
|
||||
|
||||
void close(Promise<Unit> promise) {
|
||||
do_flush();
|
||||
sync_db_safe_.reset();
|
||||
|
@ -53,6 +53,8 @@ class StoryDbSyncInterface {
|
||||
virtual void add_active_stories(DialogId dialog_id, StoryListId story_list_id, int64 dialog_order,
|
||||
BufferSlice data) = 0;
|
||||
|
||||
virtual void delete_active_stories(DialogId dialog_id) = 0;
|
||||
|
||||
virtual Status begin_write_transaction() = 0;
|
||||
virtual Status commit_transaction() = 0;
|
||||
};
|
||||
@ -89,6 +91,8 @@ class StoryDbAsyncInterface {
|
||||
virtual void add_active_stories(DialogId dialog_id, StoryListId story_list_id, int64 dialog_order, BufferSlice data,
|
||||
Promise<Unit> promise) = 0;
|
||||
|
||||
virtual void delete_active_stories(DialogId dialog_id, Promise<Unit> promise) = 0;
|
||||
|
||||
virtual void close(Promise<Unit> promise) = 0;
|
||||
virtual void force_flush() = 0;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user