From 6f98ac033cbb1dd25a0c507ab702ab9657b2b537 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sat, 1 Jun 2019 22:16:31 -0700 Subject: [PATCH 1/5] Fix new user create, no more default community --- server/src/api/user.rs | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/server/src/api/user.rs b/server/src/api/user.rs index 9361ca4d8..5d957120b 100644 --- a/server/src/api/user.rs +++ b/server/src/api/user.rs @@ -161,35 +161,6 @@ impl Perform for Oper { } }; - // Sign them up for main community no matter what - let community_follower_form = CommunityFollowerForm { - community_id: 1, - user_id: inserted_user.id, - }; - - let _inserted_community_follower = match CommunityFollower::follow(&conn, &community_follower_form) { - Ok(user) => user, - Err(_e) => { - return Err(APIError::err(&self.op, "Community follower already exists."))? - } - }; - - // If its an admin, add them as a mod and follower to main - if data.admin { - let community_moderator_form = CommunityModeratorForm { - community_id: 1, - user_id: inserted_user.id, - }; - - let _inserted_community_moderator = match CommunityModerator::join(&conn, &community_moderator_form) { - Ok(user) => user, - Err(_e) => { - return Err(APIError::err(&self.op, "Community moderator already exists."))? - } - }; - - } - // Return the jwt Ok( LoginResponse { From 525c570568d502794a7d84fd8ea0e24ceebbcae4 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sun, 2 Jun 2019 09:34:45 -0700 Subject: [PATCH 2/5] Creating the default community and signing people up for it if it doesnt exist. --- server/src/api/user.rs | 47 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/server/src/api/user.rs b/server/src/api/user.rs index 5d957120b..d6d5962eb 100644 --- a/server/src/api/user.rs +++ b/server/src/api/user.rs @@ -161,6 +161,53 @@ impl Perform for Oper { } }; + // Create the main community if it doesn't exist + let main_community: Community = match Community::read_from_name(&conn, "main".to_string()) { + Ok(c) => c, + Err(_e) => { + let community_form = CommunityForm { + name: "main".to_string(), + title: "The Default Community".to_string(), + description: Some("The Default Community".to_string()), + category_id: 1, + creator_id: inserted_user.id, + removed: None, + deleted: None, + updated: None, + }; + Community::create(&conn, &community_form).unwrap() + } + }; + + // Sign them up for main community no matter what + let community_follower_form = CommunityFollowerForm { + community_id: main_community.id, + user_id: inserted_user.id, + }; + + let _inserted_community_follower = match CommunityFollower::follow(&conn, &community_follower_form) { + Ok(user) => user, + Err(_e) => { + return Err(APIError::err(&self.op, "Community follower already exists."))? + } + }; + + // If its an admin, add them as a mod and follower to main + if data.admin { + let community_moderator_form = CommunityModeratorForm { + community_id: main_community.id, + user_id: inserted_user.id, + }; + + let _inserted_community_moderator = match CommunityModerator::join(&conn, &community_moderator_form) { + Ok(user) => user, + Err(_e) => { + return Err(APIError::err(&self.op, "Community moderator already exists."))? + } + }; + + } + // Return the jwt Ok( LoginResponse { From 107765619aa67171bfe46daa533b90867250a47e Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sun, 2 Jun 2019 09:41:57 -0700 Subject: [PATCH 3/5] Fixing communities sorting - Fixes #159 --- ui/src/components/communities.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/src/components/communities.tsx b/ui/src/components/communities.tsx index 96864e9a5..4cad76690 100644 --- a/ui/src/components/communities.tsx +++ b/ui/src/components/communities.tsx @@ -47,8 +47,6 @@ export class Communities extends Component { componentDidMount() { document.title = "Communities - Lemmy"; - let table = document.querySelector('#community_table'); - Sortable.initTable(table); } // Necessary for back button for some reason @@ -176,6 +174,8 @@ export class Communities extends Component { this.state.loading = false; window.scrollTo(0,0); this.setState(this.state); + let table = document.querySelector('#community_table'); + Sortable.initTable(table); } else if (op == UserOperation.FollowCommunity) { let res: CommunityResponse = msg; let found = this.state.communities.find(c => c.id == res.community.id); From ab9659c2e256e421922756b36fbd6b9f91ba3a54 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sun, 2 Jun 2019 18:35:46 -0700 Subject: [PATCH 4/5] Fix page titles for custom site name - Fixes #113 --- ui/src/components/communities.tsx | 2 +- ui/src/components/community.tsx | 2 +- ui/src/components/create-community.tsx | 3 ++- ui/src/components/create-post.tsx | 3 ++- ui/src/components/inbox.tsx | 2 +- ui/src/components/login.tsx | 2 +- ui/src/components/main.tsx | 6 ++---- ui/src/components/modlog.tsx | 2 +- ui/src/components/post.tsx | 2 +- ui/src/components/search.tsx | 4 ++-- ui/src/components/sponsors.tsx | 3 ++- ui/src/components/user.tsx | 2 +- ui/src/index.html | 1 - ui/src/services/UserService.ts | 1 - ui/src/services/WebSocketService.ts | 1 - 15 files changed, 17 insertions(+), 19 deletions(-) diff --git a/ui/src/components/communities.tsx b/ui/src/components/communities.tsx index 4cad76690..c4efe1fbe 100644 --- a/ui/src/components/communities.tsx +++ b/ui/src/components/communities.tsx @@ -46,7 +46,7 @@ export class Communities extends Component { } componentDidMount() { - document.title = "Communities - Lemmy"; + document.title = `Communities - ${WebSocketService.Instance.site.name}`; } // Necessary for back button for some reason diff --git a/ui/src/components/community.tsx b/ui/src/components/community.tsx index efa908f16..6a1f5da2b 100644 --- a/ui/src/components/community.tsx +++ b/ui/src/components/community.tsx @@ -200,7 +200,7 @@ export class Community extends Component { this.state.community = res.community; this.state.moderators = res.moderators; this.state.admins = res.admins; - document.title = `/c/${this.state.community.name} - Lemmy`; + document.title = `/c/${this.state.community.name} - ${WebSocketService.Instance.site.name}`; this.setState(this.state); this.fetchPosts(); } else if (op == UserOperation.EditCommunity) { diff --git a/ui/src/components/create-community.tsx b/ui/src/components/create-community.tsx index a9345f72a..5e31efc2b 100644 --- a/ui/src/components/create-community.tsx +++ b/ui/src/components/create-community.tsx @@ -1,6 +1,7 @@ import { Component } from 'inferno'; import { CommunityForm } from './community-form'; import { Community } from '../interfaces'; +import { WebSocketService } from '../services'; export class CreateCommunity extends Component { @@ -10,7 +11,7 @@ export class CreateCommunity extends Component { } componentDidMount() { - document.title = "Create Community - Lemmy"; + document.title = `Create Community - ${WebSocketService.Instance.site.name}`; } render() { diff --git a/ui/src/components/create-post.tsx b/ui/src/components/create-post.tsx index fdee01f66..0e37ba1d9 100644 --- a/ui/src/components/create-post.tsx +++ b/ui/src/components/create-post.tsx @@ -1,5 +1,6 @@ import { Component } from 'inferno'; import { PostForm } from './post-form'; +import { WebSocketService } from '../services'; export class CreatePost extends Component { @@ -9,7 +10,7 @@ export class CreatePost extends Component { } componentDidMount() { - document.title = "Create Post - Lemmy"; + document.title = `Create Post - ${WebSocketService.Instance.site.name}`; } render() { diff --git a/ui/src/components/inbox.tsx b/ui/src/components/inbox.tsx index 69ddc44b4..5fb7f874b 100644 --- a/ui/src/components/inbox.tsx +++ b/ui/src/components/inbox.tsx @@ -49,7 +49,7 @@ export class Inbox extends Component { } componentDidMount() { - document.title = `/u/${UserService.Instance.user.username} Inbox - Lemmy`; + document.title = `/u/${UserService.Instance.user.username} Inbox - ${WebSocketService.Instance.site.name}`; } render() { diff --git a/ui/src/components/login.tsx b/ui/src/components/login.tsx index 33cebdd62..6eb88438d 100644 --- a/ui/src/components/login.tsx +++ b/ui/src/components/login.tsx @@ -50,7 +50,7 @@ export class Login extends Component { } componentDidMount() { - document.title = "Login - Lemmy"; + document.title = `Login - ${WebSocketService.Instance.site.name}`; } render() { diff --git a/ui/src/components/main.tsx b/ui/src/components/main.tsx index 153c9f727..fe59ac2c2 100644 --- a/ui/src/components/main.tsx +++ b/ui/src/components/main.tsx @@ -101,10 +101,6 @@ export class Main extends Component { this.subscription.unsubscribe(); } - componentDidMount() { - document.title = "Lemmy"; - } - // Necessary for back button for some reason componentWillReceiveProps(nextProps: any) { if (nextProps.history.action == 'POP') { @@ -377,6 +373,8 @@ export class Main extends Component { this.state.site.site = res.site; this.state.site.banned = res.banned; this.setState(this.state); + document.title = `${WebSocketService.Instance.site.name}`; + } else if (op == UserOperation.EditSite) { let res: SiteResponse = msg; this.state.site.site = res.site; diff --git a/ui/src/components/modlog.tsx b/ui/src/components/modlog.tsx index 894887ae1..b8e584615 100644 --- a/ui/src/components/modlog.tsx +++ b/ui/src/components/modlog.tsx @@ -45,7 +45,7 @@ export class Modlog extends Component { } componentDidMount() { - document.title = "Modlog - Lemmy"; + document.title = `Modlog - ${WebSocketService.Instance.site.name}`; } setCombined(res: GetModlogResponse) { diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx index 3e2e07b35..7152941f1 100644 --- a/ui/src/components/post.tsx +++ b/ui/src/components/post.tsx @@ -253,7 +253,7 @@ export class Post extends Component { this.state.moderators = res.moderators; this.state.admins = res.admins; this.state.loading = false; - document.title = `${this.state.post.name} - Lemmy`; + document.title = `${this.state.post.name} - ${WebSocketService.Instance.site.name}`; this.setState(this.state); } else if (op == UserOperation.CreateComment) { let res: CommentResponse = msg; diff --git a/ui/src/components/search.tsx b/ui/src/components/search.tsx index 7c72939a7..0d3b255d0 100644 --- a/ui/src/components/search.tsx +++ b/ui/src/components/search.tsx @@ -52,7 +52,7 @@ export class Search extends Component { } componentDidMount() { - document.title = "Search - Lemmy"; + document.title = `Search - ${WebSocketService.Instance.site.name}`; } render() { @@ -250,7 +250,7 @@ export class Search extends Component { let res: SearchResponse = msg; this.state.searchResponse = res; this.state.loading = false; - document.title = `Search - ${this.state.q} - Lemmy`; + document.title = `Search - ${this.state.q} - ${WebSocketService.Instance.site.name}`; window.scrollTo(0,0); this.setState(this.state); diff --git a/ui/src/components/sponsors.tsx b/ui/src/components/sponsors.tsx index 4c9d02ffb..c0b36e4cc 100644 --- a/ui/src/components/sponsors.tsx +++ b/ui/src/components/sponsors.tsx @@ -1,4 +1,5 @@ import { Component } from 'inferno'; +import { WebSocketService } from '../services'; let general = [ @@ -17,7 +18,7 @@ export class Sponsors extends Component { } componentDidMount() { - document.title = "Sponsors - Lemmy"; + document.title = `Sponsors - ${WebSocketService.Instance.site.name}`; } render() { diff --git a/ui/src/components/user.tsx b/ui/src/components/user.tsx index 4cd88abc8..d7c2bf66d 100644 --- a/ui/src/components/user.tsx +++ b/ui/src/components/user.tsx @@ -341,7 +341,7 @@ export class User extends Component { this.state.moderates = res.moderates; this.state.posts = res.posts; this.state.loading = false; - document.title = `/u/${this.state.user.name} - Lemmy`; + document.title = `/u/${this.state.user.name} - ${WebSocketService.Instance.site.name}`; window.scrollTo(0,0); this.setState(this.state); } else if (op == UserOperation.EditComment) { diff --git a/ui/src/index.html b/ui/src/index.html index ae511adee..c510291be 100644 --- a/ui/src/index.html +++ b/ui/src/index.html @@ -6,7 +6,6 @@ - Lemmy diff --git a/ui/src/services/UserService.ts b/ui/src/services/UserService.ts index d3259adb4..92315db7b 100644 --- a/ui/src/services/UserService.ts +++ b/ui/src/services/UserService.ts @@ -16,7 +16,6 @@ export class UserService { } else { console.log('No JWT cookie found.'); } - } public login(res: LoginResponse) { diff --git a/ui/src/services/WebSocketService.ts b/ui/src/services/WebSocketService.ts index 2b30f7d8f..2fa8a4855 100644 --- a/ui/src/services/WebSocketService.ts +++ b/ui/src/services/WebSocketService.ts @@ -8,7 +8,6 @@ import { UserService } from './'; export class WebSocketService { private static _instance: WebSocketService; public subject: Subject; - public instanceName: string; public site: Site; public admins: Array; From 03435b5d3aeb241a0b279758ba8072a74a08b100 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sun, 2 Jun 2019 19:46:30 -0700 Subject: [PATCH 5/5] Version bump --- ui/src/version.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/version.ts b/ui/src/version.ts index 45ea6ab9e..0e51e1a50 100644 --- a/ui/src/version.ts +++ b/ui/src/version.ts @@ -1 +1 @@ -export let version: string = "v0.0.5-16-gc7d8d5f"; \ No newline at end of file +export let version: string = "v0.0.6-0-g27b108a"; \ No newline at end of file