Harry-Chen / Learn-Helper

清华大学网络学堂助手
https://chrome.google.com/webstore/detail/learn-helper/mdehapphdlihjjgkhmoiknmnhcjpjall
MIT License
208 stars 37 forks source link

建议:作业按ddl和完成状态排序 #75

Closed RikaKagurasaka closed 4 years ago

RikaKagurasaka commented 4 years ago

现在的作业排序似乎是按ddl排序,最远的在最上面。

希望可以修改成先按完成状态排序,未完成的在上面(考虑到有些老师一股脑布置整学期的作业,也可以设置超过一定时间如两周的作业排在下面)。相同完成状态的按ddl排序,更近的在上面。

如果能自己设定就更好了(x)

Harry-Chen commented 4 years ago

排序逻辑:

newCards.sort((a, b) => {
  let result = compareBoolean(a.starred, b.starred);
  if (result !== 0) return result;
  result = compareBoolean(!a.hasRead, !b.hasRead);
  if (result !== 0) return result;
  const aNotDue = a.type === ContentType.HOMEWORK && a.date.getTime() > new Date().getTime();
  const bNotDue = b.type === ContentType.HOMEWORK && b.date.getTime() > new Date().getTime();
  result = compareBoolean(aNotDue, bNotDue);
  if (result !== 0) return result;
  return b.date.getTime() - a.date.getTime();
});

优先级是:

可能还需要精细调整一下

Harry-Chen commented 4 years ago

目前的修改:未完成的作业按照 ddl 反向排序,ddl 越近越靠上。完成的作业混在下面一起排序,过去的天数越少越靠上。

Harry-Chen commented 4 years ago

Fixed in 147440d5d6aec5a00ef95a189c19c0c2dd647276 (忘了写在 commit log 了)