quarchive icon indicating copy to clipboard operation
quarchive copied to clipboard

Make the extension's merge use the EXACT same logic for determining which is more recent

Open calpaterson opened this issue 4 years ago • 0 comments

The server uses this to determine which of two bookmarks being merged is more recent:

        more_recent: "Bookmark" = sorted(
            (self, other),
            # 1. Take the most recently updated.
            # 2. If they're equally recent, take the longer title
            # 3. If that's not enough add the longest description
            # 4. If that's not enough compare the titles
            # 5. If that's not enough compare the description
            # 6. Then compare everything else
            key=lambda b: (
                b.updated,
                len(b.title),
                len(b.description),
                b.title,
                b.description,
                b.unread,
                not b.deleted,
            ),
            reverse=True,
        )[0]

The extension uses just this:

        let moreRecent;
        // --snip--
        if (this.updated > other.updated) {
            moreRecent = this;
        } else if (other.updated > this.updated) {
            moreRecent = other;
        } else {
            const thisLengths = this.title.length + this.description.length;
            const otherLengths = other.title.length + other.description.length;
            if (otherLengths > thisLengths) {
                moreRecent = other;
            } else {
                moreRecent = this;
            }
        }

These need to be brought into line with each other

calpaterson avatar Jan 10 '21 13:01 calpaterson