Skip to content

Commit

Permalink
Backup friend order
Browse files Browse the repository at this point in the history
  • Loading branch information
Natsumi-sama committed Sep 27, 2024
1 parent 9805a34 commit aaf589b
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions html/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9183,6 +9183,40 @@ speechSynthesis.getVoices();
this.deleteFriend(id);
}
}

this.saveFriendOrder();
};

$app.methods.saveFriendOrder = async function () {
var currentTime = Date.now();
var lastStoreTime = await configRepository.getString(
`VRCX_lastStoreTime_${API.currentUser.id}`,
''
);
// store once every week
if (lastStoreTime && currentTime - lastStoreTime < 604800000) {
return;
}
var storedData = {};
try {
var data = await configRepository.getString(
`VRCX_friendOrder_${API.currentUser.id}`
);
if (data) {
var storedData = JSON.parse(data);
}
} catch (err) {
console.error(err);
}
storedData[currentTime] = Array.from(this.friends.keys());
await configRepository.setString(
`VRCX_friendOrder_${API.currentUser.id}`,
JSON.stringify(storedData)
);
await configRepository.setString(
`VRCX_lastStoreTime_${API.currentUser.id}`,
currentTime
);
};

$app.methods.addFriend = function (id, state) {
Expand Down

0 comments on commit aaf589b

Please sign in to comment.