@@ -130,15 +130,15 @@ impl<Delegate: AppDelegate, Downloader: AppDownloader + Send + 'static> AppDownl
130
130
131
131
/// Implementation of [fetch::ProgressUpdater] that updates some [AppDelegate].
132
132
pub struct UiProgressUpdater < Delegate : AppDelegate > {
133
- domain : String ,
133
+ domain : Option < String > ,
134
134
prev_progress : Option < u32 > ,
135
135
queue : Delegate :: Queue ,
136
136
}
137
137
138
138
impl < Delegate : AppDelegate > UiProgressUpdater < Delegate > {
139
139
pub fn new ( queue : Delegate :: Queue ) -> Self {
140
140
Self {
141
- domain : "unknown source" . to_owned ( ) ,
141
+ domain : None ,
142
142
prev_progress : None ,
143
143
queue,
144
144
}
@@ -161,9 +161,13 @@ impl<Delegate: AppDelegate> UiProgressUpdater<Delegate> {
161
161
format ! (
162
162
"{} {}... ({complete_percentage}%)" ,
163
163
resource:: DOWNLOADING_DESC_PREFIX ,
164
- self . domain
164
+ self . domain( )
165
165
)
166
166
}
167
+
168
+ fn domain ( & self ) -> & str {
169
+ self . domain . as_deref ( ) . unwrap_or ( "unknown source" )
170
+ }
167
171
}
168
172
169
173
impl < Delegate : AppDelegate + ' static > fetch:: ProgressUpdater for UiProgressUpdater < Delegate > {
@@ -201,6 +205,6 @@ impl<Delegate: AppDelegate + 'static> fetch::ProgressUpdater for UiProgressUpdat
201
205
// Parse out domain name
202
206
let url = url. strip_prefix ( "https://" ) . unwrap_or ( url) ;
203
207
let ( domain, _) = url. split_once ( '/' ) . unwrap_or ( ( url, "" ) ) ;
204
- self . domain = domain. to_owned ( ) ;
208
+ self . domain = Some ( domain. to_owned ( ) ) ;
205
209
}
206
210
}
0 commit comments