move method
Moves the ChatId of ChatMessage from from
to to
.
Implementation
Future<void> move(ChatId from, ChatId to) async {
_cache.remove(from);
_controllers[to]?.close();
final StreamController<ChatMessage?>? controller = _controllers.remove(
from,
);
if (controller != null) {
_controllers[to] = controller;
}
await safe((db) async {
final stmt = db.select(db.drafts)
..where((e) => e.chatId.equals(from.val));
final row = await stmt.getSingleOrNull();
if (row != null) {
await db
.update(db.drafts)
.replace(DraftRow(chatId: to.val, data: row.data));
}
});
}