From: Dessalines Date: Tue, 21 Jul 2020 13:20:23 +0000 (-0400) Subject: Adding version to GetSite. Fixes #1001 (#1002) X-Git-Url: http://these/git/%7B%60https:/%7B%60css/themes/%22https:/nerdica.net/%7BpictrsAvatarThumbnail%28this.props.site.site.icon%29%7D?a=commitdiff_plain;h=55ce7b1339a73b8c309dce2fa7c57a6c2d81b301;p=lemmy.git Adding version to GetSite. Fixes #1001 (#1002) * Adding version to GetSite. Fixes #1001 * Removing version.ts file --- diff --git a/docker/prod/deploy.sh b/docker/prod/deploy.sh index 3b7ee174..2e872818 100755 --- a/docker/prod/deploy.sh +++ b/docker/prod/deploy.sh @@ -12,8 +12,6 @@ third_semver=$(echo $new_tag | cut -d "." -f 3) # Setting the version on the front end cd ../../ -echo "export const version: string = '$new_tag';" > "ui/src/version.ts" -git add "ui/src/version.ts" # Setting the version on the backend echo "pub const VERSION: &str = \"$new_tag\";" > "server/src/version.rs" git add "server/src/version.rs" diff --git a/docs/src/contributing_websocket_http_api.md b/docs/src/contributing_websocket_http_api.md index 5af89431..7aab3578 100644 --- a/docs/src/contributing_websocket_http_api.md +++ b/docs/src/contributing_websocket_http_api.md @@ -754,6 +754,8 @@ Search types are `All, Comments, Posts, Communities, Users, Url` site: Option, admins: Vec, banned: Vec, + online: usize, // This is currently broken + version: String, } } ``` diff --git a/server/src/api/site.rs b/server/src/api/site.rs index 241a80e3..a945d9ec 100644 --- a/server/src/api/site.rs +++ b/server/src/api/site.rs @@ -3,6 +3,7 @@ use crate::{ api::{claims::Claims, APIError, Oper, Perform}, apub::fetcher::search_by_apub_id, blocking, + version, websocket::{server::SendAllMessage, UserOperation, WebsocketInfo}, DbPool, LemmyError, @@ -110,6 +111,7 @@ pub struct GetSiteResponse { admins: Vec, banned: Vec, pub online: usize, + version: String, } #[derive(Serialize, Deserialize)] @@ -424,6 +426,7 @@ impl Perform for Oper { admins, banned, online, + version: version::VERSION.to_string(), }) } } @@ -666,6 +669,7 @@ impl Perform for Oper { admins, banned, online: 0, + version: version::VERSION.to_string(), }) } } diff --git a/ui/src/components/admin-settings.tsx b/ui/src/components/admin-settings.tsx index 0034c229..6fe4e934 100644 --- a/ui/src/components/admin-settings.tsx +++ b/ui/src/components/admin-settings.tsx @@ -46,6 +46,7 @@ export class AdminSettings extends Component { admins: [], banned: [], online: null, + version: null, }, siteConfigForm: { config_hjson: null, diff --git a/ui/src/components/footer.tsx b/ui/src/components/footer.tsx index cadb6aa3..e911370f 100644 --- a/ui/src/components/footer.tsx +++ b/ui/src/components/footer.tsx @@ -1,12 +1,41 @@ import { Component } from 'inferno'; import { Link } from 'inferno-router'; -import { repoUrl } from '../utils'; -import { version } from '../version'; import { i18n } from '../i18next'; +import { Subscription } from 'rxjs'; +import { retryWhen, delay, take } from 'rxjs/operators'; +import { WebSocketService } from '../services'; +import { repoUrl, wsJsonToRes } from '../utils'; +import { + UserOperation, + WebSocketJsonResponse, + GetSiteResponse, +} from '../interfaces'; -export class Footer extends Component { +interface FooterState { + version: string; +} + +export class Footer extends Component { + private wsSub: Subscription; + emptyState: FooterState = { + version: null, + }; constructor(props: any, context: any) { super(props, context); + + this.state = this.emptyState; + + this.wsSub = WebSocketService.Instance.subject + .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10)))) + .subscribe( + msg => this.parseMessage(msg), + err => console.error(err), + () => console.log('complete') + ); + } + + componentWillUnmount() { + this.wsSub.unsubscribe(); } render() { @@ -15,7 +44,7 @@ export class Footer extends Component {