mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
core: fix invalid object-ids generated on desktop
This commit is contained in:
@@ -17,12 +17,8 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const supportsPid =
|
|
||||||
"process" in globalThis &&
|
|
||||||
(typeof process === "undefined" || typeof process.pid !== "number");
|
|
||||||
const MACHINE_ID = Math.floor(Math.random() * 0xffffff);
|
const MACHINE_ID = Math.floor(Math.random() * 0xffffff);
|
||||||
const pid =
|
const pid = Math.floor(Math.random() * 100000) % 0xffff;
|
||||||
(supportsPid ? process.pid : Math.floor(Math.random() * 100000)) % 0xffff;
|
|
||||||
let index = Math.floor(Math.random() * 0xffffff);
|
let index = Math.floor(Math.random() * 0xffffff);
|
||||||
const PROCESS_UNIQUE = MACHINE_ID.toString(16) + pid.toString(16);
|
const PROCESS_UNIQUE = MACHINE_ID.toString(16) + pid.toString(16);
|
||||||
export function createObjectId(date = Date.now()): string {
|
export function createObjectId(date = Date.now()): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user