auto-updates: Do not poll for updates on dev channel (#13311)

Thorsten Ball created

Our dev builds don't have updates and will never have updates, so
instead of polling our servers every time we start a dev instance, let's
disable it for the dev channel.

Release Notes:

- N/A

Change summary

crates/auto_update/src/auto_update.rs | 12 ++++++++++++
crates/release_channel/src/lib.rs     |  8 ++++++++
2 files changed, 20 insertions(+)

Detailed changes

crates/auto_update/src/auto_update.rs 🔗

@@ -141,8 +141,13 @@ pub fn init(http_client: Arc<HttpClientWithUrl>, cx: &mut AppContext) {
     let auto_updater = cx.new_model(|cx| {
         let updater = AutoUpdater::new(version, http_client);
 
+        let poll_for_updates = ReleaseChannel::try_global(cx)
+            .map(|channel| channel.poll_for_updates())
+            .unwrap_or(false);
+
         if option_env!("ZED_UPDATE_EXPLANATION").is_none()
             && env::var("ZED_UPDATE_EXPLANATION").is_err()
+            && poll_for_updates
         {
             let mut update_subscription = AutoUpdateSetting::get_global(cx)
                 .0
@@ -186,6 +191,13 @@ pub fn check(_: &Check, cx: &mut WindowContext) {
         return;
     }
 
+    if !ReleaseChannel::try_global(cx)
+        .map(|channel| channel.poll_for_updates())
+        .unwrap_or(false)
+    {
+        return;
+    }
+
     if let Some(updater) = AutoUpdater::get(cx) {
         updater.update(cx, |updater, cx| updater.poll(cx));
     } else {

crates/release_channel/src/lib.rs 🔗

@@ -118,6 +118,14 @@ impl ReleaseChannel {
             .map(|channel| channel.0)
     }
 
+    /// Returns whether we want to poll for updates for this [`ReleaseChannel`]
+    pub fn poll_for_updates(&self) -> bool {
+        match self {
+            ReleaseChannel::Dev => false,
+            _ => true,
+        }
+    }
+
     /// Returns the display name for this [`ReleaseChannel`].
     pub fn display_name(&self) -> &'static str {
         match self {