diff --git a/Linux/Tentia.py b/Linux/Tentia.py index 7fe5f2b..7d8c5be 100755 --- a/Linux/Tentia.py +++ b/Linux/Tentia.py @@ -186,7 +186,14 @@ class Controller(QtCore.QObject): func = "tentia_instance.showProfileForEntity('{}');".format(entity) self.app.profile.evaluateJavaScript(func) self.app.profile.show() - + + @QtCore.pyqtSlot(str, str) + def notificateViewsAboutDeletedPostWithIdbyEntity(self, post_id, entity): + func = "tentia_instance.postDeleted('{}', '{}')".format(post_id, entity); + self.app.timelineView.evaluateJavaScript(func) + self.app.mentionsView.evaluateJavaScript(func) + self.app.conversationView.evaluateJavaScript(func) + self.app.profileView.evaluateJavaScript(func) @QtCore.pyqtSlot(str) def authentificationDidNotSucceed(self, errorMessage): diff --git a/Mac/Controller.h b/Mac/Controller.h index fd30b85..103dbdd 100644 --- a/Mac/Controller.h +++ b/Mac/Controller.h @@ -73,6 +73,7 @@ - (void)openURL:(NSString *)url; - (IBAction)showProfile:(id)sender; +- (void)notificateViewsAboutDeletedPostWithId:(NSString *)postId byEntity:(NSString*)entity; - (void)setString:(NSString *)string forKey:(NSString *)aKey; - (void)setSecret:(NSString *)string; diff --git a/Mac/Controller.m b/Mac/Controller.m index 6788090..bfc694b 100644 --- a/Mac/Controller.m +++ b/Mac/Controller.m @@ -90,9 +90,9 @@ NSString *index_string = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@index.html", path] encoding:NSUTF8StringEncoding error:nil]; oauthView = [[WebView alloc] init]; - WebPreferences* prefs = [oauthView preferences]; - [prefs _setLocalStorageDatabasePath:@"~/Library/Application Support/Tentia"]; - [prefs setLocalStorageEnabled:YES]; + //WebPreferences* prefs = [oauthView preferences]; + //[prefs _setLocalStorageDatabasePath:@"~/Library/Application Support/Tentia"]; + //[prefs setLocalStorageEnabled:YES]; viewDelegate.oauthView = oauthView; [[oauthView mainFrame] loadHTMLString:index_string baseURL:url]; [oauthView setFrameLoadDelegate:viewDelegate]; @@ -113,7 +113,7 @@ { [self initOauth]; - NSString *localStoragePath = @"~/Library/Application Support/Tentia"; + //NSString *localStoragePath = @"~/Library/Application Support/Tentia"; NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Webkit/"]; NSURL *url = [NSURL fileURLWithPath:path]; @@ -125,9 +125,9 @@ [timelineView setPolicyDelegate:viewDelegate]; [timelineView setUIDelegate:viewDelegate]; [[timelineView windowScriptObject] setValue:self forKey:@"controller"]; - WebPreferences* prefs = [timelineView preferences]; - [prefs _setLocalStorageDatabasePath:localStoragePath]; - [prefs setLocalStorageEnabled:YES]; + //WebPreferences* prefs = [timelineView preferences]; + //[prefs _setLocalStorageDatabasePath:localStoragePath]; + //[prefs setLocalStorageEnabled:YES]; viewDelegate.mentionsView = mentionsView; [[mentionsView mainFrame] loadHTMLString:index_string baseURL:url]; @@ -135,9 +135,9 @@ [mentionsView setPolicyDelegate:viewDelegate]; [mentionsView setUIDelegate:viewDelegate]; [[mentionsView windowScriptObject] setValue:self forKey:@"controller"]; - prefs = [mentionsView preferences]; - [prefs _setLocalStorageDatabasePath:localStoragePath]; - [prefs setLocalStorageEnabled:YES]; + //prefs = [mentionsView preferences]; + //[prefs _setLocalStorageDatabasePath:localStoragePath]; + //[prefs setLocalStorageEnabled:YES]; viewDelegate.conversationView = conversationView; [[conversationView mainFrame] loadHTMLString:index_string baseURL:url]; @@ -145,9 +145,9 @@ [conversationView setPolicyDelegate:viewDelegate]; [conversationView setUIDelegate:viewDelegate]; [[conversationView windowScriptObject] setValue:self forKey:@"controller"]; - prefs = [conversationView preferences]; - [prefs _setLocalStorageDatabasePath:localStoragePath]; - [prefs setLocalStorageEnabled:YES]; + //prefs = [conversationView preferences]; + //[prefs _setLocalStorageDatabasePath:localStoragePath]; + //[prefs setLocalStorageEnabled:YES]; viewDelegate.profileView = profileView; [[profileView mainFrame] loadHTMLString:index_string baseURL:url]; @@ -155,9 +155,9 @@ [profileView setPolicyDelegate:viewDelegate]; [profileView setUIDelegate:viewDelegate]; [[profileView windowScriptObject] setValue:self forKey:@"controller"]; - prefs = [profileView preferences]; - [prefs _setLocalStorageDatabasePath:localStoragePath]; - [prefs setLocalStorageEnabled:YES]; + //prefs = [profileView preferences]; + //[prefs _setLocalStorageDatabasePath:localStoragePath]; + //[prefs setLocalStorageEnabled:YES]; } else @@ -421,6 +421,15 @@ } } +- (void)notificateViewsAboutDeletedPostWithId:(NSString *)postId byEntity:(NSString*)entity +{ + NSString *fun = [NSString stringWithFormat:@"tentia_instance.postDeleted('%@', '%@')", postId, entity]; + [timelineView stringByEvaluatingJavaScriptFromString:fun]; + [mentionsView stringByEvaluatingJavaScriptFromString:fun]; + [conversationView stringByEvaluatingJavaScriptFromString:fun]; + [profileView stringByEvaluatingJavaScriptFromString:fun]; +} + /* - (void)storeAccessToken:(NSString *)_accessToken secret:(NSString *)secret userId:(NSString *)userId andScreenName:(NSString *)screenName diff --git a/Mac/ViewDelegate.m b/Mac/ViewDelegate.m index 0209416..7f44d15 100644 --- a/Mac/ViewDelegate.m +++ b/Mac/ViewDelegate.m @@ -99,13 +99,20 @@ } } -- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems { +- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems +{ + // FIXME + /* + NSMutableArray *menuItems = [NSMutableArray arrayWithArray:defaultMenuItems]; + for (NSMenuItem*item in defaultMenuItems) { if ([[item title] isEqualToString:@"Reload"]) { - [item setAction:@selector(reload:)]; - [item setTarget:self]; + //[item setAction:@selector(reload:)]; + //[item setTarget:self]; + } else { + [menuItems addObject:item]; } - } + }*/ return defaultMenuItems; } diff --git a/WebKit/scripts/controller/Timeline.js b/WebKit/scripts/controller/Timeline.js index 12fcd93..649d20a 100644 --- a/WebKit/scripts/controller/Timeline.js +++ b/WebKit/scripts/controller/Timeline.js @@ -62,10 +62,8 @@ function(Core, Paths, HostApp, URI) { } else if (status.type == "https://tent.io/types/post/delete/v0.1.0") { - var li = document.getElementById("post-" + status.content.id); - if (li) { - this.body.removeChild(li); - } + HostApp.notificateViewsAboutDeletedPost(status.content.id, status.entity); + } else if (status.type == "https://tent.io/types/post/repost/v0.1.0") { this.getRepost(status, this.body.firstChild); diff --git a/WebKit/scripts/helper/Core.js b/WebKit/scripts/helper/Core.js index fb4501a..0882bb2 100644 --- a/WebKit/scripts/helper/Core.js +++ b/WebKit/scripts/helper/Core.js @@ -747,6 +747,13 @@ function(jQuery, Paths, URI, HostApp, Cache) { HostApp.openNewMessageWidow(entity, status_id, string, is_private); } + Core.prototype.postDeleted = function(post_id, entity) { + var li = document.getElementById("post-" + post_id); + if (li) { + this.body.removeChild(li); + } + }; + return Core; }); \ No newline at end of file diff --git a/WebKit/scripts/helper/HostApp.js b/WebKit/scripts/helper/HostApp.js index 8d6ff45..a62325d 100644 --- a/WebKit/scripts/helper/HostApp.js +++ b/WebKit/scripts/helper/HostApp.js @@ -132,6 +132,14 @@ define(function() { return OS_TYPE == "mac" ? "OS X" : "Linux"; } + HostApp.notificateViewsAboutDeletedPost = function(postId, entity) { + if (OS_TYPE == "mac") { + controller.notificateViewsAboutDeletedPostWithId_byEntity_(postId, entity); + } else { + controller.notificateViewsAboutDeletedPostWithIdbyEntity(postId, entity); + } + } + return HostApp; }); \ No newline at end of file