Skip to content

Commit

Permalink
standardised timings for refresh @ 10s & 20s, and noted same in menu
Browse files Browse the repository at this point in the history
fixed bug in preferences window with a click out guidance
  • Loading branch information
DarraghRogan committed Jul 20, 2020
1 parent 90d0879 commit b476876
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 32 deletions.
37 changes: 17 additions & 20 deletions Per mille/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {

if defaults.integer(forKey: "InstagramInUse") == 1{
DataLoaderInstagram().loadInstagramData()
self.instagramUsername.title = "Username: Loading, please wait"
self.instagramFollowers.title = "Followers ጰ: Loading, please wait"
self.instagramAverageLikes.title = "Average ♥: Loading, please wait"
self.instagramLastPost.title = "Last Post: Loading, please wait"
self.instagramUsername.title = "Username: Loading, please wait (10s)"
self.instagramFollowers.title = "Followers ጰ: Loading, please wait (10s)"
self.instagramAverageLikes.title = "Average ♥: Loading, please wait (10s)"
self.instagramLastPost.title = "Last Post: Loading, please wait (10s)"
}
else{
}
Expand All @@ -265,34 +265,31 @@ class AppDelegate: NSObject, NSApplicationDelegate {

if defaults.integer(forKey: "TwitterInUse") == 1{
DataLoaderTwitter().loadTwitterData()
self.twitterScreenName.title = "Screen Name: Loading, please wait"
self.twitterFollowers.title = "Followers ጰ: Loading, please wait"
self.twitterListed.title = "Listed: Loading, please wait"
self.twitterPinnedTweet.title = "Pinned Tweet: Loading, please wait"
self.twitterScreenName.title = "Screen Name: Loading, please wait (10s)"
self.twitterFollowers.title = "Followers ጰ: Loading, please wait (10s)"
self.twitterListed.title = "Listed: Loading, please wait (10s)"
self.twitterPinnedTweet.title = "Pinned Tweet: Loading, please wait (10s)"
}
else{
}

if defaults.integer(forKey: "YouTubeInUse") == 1{
DataLoaderYouTube().loadYouTubeDataChannel()

DispatchQueue.main.asyncAfter(deadline: .now() + 2.0, execute: {
DataLoaderYouTube().loadYouTubeDataSearch()
})
DataLoaderYouTube().loadYouTubeDataSearch()

DispatchQueue.main.asyncAfter(deadline: .now() + 4.0, execute: {
DispatchQueue.main.asyncAfter(deadline: .now() + 10.0, execute: {
DataLoaderYouTube().loadYouTubeDataVideos()
})

self.youTubeTitle.title = "Channel: Loading, please wait"
self.youTubeSubscribers.title = "Subscribers ጰ: Loading, please wait"
self.youTubeViews.title = "Lifetime ▶: Loading, please wait"
self.YouTubeLatestVideo.title = "Latest Video: Loading, please wait"
self.youTubeTitle.title = "Channel: Loading, please wait (10s)"
self.youTubeSubscribers.title = "Subscribers ጰ: Loading, please wait (10s)"
self.youTubeViews.title = "Lifetime ▶: Loading, please wait (10s)"
self.YouTubeLatestVideo.title = "Latest Video: Loading, please wait (20s)"
}
else{
}

DispatchQueue.main.asyncAfter(deadline: .now() + 7.0, execute: {
DispatchQueue.main.asyncAfter(deadline: .now() + 10.1, execute: {

if self.defaults.integer(forKey: "InstagramInUse") == 1{
self.instagramUsername.title = "Username: \(String(instagramData.username))"
Expand All @@ -313,7 +310,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
})


DispatchQueue.main.asyncAfter(deadline: .now() + 3.0, execute: {
DispatchQueue.main.asyncAfter(deadline: .now() + 10.1, execute: {

if self.defaults.integer(forKey: "TwitterInUse") == 1{

Expand Down Expand Up @@ -361,7 +358,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}


DispatchQueue.main.asyncAfter(deadline: .now() + 4.1, execute: {
DispatchQueue.main.asyncAfter(deadline: .now() + 10.1, execute: {

if youTubeDataVideos.pageInfo?.resultsPerPage == 1 {
let YouTubeLatestVideoViews: Int = Int(youTubeDataVideos.items?[0].statistics.viewCount as! String) ?? 0
Expand Down
7 changes: 2 additions & 5 deletions Per mille/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -1008,17 +1008,14 @@
<rect key="frame" x="365" y="139" width="898" height="60"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" selectable="YES" alignment="left" id="U86-CB-8cS">
<font key="font" metaFont="system" size="12"/>
<font key="font" metaFont="label" size="12"/>
<string key="title">Please check YouTube Channel ID, it should be similar to this:
UClt25f9gZu4_M3sxpAAJ4QQ
Click the help button for to access an (unaffiliated) service which
converts Channel URL to Channel ID.</string>
<color key="textColor" name="systemRedColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<action selector="YouTubeGuidanceFieldClicked:" target="XfG-lQ-9wD" id="van-Mk-5eh"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="GPu-zj-A32">
<rect key="frame" x="19" y="82" width="123" height="16"/>
Expand All @@ -1042,7 +1039,7 @@ converts Channel URL to Channel ID.</string>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" selectable="YES" title="Autorun ‰ Per mille at Mac startup" id="uzo-OR-316">
<font key="font" metaFont="system"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
Expand Down
14 changes: 7 additions & 7 deletions Per mille/DataLoaderYouTube.swift
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,13 @@ var youTubeDataVideos = YouTubeDataStructureVideos()
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print("Received from the YouTube Search API")
if let data = data,
let urlContent = NSString(data: data, encoding: String.Encoding.ascii.rawValue) {
print(urlContent)
} else {
print("error with printing string encoded data")
}
// print("Received from the YouTube Search API")
// if let data = data,
// let urlContent = NSString(data: data, encoding: String.Encoding.ascii.rawValue) {
// print(urlContent)
// } else {
// print("error with printing string encoded data")
// }
//Parse JSON
let decoder = JSONDecoder()
do {
Expand Down

0 comments on commit b476876

Please sign in to comment.