add local favorites friend

This commit is contained in:
pa
2026-02-11 22:38:15 +09:00
parent 6d76140e1d
commit 61a4176f47
9 changed files with 601 additions and 20 deletions
+5
View File
@@ -1,5 +1,6 @@
import { avatarFavorites } from './database/avatarFavorites.js';
import { feed } from './database/feed.js';
import { friendFavorites } from './database/friendFavorites.js';
import { friendLogCurrent } from './database/friendLogCurrent.js';
import { friendLogHistory } from './database/friendLogHistory.js';
import { gameLog } from './database/gameLog.js';
@@ -30,6 +31,7 @@ const database = {
...friendLogCurrent,
...memos,
...avatarFavorites,
...friendFavorites,
...worldFavorites,
...tableAlter,
...tableFixes,
@@ -126,6 +128,9 @@ const database = {
await sqliteService.executeNonQuery(
`CREATE TABLE IF NOT EXISTS favorite_avatar (id INTEGER PRIMARY KEY, created_at TEXT, avatar_id TEXT, group_name TEXT)`
);
await sqliteService.executeNonQuery(
`CREATE TABLE IF NOT EXISTS favorite_friend (id INTEGER PRIMARY KEY, created_at TEXT, user_id TEXT, group_name TEXT)`
);
await sqliteService.executeNonQuery(
`CREATE TABLE IF NOT EXISTS memos (user_id TEXT PRIMARY KEY, edited_at TEXT, memo TEXT)`
);
+58
View File
@@ -0,0 +1,58 @@
import sqliteService from '../sqlite.js';
const friendFavorites = {
addFriendToLocalFavorites(userId, groupName) {
sqliteService.executeNonQuery(
'INSERT OR REPLACE INTO favorite_friend (user_id, group_name, created_at) VALUES (@user_id, @group_name, @created_at)',
{
'@user_id': userId,
'@group_name': groupName,
'@created_at': new Date().toJSON()
}
);
},
removeFriendFromLocalFavorites(userId, groupName) {
sqliteService.executeNonQuery(
`DELETE FROM favorite_friend WHERE user_id = @user_id AND group_name = @group_name`,
{
'@user_id': userId,
'@group_name': groupName
}
);
},
renameFriendFavoriteGroup(newGroupName, groupName) {
sqliteService.executeNonQuery(
`UPDATE favorite_friend SET group_name = @new_group_name WHERE group_name = @group_name`,
{
'@new_group_name': newGroupName,
'@group_name': groupName
}
);
},
deleteFriendFavoriteGroup(groupName) {
sqliteService.executeNonQuery(
`DELETE FROM favorite_friend WHERE group_name = @group_name`,
{
'@group_name': groupName
}
);
},
async getFriendFavorites() {
const data = [];
await sqliteService.execute((dbRow) => {
const row = {
created_at: dbRow[1],
userId: dbRow[2],
groupName: dbRow[3]
};
data.push(row);
}, 'SELECT * FROM favorite_friend');
return data;
}
};
export { friendFavorites };