{"id":42470,"date":"2024-04-16T23:55:36","date_gmt":"2024-04-16T21:55:36","guid":{"rendered":"https:\/\/client4.pro-assistance.fr\/?p=42470"},"modified":"2024-04-16T23:56:44","modified_gmt":"2024-04-16T21:56:44","slug":"the-design-behind-okcupid-s-offline-first-chat-app","status":"publish","type":"post","link":"https:\/\/client4.pro-assistance.fr\/?p=42470","title":{"rendered":"The Design Behind OkCupid&#8217;s Offline-first Chat App"},"content":{"rendered":"<p><title>The Design Behind OkCupid&#8217;s Offline-first Chat App<\/title><\/p>\n<p>The chat app is a table-stakes feature for any dating app. A responsive and reliable messaging experience encourages users to stay on the platform for communications. This is desirable from a trust and safety standpoint, as abusive messages produced on the <a href=\"https:\/\/kissbrides.com\/fi\/tsekin-naiset\/\">treffit T\u0415\u040eekin naisten kanssa<\/a> platform can be effectively moderated and proper actions can be promptly taken.<\/p>\n<p>In this article, we will explore the design of an offline-first chat app on the OkCupid website, in particular, how we achieved responsiveness by implementing optimistic UI design patterns and reliability by incorporating a messages cache to support offline-mode.<!--more--><\/p>\n<h2>Why do we need the chat app to be offline-first?<\/h2>\n<p>Quick response time from the server is not always achievable, especially when the user is on a slow network on a mobile device. Offline-mode support is common for mobile apps because mobile apps often have to deal with spotty internet connection.<\/p>\n<p>1. If the web app is used in a mobile web browser on a phone where reliable network connections are not guaranteed.<\/p>\n<p>It&#8217;s common for a web app that runs in a desktop browser and the web app that runs in a mobile browser to share code (sometimes they are the same web app!). On mobile web, being offline is a real possibility.<\/p>\n<p>In a chat app, it can be frustrating user experience if you spend a long time drafting a new message to be sent but the draft is not persisted when the message fails to send, forcing you to have to type it all up again.<\/p>\n<p>The desktop version of popular chat apps like iMessage, Whatsapp, and Facebook Messenger all support offline-mode so users expect offline-mode support for any chat app regardless of the device.<\/p>\n<h2>What does offline-first mean exactly?<\/h2>\n<p>When the app is completely offline, the POST request for new content never resolves. If the app is designed to be offline-first, we would expect the app to still show the new content (responsiveness) and to still allow us to create newer content without losing the previously created new content (persistence).<\/p>\n<p>Responsiveness is achieved by applying optimistic UI techniques. To make user interactions seem instant in a CRUD app, we can mock the expected server response before the server response is received and display the mocked response (the optimistic result). Optimistic results are things that exist client-side but not server-side.<\/p>\n<p>Things can get very hairy when we need to persist an arbitrary number of optimistic results and these optimistic results need to be displayed alongside things that exist server-side.<\/p>\n<p>We will discuss that in more detail in the solution approach section. But first, let&#8217;s look at the design decisions behind the offline-first OkCupid chat app.<\/p>\n<h2>Architectural Design Considerations<\/h2>\n<p>The previous section answers the question of why we need to have offline-mode for the chat app. This section answers the question of How we should implement an offline-first chat app for OkCupid.<\/p>\n<p>In general, to design a correct and future-proof solution, we must first consider the requirements and constraints to establish the boundaries for our problem-solving. Second, we must decompose the problem into sub-problems and search through the solution space for the best way to solve these sub-problems.<\/p>\n<h2>Requirements Gathering<\/h2>\n<p>Understanding the scope of the problem requires insight into the business context of the problem we are solving and how the solution will need to scale for future use cases.<\/p>\n<p>There are must-have and nice-to-have requirements for a modern chat app. The best way to enumerate the functional requirements for a feature is to use user stories. As a user, I want to be able to send and receive messages so that I can communicate with other users. More specifically,<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Design Behind OkCupid&#8217;s Offline-first Chat App The chat app is a table-stakes feature for any dating app. A responsive and reliable messaging experience encourages users to stay on the platform for communications. This is desirable from a trust and safety standpoint, as abusive messages produced on the treffit T\u0415\u040eekin naisten kanssa platform can be [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11671],"tags":[],"class_list":["post-42470","post","type-post","status-publish","format-standard","hentry","category-fi-tsekin-naiset-parhaat-oikeat-postimyynti-2"],"_links":{"self":[{"href":"https:\/\/client4.pro-assistance.fr\/index.php?rest_route=\/wp\/v2\/posts\/42470","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/client4.pro-assistance.fr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/client4.pro-assistance.fr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/client4.pro-assistance.fr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/client4.pro-assistance.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=42470"}],"version-history":[{"count":1,"href":"https:\/\/client4.pro-assistance.fr\/index.php?rest_route=\/wp\/v2\/posts\/42470\/revisions"}],"predecessor-version":[{"id":42471,"href":"https:\/\/client4.pro-assistance.fr\/index.php?rest_route=\/wp\/v2\/posts\/42470\/revisions\/42471"}],"wp:attachment":[{"href":"https:\/\/client4.pro-assistance.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=42470"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/client4.pro-assistance.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=42470"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/client4.pro-assistance.fr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=42470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}