on master help sign in
Replace ListBox with ScrollViewer+VStack to fix conversation view not updating on new messages
5feb666iko
client/ViewConversations.fs+37−37
@@ -32,51 +32,51 @@ module ViewConversations =
32 )
32 )
33 else
33 else
34 AnyView(
34 AnyView(
35− ListBox(
35+ ScrollViewer(
36− contacts,
36+ VStack(0.) {
37− fun c ->
37+ for c in contacts do
38− let name = contactName model.Contacts c.Pubkey
38+ let name = contactName model.Contacts c.Pubkey
39
39
40− let preview =
40+ let preview =
41− messagesFor c.Pubkey model.Messages
41+ messagesFor c.Pubkey model.Messages
42− |> List.tryLast
42+ |> List.tryLast
43− |> Option.map (fun m -> if m.Body.Length > 40 then m.Body.[..39] + "..." else m.Body)
43+ |> Option.map (fun m -> if m.Body.Length > 40 then m.Body.[..39] + "..." else m.Body)
44− |> Option.defaultValue ""
44+ |> Option.defaultValue ""
45
45
46− Border(
46+ Border(
47− (HStack(8.) {
47+ (HStack(8.) {
48
48
49− Grid() {
49+ Grid() {
50− (match c.Photo with
50+ (match c.Photo with
51− | None -> Image("avares://Skrepka/Assets/Images/user.png", Stretch.Uniform)
51+ | None -> Image("avares://Skrepka/Assets/Images/user.png", Stretch.Uniform)
52− | Some i -> Image(cachedBitmap i, Stretch.UniformToFill))
52+ | Some i -> Image(cachedBitmap i, Stretch.UniformToFill))
53− .width(16.)
53+ .width(16.)
54− .height(16.)
54+ .height(16.)
55− .margin(8.)
55+ .margin(8.)
56− .clipToBounds (true)
56+ .clipToBounds (true)
57
57
58− Rectangle().stroke(Colors.Black).strokeThickness (4.)
58+ Rectangle().stroke(Colors.Black).strokeThickness (4.)
59− }
59+ }
60
60
61− VStack(2.) {
61+ VStack(2.) {
62− TextBlock(name)
62+ TextBlock(name)
63− .fontFamily(Constants.fontFamily)
63+ .fontFamily(Constants.fontFamily)
64− .fontWeight(FontWeight.Bold)
64+ .fontWeight(FontWeight.Bold)
65− .fontSize (16.)
65+ .fontSize (16.)
66
66
67− if preview <> "" then
67+ if preview <> "" then
68− TextBlock(preview).fontSize(12.).fontWeight (FontWeight.Bold)
68+ TextBlock(preview).fontSize(12.).fontWeight (FontWeight.Bold)
69− }
69+ }
70
70
71− })
71+ })
72− .margin (8.)
72+ .margin (8.)
73− )
73+ )
74− .borderThickness(Avalonia.Thickness(0., 0., 0., 4.))
74+ .borderThickness(Avalonia.Thickness(0., 0., 0., 4.))
75− .borderBrush(SolidColorBrush(Colors.Black))
75+ .borderBrush(SolidColorBrush(Colors.Black))
76− .background(Colors.Transparent)
76+ .background(Colors.Transparent)
77− .onTapped (fun _ -> SetPage(Chat(c.Pubkey, "")))
77+ .onTapped (fun _ -> SetPage(Chat(c.Pubkey, "")))
78+ }
78 )
79 )
79− .styles(noListBoxPadding ())
80 .background(Colors.White)
80 .background(Colors.White)
81 .verticalAlignment (VerticalAlignment.Bottom)
81 .verticalAlignment (VerticalAlignment.Bottom)
82 )
82 )