Skip to content

Commit 8cf5b48

Browse files
author
i2cjak
authored
Merge pull request #160 from i2cjak/mail/2u
Mailroom view model (pure, shared by all clients)
2 parents 39ca1ab + 5d3be4c commit 8cf5b48

4 files changed

Lines changed: 1182 additions & 0 deletions

File tree

‎LAWS.bend‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import ./src/core/usage.bend as UZ
55
import ./src/core/refview.bend as RC # links (cards, trail)
66
import ./src/core/mail.bend as ML # mail 1
77
import ./src/core/mailbody.bend as MB # mail 2a
8+
import ./src/core/mailview.bend as MVW # mail view
89
import ./src/core/ref.bend as REF
910
# ---- i18n cjk ----
1011
import ./src/core/cjk.bend as CJK
@@ -9106,3 +9107,26 @@ law prompt_lang_off:
91069107
law prompt_lang_unknown:
91079108
{PM.Prompt.lang("x") == "" : String}
91089109
# ---- end i18n lang ----
9110+
9111+
# ---- mail view ----
9112+
# the rows built for the visible window never run past the list
9113+
law mv_visible_bounds:
9114+
for +total: Nat
9115+
for +scroll: Nat
9116+
for +view: Nat
9117+
{Nat.is_ge(total, Nat.add(MVW.Mv.count(total, scroll, view), MVW.Mv.first(total, scroll, view))) == True{} : Bool}
9118+
9119+
# merging full-text hits into local ones never repeats a conversation
9120+
# (a closed case: local and server both repeat an id, and share one)
9121+
law mv_merge_no_dup:
9122+
{MVW.Mv.unique(MVW.Mv.merge_hits([MVW.Mv.stub("a", 9n), MVW.Mv.stub("b", 7n), MVW.Mv.stub("a", 9n)], [MVW.Mv.stub("b", 8n), MVW.Mv.stub("d", 6n), MVW.Mv.stub("a", 9n)])) == True{} : Bool}
9123+
9124+
# a newer page for the same slots leaves the ids of rows it did not change
9125+
law mv_rows_stable:
9126+
{MVW.Mv.ids(MVW.Mv.rows(MVW.Mv.put_page(MVW.Mv.put_page(MVW.Mv.cache(), MVW.Mv.filter(), 0n, 3n, [MVW.Mv.stub("a", 9n), MVW.Mv.stub("b", 7n), MVW.Mv.stub("c", 5n)]), MVW.Mv.filter(), 0n, 3n, [MVW.Mv.stub("a", 9n), MVW.Mv.stub("b", 11n), MVW.Mv.stub("c", 5n)]), MVW.Mv.key(MVW.Mv.filter()), 0n, 3n)) == "a,b,c," : String}
9127+
9128+
# two chips that differ never share a cache key, even with a "|" in a name
9129+
law mv_filter_key_separates:
9130+
{String.eq(MVW.Mv.key(MVW.Filter{"a|b", "", "c", ""}), MVW.Mv.key(MVW.Filter{"a", "|b", "c", ""})) == False{} : Bool}
9131+
9132+
# ---- end mail view ----

‎PROOF.bend‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import ./src/core/i18n.bend as I18
33
import ./test/fixtures/i18n_fallback.bend as I18F
44
import ./src/core/mail.bend as ML # mail 1
55
import ./src/core/mailbody.bend as MB # mail 2a
6+
import ./src/core/mailview.bend as MVW # mail view
67
import ./src/core/stamp.bend as STP
78
import ./src/core/tz.bend as TZ
89
import ./src/core/when.bend as WH
@@ -10945,3 +10946,18 @@ def Laws.prompt_lang_off():
1094510946
def Laws.prompt_lang_unknown():
1094610947
{==}
1094710948
# ---- end i18n lang ----
10949+
10950+
# ---- mail view ----
10951+
def Laws.mv_visible_bounds(total, scroll, view):
10952+
Laws.menu_scroll_in_list(MVW.Mv.first_raw(scroll), total, MVW.Mv.count(total, scroll, view), le_ge(MVW.Mv.count(total, scroll, view), total, min_le_k(Nat.is_le(MVW.Mv.want(scroll, view), total), MVW.Mv.want(scroll, view), total, {==})))
10953+
10954+
def Laws.mv_merge_no_dup():
10955+
{==}
10956+
10957+
def Laws.mv_rows_stable():
10958+
{==}
10959+
10960+
def Laws.mv_filter_key_separates():
10961+
{==}
10962+
10963+
# ---- end mail view ----

0 commit comments

Comments
 (0)