The unknown contact.

Brandon Wissmann
Apr 12 · 3 min read
Photo by Elijah Hail on Unsplash

This week I’ve been looking for another issue to work on. I decided to try my hand at this issue on the Status repository. It was quite difficult surprisingly as it was a two part issue. As described by the original poster, if a user clicked a notification that was from somebody they blocked (after having received the notification) or if they deleted the chat, they would be sent to a chat with an unknown user and even have the option to add “unknown user” to their contacts. Very mysterious.

The first thing I did was to go ahead and make sure this issue was still relevant. I found out that this was not so easy, as on my live device I could not receive notifications when I had the debug app along with the production app. I then went to use Genymotion (an android emulator) which I eventually found out I needed to download an extension to get push notifications working on their devices.

Eventually, it all came together and I could finally start testing. I used my phone to send messages onto a spoof account and did all the steps to reproduce. The issue was indeed still there.

I decided to tackle the issue of being able to navigate to a unknown user after blocking the contact. I found the following method that handled push notifications and simply added a flag to check if the user was blocked before continuing. I won’t go into detail as this work was scrapped as soon as I fixed part 2 of the issue.

Part 2 involved the chat not existing. As soon as I started working I realized my previous work was no longer relevant as by fixing this I would fix both. I realized by looking at the code that when a user was blocked the chat was also deleted. Marked as inactive. The same thing is done when a chat is deleted. I therefore decided to build a simple function to check if the chat is active or not which I would then call in the chat handler.

The function looked like this:

(defn is-active?   ([chat]      (:is-active chat))   ([cofx chat-id]      (is-active? (get-chat cofx chat-id))))

It was then used in a existing function:

(fx/defn navigate-to-chat"Takes coeffects map and chat-id, returns effects necessary for navigation and preloading data"[cofx chat-id {:keys [modal? navigation-reset?]}](when (= (is-active? (get-chat cofx chat-id)) true)(condmodal?(fx/merge cofx(navigation/navigate-to-cofx :chat-modal {})(preload-chat-data chat-id))navigation-reset?(fx/merge cofx(navigation/navigate-reset {:index   1:actions [{:routeName :home}{:routeName :chat}]})(preload-chat-data chat-id)):else(fx/merge cofx(navigation/navigate-to-cofx :chat {})(preload-chat-data chat-id)))))

As you can see, the when condition checks if the chat is still around and if it is, it continues on to the regular function. I later went on to testing and was able to submit a pull request. Looking back at how simple it is to explain, I believe that I could have finished this task much quicker if I was more familiar with things like reagent and renatal. (ClojureScript frameworks to run react native and react). I am glad that I tackled the issue as I learned a lot and I hope to see my pull request accepted.