优化列表同步代码逻辑
parent
8810e25ea9
commit
001eba6729
|
@ -1,4 +1,3 @@
|
||||||
### 修复
|
### 优化
|
||||||
|
|
||||||
- 修复我的列表搜索无法搜索小括号、中括号等字符的问题
|
- 优化列表同步代码逻辑
|
||||||
- 修复v1.14.0出现的备份与恢复功能备份的数据无法恢复的问题,同时兼容使用v1.14.0导出的存在问题的数据
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ const modules = require('../modules')
|
||||||
const { authCode, authConnect } = require('./auth')
|
const { authCode, authConnect } = require('./auth')
|
||||||
const { getAddress, getServerId, generateCode, getClientKeyInfo } = require('./utils')
|
const { getAddress, getServerId, generateCode, getClientKeyInfo } = require('./utils')
|
||||||
const syncList = require('./syncList')
|
const syncList = require('./syncList')
|
||||||
|
const { log } = require('@common/utils')
|
||||||
|
|
||||||
|
|
||||||
let status = {
|
let status = {
|
||||||
|
@ -88,7 +89,8 @@ const handleStartServer = (port = 9527) => new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
await syncList(io, socket)
|
await syncList(io, socket)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err)
|
// console.log(err)
|
||||||
|
log.warn(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
status.devices.push(keyInfo)
|
status.devices.push(keyInfo)
|
||||||
|
|
|
@ -260,10 +260,7 @@ const mergeListDataFromSnapshot = (sourceList, targetList, snapshotList, addMusi
|
||||||
for (const m of sourceList.list) sourceListItemIds.add(m.songmid)
|
for (const m of sourceList.list) sourceListItemIds.add(m.songmid)
|
||||||
for (const m of targetList.list) targetListItemIds.add(m.songmid)
|
for (const m of targetList.list) targetListItemIds.add(m.songmid)
|
||||||
for (const m of snapshotList.list) {
|
for (const m of snapshotList.list) {
|
||||||
if (!sourceListItemIds.has(m.songmid)) removedListIds.add(m.songmid)
|
if (!sourceListItemIds.has(m.songmid) || !targetListItemIds.has(m.songmid)) removedListIds.add(m.songmid)
|
||||||
}
|
|
||||||
for (const m of snapshotList.list) {
|
|
||||||
if (!targetListItemIds.has(m.songmid)) removedListIds.add(m.songmid)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let newList
|
let newList
|
||||||
|
@ -311,10 +308,7 @@ const handleMergeListDataFromSnapshot = async(socket, snapshot) => {
|
||||||
for (const l of remoteListData.userList) remoteUserListIds.add(l.id)
|
for (const l of remoteListData.userList) remoteUserListIds.add(l.id)
|
||||||
|
|
||||||
for (const l of snapshot.userList) {
|
for (const l of snapshot.userList) {
|
||||||
if (!localUserListIds.has(l.id)) removedListIds.add(l.id)
|
if (!localUserListIds.has(l.id) || !remoteUserListIds.has(l.id)) removedListIds.add(l.id)
|
||||||
}
|
|
||||||
for (const l of snapshot.userList) {
|
|
||||||
if (!remoteUserListIds.has(l.id)) removedListIds.add(l.id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let newUserList = []
|
let newUserList = []
|
||||||
|
@ -353,7 +347,7 @@ const registerUpdateSnapshotTask = (socket, snapshot) => {
|
||||||
if (loveList != null) snapshot.loveList = loveList
|
if (loveList != null) snapshot.loveList = loveList
|
||||||
if (userList != null) snapshot.userList = userList
|
if (userList != null) snapshot.userList = userList
|
||||||
updateSnapshot(socket.data.snapshotFilePath, JSON.stringify(snapshot))
|
updateSnapshot(socket.data.snapshotFilePath, JSON.stringify(snapshot))
|
||||||
}, 10000)
|
}, 2000)
|
||||||
global.lx_event.common.on(COMMON_EVENT_NAME.saveMyList, handleUpdateSnapshot)
|
global.lx_event.common.on(COMMON_EVENT_NAME.saveMyList, handleUpdateSnapshot)
|
||||||
socket.on('disconnect', () => {
|
socket.on('disconnect', () => {
|
||||||
global.lx_event.common.off(COMMON_EVENT_NAME.saveMyList, handleUpdateSnapshot)
|
global.lx_event.common.off(COMMON_EVENT_NAME.saveMyList, handleUpdateSnapshot)
|
||||||
|
|
Loading…
Reference in New Issue