this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Slightly rename message variants to reflect what happened instead of what should happen.

+89 -71
+28 -23
client/src/lumina_client.gleam
··· 33 33 import lumina_client/dom 34 34 import lumina_client/helpers.{login_view_checker, model_local_storage_key} 35 35 import lumina_client/model_type.{ 36 - type Model, type Msg, FocusLostEmailField, HomeTimeline, Landing, Licence, 37 - Login, LoginFields, Logout, Model, NotFound, Past150ms, Register, 38 - RegisterPageFields, SubmitLogin, SubmitSignup, ToLandingPage, ToLoginPage, 39 - ToRegisterPage, UpdateEmailField, UpdateLastRefreshRequestTime, 40 - UpdatePasswordConfirmField, UpdatePasswordField, UpdateUsernameField, 41 - WSTryReconnect, WsDisconnectDefinitive, WsWrapper, 36 + type Model, type Msg, EffectPast150ms, EmailFieldLostFocus, HomeTimeline, 37 + Landing, Licence, Login, LoginFields, Model, NotFound, Register, 38 + RegisterPageFields, UpdateLastRefreshRequestTime, UserClickedLogout, 39 + UserNavigatedToLandingPage, UserNavigatedToLoginPage, 40 + UserNavigatedToRegisterPage, UserSubmittedLogin, UserSubmittedSignup, 41 + UserUpdatedControlledEmailField, UserUpdatedControlledPasswordConfirmField, 42 + UserUpdatedControlledPasswordField, UserUpdatedControlledUsernameField, 43 + WSTryReconnect, WebSocketIncomingMessage, WsDisconnectDefinitive, 42 44 } 43 45 44 46 import lumina_client/view.{view} ··· 170 172 } 171 173 }, 172 174 effect.batch([ 173 - lustre_websocket.init("/connection", WsWrapper), 175 + lustre_websocket.init("/connection", WebSocketIncomingMessage), 174 176 count_to_150(), 175 177 ]), 176 178 ) ··· 184 186 pub fn count_to_150() { 185 187 use dispatch <- effect.from 186 188 use <- helpers.set_timeout_nilled(150) 187 - dispatch(Past150ms) 189 + dispatch(EffectPast150ms) 188 190 } 189 191 190 192 fn let_definitely_disconnect(model: Model) { ··· 204 206 205 207 fn update(model: Model, msg: Msg) -> #(Model, Effect(Msg)) { 206 208 case msg { 207 - Past150ms -> { 209 + EffectPast150ms -> { 208 210 #(Model(..model, has_been_running_for_150ms: True), effect.none()) 209 211 } 210 212 UpdateLastRefreshRequestTime(new_time) -> { ··· 235 237 ) 236 238 } 237 239 // Catch other Ws Events in a different function, since that is generally very different stuff. 238 - WsWrapper(event) -> update_ws(model, event) 239 - ToLoginPage -> #( 240 + WebSocketIncomingMessage(event) -> update_ws(model, event) 241 + UserNavigatedToLoginPage -> #( 240 242 Model(..model, page: Login(fields: LoginFields("", ""), success: None)), 241 243 effect.none(), 242 244 ) 243 - ToRegisterPage -> #( 245 + UserNavigatedToRegisterPage -> #( 244 246 Model( 245 247 ..model, 246 248 page: Register(fields: RegisterPageFields("", "", "", ""), ready: None), 247 249 ), 248 250 effect.none(), 249 251 ) 250 - ToLandingPage -> #(Model(..model, page: Landing), effect.none()) 251 - UpdateEmailField(new_email) -> { 252 + UserNavigatedToLandingPage -> #( 253 + Model(..model, page: Landing), 254 + effect.none(), 255 + ) 256 + UserUpdatedControlledEmailField(new_email) -> { 252 257 case model.page { 253 258 Register(fields, ready) -> #( 254 259 Model( ··· 284 289 _ -> #(model, effect.none()) 285 290 } 286 291 } 287 - UpdatePasswordField(new_password) -> { 292 + UserUpdatedControlledPasswordField(new_password) -> { 288 293 case model.page { 289 294 Register(fields, ready) -> #( 290 295 Model( ··· 342 347 _ -> #(model, effect.none()) 343 348 } 344 349 } 345 - UpdatePasswordConfirmField(new_password_confirmation) -> { 350 + UserUpdatedControlledPasswordConfirmField(new_password_confirmation) -> { 346 351 case model.page { 347 352 Register(fields, ready) -> #( 348 353 Model( ··· 371 376 _ -> #(model, effect.none()) 372 377 } 373 378 } 374 - UpdateUsernameField(new_username) -> { 379 + UserUpdatedControlledUsernameField(new_username) -> { 375 380 case model.page { 376 381 Register(fields, ready) -> #( 377 382 Model( ··· 406 411 _ -> #(model, effect.none()) 407 412 } 408 413 } 409 - FocusLostEmailField -> { 414 + EmailFieldLostFocus -> { 410 415 // This handles the login username/email field value once the user seems to be done typing. 411 416 let assert Login(fields, _success) = model.page 412 417 let value = case string.starts_with(fields.emailfield, "@") { ··· 437 442 effect.none(), 438 443 ) 439 444 } 440 - Logout -> session_destroy() 441 - SubmitLogin(_) -> { 445 + UserClickedLogout -> session_destroy() 446 + UserSubmittedLogin(_) -> { 442 447 let assert Login(fields, _) = model.page 443 448 let values_ok = login_view_checker(fields) 444 449 case values_ok { ··· 463 468 } 464 469 } 465 470 } 466 - SubmitSignup(_) -> { 471 + UserSubmittedSignup(_) -> { 467 472 let assert Register(fields, ready) = model.page 468 473 469 474 case ··· 495 500 } 496 501 } 497 502 } 498 - model_type.TimeLineTo(tid) -> { 503 + model_type.UserSwitchedTimeLineTo(tid) -> { 499 504 let assert model_type.WsConnectionConnected(socket) = model.ws 500 505 as "Socket not connected" 501 506 let model = case model.page { ··· 546 551 _ -> #(model, effect.none()) 547 552 } 548 553 } 549 - model_type.CloseModal -> { 554 + model_type.UserClosedModal -> { 550 555 case model.page { 551 556 HomeTimeline(timeline_name:, modal: _) -> #( 552 557 Model(..model, page: HomeTimeline(timeline_name:, modal: None)),
+15 -15
client/src/lumina_client/model_type.gleam
··· 27 27 28 28 pub type Msg { 29 29 WSTryReconnect 30 - Past150ms 30 + EffectPast150ms 31 31 UpdateLastRefreshRequestTime(Int) 32 32 WsDisconnectDefinitive 33 - WsWrapper(lustre_websocket.WebSocketEvent) 34 - ToLoginPage 35 - SubmitLogin(List(#(String, String))) 36 - ToRegisterPage 37 - SubmitSignup(List(#(String, String))) 38 - ToLandingPage 33 + WebSocketIncomingMessage(lustre_websocket.WebSocketEvent) 34 + UserNavigatedToLoginPage 35 + UserNavigatedToRegisterPage 36 + UserNavigatedToLandingPage 37 + UserSubmittedLogin(List(#(String, String))) 38 + UserSubmittedSignup(List(#(String, String))) 39 39 // Can be re-used for both login and register pages 40 - UpdateEmailField(String) 41 - UpdatePasswordField(String) 40 + UserUpdatedControlledEmailField(String) 41 + UserUpdatedControlledPasswordField(String) 42 42 // Register page 43 - UpdateUsernameField(String) 44 - UpdatePasswordConfirmField(String) 45 - FocusLostEmailField 43 + UserUpdatedControlledUsernameField(String) 44 + UserUpdatedControlledPasswordConfirmField(String) 45 + EmailFieldLostFocus 46 46 /// Travel to a different timeline. 47 - TimeLineTo(String) 47 + UserSwitchedTimeLineTo(String) 48 48 /// Load more posts for the current timeline 49 49 LoadMorePosts(String) 50 50 /// Log the user out (destroys session and recreates model) 51 - Logout 51 + UserClickedLogout 52 52 /// Close current modal 53 - CloseModal 53 + UserClosedModal 54 54 /// Browse modal to different page 55 55 SetModal(String) 56 56 /// Start dragging the modal box
+29 -21
client/src/lumina_client/view.gleam
··· 27 27 } 28 28 import lumina_client/model_type.{ 29 29 type Model, type Msg, HomeTimeline, Landing, Licence, Login, NotFound, 30 - Register, SubmitLogin, SubmitSignup, ToLandingPage, ToLoginPage, 31 - ToRegisterPage, UpdateEmailField, UpdatePasswordConfirmField, 32 - UpdatePasswordField, UpdateUsernameField, WSTryReconnect, 30 + Register, UserNavigatedToLandingPage, UserNavigatedToLoginPage, 31 + UserNavigatedToRegisterPage, UserSubmittedLogin, UserSubmittedSignup, 32 + UserUpdatedControlledEmailField, UserUpdatedControlledPasswordConfirmField, 33 + UserUpdatedControlledPasswordField, UserUpdatedControlledUsernameField, 34 + WSTryReconnect, 33 35 } 34 36 import lumina_client/view/common_view_parts.{common_view_parts} 35 37 import lumina_client/view/common_view_parts/svgs ··· 145 147 html.button( 146 148 [ 147 149 attribute.class("btn btn-primary font-menuitems"), 148 - event.on_click(ToLoginPage), 150 + event.on_click(UserNavigatedToLoginPage), 149 151 ], 150 152 [element.text("Login")], 151 153 ), 152 154 html.button( 153 155 [ 154 156 attribute.class("btn btn-secondary font-menuitems"), 155 - event.on_click(ToRegisterPage), 157 + event.on_click(UserNavigatedToRegisterPage), 156 158 ], 157 159 [element.text("Register")], 158 160 ), ··· 504 506 attribute.class( 505 507 "card-body m-4 transition-[height] duration-300 ease-in-out transition", 506 508 ), 507 - event.on_submit(SubmitLogin), 509 + event.on_submit(UserSubmittedLogin), 508 510 ], 509 511 [ 510 512 html.fieldset([attribute.class("fieldset")], [ ··· 518 520 ), 519 521 attribute.type_("text"), 520 522 attribute.value(fieldvalues.emailfield), 521 - event.on_input(UpdateEmailField), 523 + event.on_input(UserUpdatedControlledEmailField), 522 524 event.on("focusout", { 523 - decode.success(model_type.FocusLostEmailField) 525 + decode.success(model_type.EmailFieldLostFocus) 524 526 }), 525 527 ]), 526 528 html.label([attribute.class("fieldset-label")], [ ··· 528 530 ]), 529 531 html.input([ 530 532 attribute.value(fieldvalues.passwordfield), 531 - event.on_input(UpdatePasswordField), 533 + event.on_input(UserUpdatedControlledPasswordField), 532 534 attribute.placeholder("Password"), 533 535 attribute.class( 534 536 "input input-primary bg-primary font-content", ··· 584 586 ), 585 587 ] 586 588 |> common_view_parts(with_menu: [ 587 - html.li([event.on_click(ToLandingPage)], [ 589 + html.li([event.on_click(UserNavigatedToLandingPage)], [ 588 590 html.a([], [element.text("Back")]), 589 591 ]), 590 - html.li([event.on_click(ToRegisterPage)], [ 592 + html.li([event.on_click(UserNavigatedToRegisterPage)], [ 591 593 html.a([], [element.text("Register")]), 592 594 ]), 593 - html.li([event.on_click(ToLoginPage)], [ 595 + html.li([event.on_click(UserNavigatedToLoginPage)], [ 594 596 html.a([attribute.class("bg-primary text-primary-content")], [ 595 597 element.text("Login"), 596 598 ]), ··· 623 625 attribute.class( 624 626 "card-body m-4 delay-150 duration-300 ease-in-out transition-[height]", 625 627 ), 626 - event.on_submit(SubmitSignup), 628 + event.on_submit(UserSubmittedSignup), 627 629 ], 628 630 [ 629 631 html.fieldset([attribute.class("fieldset")], [ ··· 637 639 ), 638 640 attribute.type_("email"), 639 641 attribute.value(fieldvalues.emailfield), 640 - event.on_input(UpdateEmailField), 642 + event.on_input(UserUpdatedControlledEmailField), 641 643 ]), 642 644 html.label([attribute.class("fieldset-label")], [ 643 645 element.text("Username"), ··· 649 651 ), 650 652 attribute.type_("string"), 651 653 attribute.value(fieldvalues.usernamefield), 652 - event.on_input(UpdateUsernameField), 654 + event.on_input(UserUpdatedControlledUsernameField), 653 655 ]), 654 656 html.label([attribute.class("fieldset-label")], [ 655 657 element.text("Password"), 656 658 ]), 657 659 html.input([ 658 660 attribute.value(fieldvalues.passwordfield), 659 - event.on_input(UpdatePasswordField), 661 + event.on_input(UserUpdatedControlledPasswordField), 660 662 attribute.placeholder("Password"), 661 663 attribute.class( 662 664 "input input-primary bg-primary font-content", ··· 668 670 ]), 669 671 html.input([ 670 672 attribute.value(fieldvalues.passwordconfirmfield), 671 - event.on_input(UpdatePasswordConfirmField), 673 + event.on_input( 674 + UserUpdatedControlledPasswordConfirmField, 675 + ), 672 676 attribute.placeholder("Re-type password"), 673 677 attribute.class( 674 678 "input input-primary bg-primary font-content", ··· 731 735 ), 732 736 html.a( 733 737 [ 734 - event.on_click(ToLoginPage), 738 + event.on_click( 739 + UserNavigatedToLoginPage, 740 + ), 735 741 attribute.class( 736 742 "link link-primary", 737 743 ), ··· 774 780 ), 775 781 ] 776 782 |> common_view_parts(with_menu: [ 777 - html.li([event.on_click(ToLandingPage)], [ 783 + html.li([event.on_click(UserNavigatedToLandingPage)], [ 778 784 html.a([], [element.text("Back")]), 779 785 ]), 780 - html.li([event.on_click(ToRegisterPage)], [ 786 + html.li([event.on_click(UserNavigatedToRegisterPage)], [ 781 787 html.a([attribute.class("bg-primary text-primary-content")], [ 782 788 element.text("Register"), 783 789 ]), 784 790 ]), 785 - html.li([event.on_click(ToLoginPage)], [html.a([], [element.text("Login")])]), 791 + html.li([event.on_click(UserNavigatedToLoginPage)], [ 792 + html.a([], [element.text("Login")]), 793 + ]), 786 794 ]) 787 795 }
+17 -12
client/src/lumina_client/view/homepage.gleam
··· 32 32 import lumina_client/dom 33 33 import lumina_client/helpers 34 34 import lumina_client/model_type.{ 35 - type CachedTimeline, type Model, type Msg, CachedTimeline, CloseModal, Logout, 36 - SetModal, StartDraggingModalBox, 35 + type CachedTimeline, type Model, type Msg, CachedTimeline, SetModal, 36 + StartDraggingModalBox, UserClickedLogout, UserClosedModal, 37 37 } 38 38 import lumina_client/view/common_view_parts.{common_view_parts} 39 39 import lumina_client/view/common_view_parts/svgs ··· 47 47 fn closemodal_not_for_modal_box() { 48 48 use target <- decode.field("target", decode.dynamic) 49 49 case bool.negate(dom.classfoundintree(target, "modal-box")) { 50 - True -> decode.success(CloseModal) 51 - False -> decode.failure(CloseModal, "Clicked inside modal-box, ignoring") 50 + True -> decode.success(UserClosedModal) 51 + False -> 52 + decode.failure(UserClosedModal, "Clicked inside modal-box, ignoring") 52 53 } 53 54 } 54 55 ··· 91 92 "btn rounded-none rounded-bl-sm btn-error absolute top-0 right-0 text-2xl", 92 93 ), 93 94 94 - event.on_click(CloseModal), 95 + event.on_click(UserClosedModal), 95 96 ], 96 97 [ 97 98 element.text( ··· 159 160 attribute.class( 160 161 "btn rounded-none rounded-bl-sm btn-error absolute top-0 right-0 text-2xl", 161 162 ), 162 - event.on_click(CloseModal), 163 + event.on_click(UserClosedModal), 163 164 ], 164 165 [element.text("×")], 165 166 ) ··· 195 196 attribute.class( 196 197 "btn rounded-none rounded-bl-sm btn-error absolute top-0 right-0 text-2xl", 197 198 ), 198 - event.on_click(CloseModal), 199 + event.on_click(UserClosedModal), 199 200 ], 200 201 [element.text("×")], 201 202 ), ··· 226 227 attribute.class( 227 228 "btn btn-circle btn-error absolute top-4 right-4 text-2xl", 228 229 ), 229 - event.on_click(CloseModal), 230 + event.on_click(UserClosedModal), 230 231 ], 231 232 [element.text("×")], 232 233 ), ··· 380 381 return: fn() { attribute.class("menu-active") }, 381 382 otherwise: fn() { attribute.none() }, 382 383 ), 383 - event.on_click(model_type.TimeLineTo("global")), 384 + event.on_click(model_type.UserSwitchedTimeLineTo("global")), 384 385 ], 385 386 [ 386 387 svgs.globe("inline h-5 w-5 mr-2"), ··· 396 397 return: fn() { attribute.class("menu-active") }, 397 398 otherwise: fn() { attribute.none() }, 398 399 ), 399 - event.on_click(model_type.TimeLineTo("following")), 400 + event.on_click(model_type.UserSwitchedTimeLineTo( 401 + "following", 402 + )), 400 403 ], 401 404 [ 402 405 svgs.follows("inline h-5 w-5 mr-2"), ··· 412 415 return: fn() { attribute.class("menu-active") }, 413 416 otherwise: fn() { attribute.none() }, 414 417 ), 415 - event.on_click(model_type.TimeLineTo("mutuals")), 418 + event.on_click(model_type.UserSwitchedTimeLineTo( 419 + "mutuals", 420 + )), 416 421 ], 417 422 [ 418 423 // SVG: Heart and star overlapping for 'Mutuals' ··· 797 802 html.a( 798 803 [ 799 804 attribute.class("btn btn-warn font-menuitems"), 800 - event.on_click(Logout), 805 + event.on_click(UserClickedLogout), 801 806 ], 802 807 [ 803 808 element.text("Log out"),