🔒 (notes): 新想法默认私有,设置里可改可见范围
公开和仅关注只对新想法生效。已有想法沿用原来记下的范围。
This commit is contained in:
1 parent
352ee1bd99
commit
338e2d2d3c
10 files changed
+207
-61
No files matched your search
@@ -287,3 +287,46 @@ do -- 没记过可见范围的旧想法:修改不带 isPrivate,也不回读
|
||||
Assert.is_true(name ~= "reviewSingleAsync")
|
||||
end
|
||||
end
|
||||
|
||||
do -- 设置成仅关注:新想法带 friendship,不再读私密阅读
|
||||
require("moonsource_weread.context").clear()
|
||||
local Settings = require("utils.settings")
|
||||
local cfg = Settings.getSource("weread")
|
||||
local old = cfg.note_visibility
|
||||
cfg.note_visibility = "follow"
|
||||
Settings.saveSource("weread", cfg)
|
||||
local Toc = require("moonsource_weread.toc")
|
||||
local Position = require("moonsource_weread.progress")
|
||||
local old_read, old_load = Toc.read, Position.loadAsync
|
||||
Toc.read = function() return { { uid = "c1" } } end
|
||||
Position.loadAsync = function(_identity, _chapter, cb)
|
||||
cb("<html><body><p>原文</p></body></html>", "html")
|
||||
return nil
|
||||
end
|
||||
local item = {
|
||||
drawer = "lighten", text = "原文", note = "给关注的人",
|
||||
wr_range = "1-2", wr_review_only = true,
|
||||
pos0 = "/html/body/p/text().0", pos1 = "/html/body/p/text().2",
|
||||
}
|
||||
local client = fakeClient({
|
||||
bookmarkListAsync = { updated = {} },
|
||||
myReviewsAsync = { reviews = {}, hasMore = 0, totalCount = 0 },
|
||||
addReviewAsync = { reviewId = "rv-follow" },
|
||||
reviewSingleAsync = { review = { isPrivate = 0, friendship = 1 } },
|
||||
})
|
||||
local ok, err
|
||||
NotesPush.run(client, identity, "c1",
|
||||
"<html><body><p>原文</p></body></html>", { item }, function(o, e) ok, err = o, e end)
|
||||
Stubs.flush()
|
||||
Toc.read, Position.loadAsync = old_read, old_load
|
||||
cfg.note_visibility = old
|
||||
Settings.saveSource("weread", cfg)
|
||||
Assert.is_true(ok, tostring(err))
|
||||
Assert.eq(client.sent.addReviewAsync[1].isPrivate, 0)
|
||||
Assert.eq(client.sent.addReviewAsync[1].friendship, 1)
|
||||
Assert.eq(item.wr_friendship, 1)
|
||||
Assert.eq(item.wr_private, 0)
|
||||
for _, name in ipairs(client.calls) do
|
||||
Assert.is_true(name ~= "bookInfoAsync", "设置了范围就不必再读私密阅读")
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user