fix(PostImages, CreatePostScreen): adjust image gap for improved layout consistency
Some checks failed
Frontend CI / build-and-push-web (push) Successful in 9m17s
Frontend CI / ota-android (push) Successful in 11m48s
Frontend CI / build-android-apk (push) Successful in 1h12m38s
Frontend CI / ota-android (pull_request) Has been skipped
Frontend CI / build-and-push-web (pull_request) Failing after 37s
Frontend CI / build-android-apk (pull_request) Has been cancelled

- Reduced image gap in PostImages and CreatePostScreen components from 12 to 4 (desktop) and 8 to 2 (mobile) for better spacing.
- Updated ImageGrid component to modify grid item widths for enhanced layout.
- Refactored PostRepository to improve local caching logic, ensuring non-blocking UI updates during cache writes.
- Introduced saveConversationsWithRelatedCache function to streamline conversation, user, and group data saving in the database.
This commit is contained in:
lafay
2026-03-25 17:08:11 +08:00
parent f875b417c8
commit 619f08275c
7 changed files with 91 additions and 49 deletions

View File

@@ -265,10 +265,13 @@ export class PostRepository implements IPostRepository {
const posts = (response.list || []).map(p => this.mapToPost(p));
// 缓存帖子
posts.forEach(post => {
for (const post of posts) {
this.saveToMemoryCache(post);
this.saveToLocalCache(post);
});
// 不等待本地缓存写入完成,避免阻塞 UI
this.saveToLocalCache(post).catch(err => {
console.warn('[PostRepository] 缓存帖子失败:', post.id, err);
});
}
// 计算 hasMore优先使用 has_more否则通过 page/total_pages 计算
let hasMore = response.has_more;
@@ -338,10 +341,12 @@ export class PostRepository implements IPostRepository {
const posts = (response.list || []).map(p => this.mapToPost(p));
// 缓存帖子
posts.forEach(post => {
for (const post of posts) {
this.saveToMemoryCache(post);
this.saveToLocalCache(post);
});
this.saveToLocalCache(post).catch(err => {
console.warn('[PostRepository] 缓存帖子失败:', post.id, err);
});
}
return {
posts,
@@ -373,10 +378,12 @@ export class PostRepository implements IPostRepository {
const posts = (response.list || []).map(p => this.mapToPost(p));
// 缓存帖子
posts.forEach(post => {
for (const post of posts) {
this.saveToMemoryCache(post);
this.saveToLocalCache(post);
});
this.saveToLocalCache(post).catch(err => {
console.warn('[PostRepository] 缓存帖子失败:', post.id, err);
});
}
return {
posts,