76f266645d
含 Phase 1.1 IM seq 排序、断线重连、多端已读同步与微信式语音转文字 UI。 排除 node_modules、构建产物、安装包与 .env 密钥。 Co-authored-by: Cursor <cursoragent@cursor.com>
33 lines
960 B
Dart
33 lines
960 B
Dart
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
/// 自定义表情:服务端 fileId 列表。GIF / 表情面板发出的都走这里。
|
|
class StickerStore {
|
|
StickerStore._();
|
|
static const _key = 'im.stickers';
|
|
static SharedPreferences? _p;
|
|
static List<String> _ids = [];
|
|
|
|
static List<String> get ids => List.unmodifiable(_ids);
|
|
|
|
static Future<void> ensure() async {
|
|
_p ??= await SharedPreferences.getInstance();
|
|
_ids = _p!.getStringList(_key) ?? [];
|
|
}
|
|
|
|
static bool has(String fileId) => fileId.isNotEmpty && _ids.contains(fileId);
|
|
|
|
static Future<void> add(String fileId) async {
|
|
if (fileId.isEmpty) return;
|
|
await ensure();
|
|
if (_ids.contains(fileId)) return;
|
|
_ids = [fileId, ..._ids];
|
|
await _p!.setStringList(_key, _ids);
|
|
}
|
|
|
|
static Future<void> remove(String fileId) async {
|
|
await ensure();
|
|
_ids = _ids.where((e) => e != fileId).toList();
|
|
await _p!.setStringList(_key, _ids);
|
|
}
|
|
}
|