RetroShare / RSNewWebUI

30 stars 20 forks source link

Channels/Forums #51

Closed Sukhamjot-Singh closed 2 years ago

Sukhamjot-Singh commented 2 years ago

I have created this draft pull request to start my work on the Channels and forums tab.

Sukhamjot-Singh commented 2 years ago

code_api console_ss_api

I have managed to get all the channels using https://github.com/RetroShare/libretroshare/blob/72f8b7e8e240923731a141c6f2a0438588f04f59/src/retroshare/rsgxschannels.h#L319. But when I call getChannelsInfo, I get this error and Retroshare crashes :/

i cannot pinpoint the problem.

csoler commented 2 years ago

If I use curl -u login:passw http://localhost:9092/rsgxschannels/getChannelsInfo it seems to work. I'm not sure how to pass parameters.

Sukhamjot-Singh commented 2 years ago

If I use curl -u login:passw http://localhost:9092/rsgxschannels/getChannelsInfo it seems to work. I'm not sure how to pass parameters.

Okay, I will look into it. It seems to be a syntax error probably.

csoler commented 2 years ago

apparently with curl, the following works:

curl -u test:user http://localhost:9092/rsgxschannels/getChannelsInfo -d '{"chanIds":["ff8d59ef38cad0429f34cc21749dda71"]}'

Use this to check the syntaxt of the url you're passing

Sukhamjot-Singh commented 2 years ago

apparently with curl, the following works:

curl -u test:user http://localhost:9092/rsgxschannels/getChannelsInfo -d '{"chanIds":["ff8d59ef38cad0429f34cc21749dda71"]}'

Use this to check the syntaxt of the url you're passing

Thanks, I mistook it as an individual input. I had to pass a list. Its working well.

Sukhamjot-Singh commented 2 years ago

image Update: Implemented functional searching in Channels tab.(Tried async).

Sukhamjot-Singh commented 2 years ago

image Update: added channel description.

defnax commented 2 years ago

nice work, but wondering the rest of the webui is not ready/finished and you started with this one :) it will be functional or useable after its done? :D

Sukhamjot-Singh commented 2 years ago

nice work, but wondering the rest of the webui is not ready/finished and you started with this one :) it will be functional or useable after its done? :D

I will also work on the rest of the incomplete webui. It is included in my proposal in the later half. As of now I was proceeding with Channels and Forums tab development as discussed with @csoler.

Sukhamjot-Singh commented 2 years ago

image image Update : Forums tab

defnax commented 2 years ago

hi i has experimented with boards cloned from channels code but it does not load channel and boards has same code structure https://github.com/Sukhamjot-Singh/RSNewWebUI/pull/1 maybe i did mistakes :D

    rs.rsJsonApiRequest('/rsposted/getBoardsSummaries', {}, (data) => {
      getBoards.All = data.boards;

image

Sukhamjot-Singh commented 2 years ago

hi i has experimented with boards cloned from channels code but it does not load channel and boards has same code structure https://github.com/Sukhamjot-Singh/RSNewWebUI/pull/1 maybe i did mistakes :D

    rs.rsJsonApiRequest('/rsposted/getBoardsSummaries', {}, (data) => {
      getBoards.All = data.boards;

image

Okay, maybe console.log() the data to check whether the problem is with the API or with the code.

csoler commented 2 years ago

Defnax, simply cloning the code isn't likely doing what you think if the API is slightly different between channels and boards. I think we should let Sukhamjot make progress on channels before switching to boards.

defnax commented 2 years ago

Defnax, simply cloning the code isn't likely doing what you think if the API is slightly different between channels and boards. I think we should let Sukhamjot make progress on channels before switching to boards.

i has only did a experiment :)

Sukhamjot-Singh commented 2 years ago

image I wanted to check if it is my Channel. In rsgxsflag.h (https://github.com/RetroShare/libretroshare/blob/72f8b7e8e240923731a141c6f2a0438588f04f59/src/retroshare/rsgxsflags.h) It says 0x01 or 0x02, but I am receiving flag 0x07 for my channel.

defnax commented 2 years ago

im not sure but maybe i think it will work without api changes

you need to test if this works:

name: details.mMeta.mGroupName,
posts:  details.mMeta.mVisibleMsgCount,
activity: details.mMeta.mLastPost;
created: details.mMeta.mPublishTs,
isSearched: true,
description: details.mDescription,
image: details.mImage,

in qt code is this function: void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGroup &group)

ui->infoPosts->setText(QString::number(group.mMeta.mVisibleMsgCount));

    if(group.mMeta.mLastPost==0)
        ui->infoLastPost->setText(tr("Never"));
    else
        ui->infoLastPost->setText(DateTime::formatLongDateTime(group.mMeta.mLastPost));

    uint32_t current_sync_time  = GxsGroupFrameDialog::checkDelay(rsGxsChannels->getSyncPeriod(group.mMeta.mGroupId))/86400 ;

    QString sync_string;
    switch(current_sync_time)
    {
    case 5: sync_string = tr("5 days");  break;
    case 15: sync_string = tr("2 weeks");  break;
    case 30: sync_string = tr("1 month");  break;
    case 90: sync_string = tr("3 months");  break;
    case 180: sync_string = tr("6 months");  break;
    case 365: sync_string = tr("1 year");  break;
    case   0: sync_string = tr("indefinitly");  break;
    default:
        sync_string = tr("Unknown");
    }

    auto sync_period = rsGxsChannels->getSyncPeriod(group.mMeta.mGroupId) ;

    if(sync_period > 0 && group.mMeta.mLastPost > 0 && group.mMeta.mLastPost + rsGxsChannels->getSyncPeriod(group.mMeta.mGroupId) < time(NULL) && IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags))
        sync_string += " (Warning: will not allow posts to sync)";

    ui->infoSyncTimeLabel->setText(sync_string);

    QString formatDescription = QString::fromUtf8(group.mDescription.c_str());

    unsigned int formatFlag = RSHTML_FORMATTEXT_EMBED_LINKS;

    // embed smileys ?
    if (Settings->valueFromGroup(QString("ChannelPostsWidget"), QString::fromUtf8("Emoteicons_ChannelDecription"), true).toBool()) {
        formatFlag |= RSHTML_FORMATTEXT_EMBED_SMILEYS;
    }

    formatDescription = RsHtml().formatText(NULL, formatDescription, formatFlag);

    ui->infoDescription->setText(formatDescription);

    ui->infoAdministrator->setId(group.mMeta.mAuthorId) ;

    if(!group.mMeta.mAuthorId.isNull())
    {
        RetroShareLink link = RetroShareLink::createMessage(group.mMeta.mAuthorId, "");
        ui->infoAdministrator->setText(link.toHtml());
    }
    else
        ui->infoAdministrator->setText("[No contact author]");

    ui->infoCreated->setText(DateTime::formatLongDateTime(group.mMeta.mPublishTs));
Sukhamjot-Singh commented 2 years ago

im not sure but maybe i think it will work without api changes

* Posts -> group.mMeta.mVisibleMsgCount

* Last Activity -> group.mMeta.mLastPost

* Date created -> group.mMeta.mPublishTs

you need to test if this works:

name: details.mMeta.mGroupName,
posts:  details.mMeta.mVisibleMsgCount,
activity: details.mMeta.mLastPost;
created: details.mMeta.mPublishTs,
isSearched: true,
description: details.mDescription,
image: details.mImage,

in qt code is this function: void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGroup &group)

ui->infoPosts->setText(QString::number(group.mMeta.mVisibleMsgCount));

  if(group.mMeta.mLastPost==0)
      ui->infoLastPost->setText(tr("Never"));
  else
      ui->infoLastPost->setText(DateTime::formatLongDateTime(group.mMeta.mLastPost));

    uint32_t current_sync_time  = GxsGroupFrameDialog::checkDelay(rsGxsChannels->getSyncPeriod(group.mMeta.mGroupId))/86400 ;

    QString sync_string;
    switch(current_sync_time)
    {
    case 5: sync_string = tr("5 days");  break;
    case 15: sync_string = tr("2 weeks");  break;
    case 30: sync_string = tr("1 month");  break;
    case 90: sync_string = tr("3 months");  break;
    case 180: sync_string = tr("6 months");  break;
    case 365: sync_string = tr("1 year");  break;
    case   0: sync_string = tr("indefinitly");  break;
    default:
        sync_string = tr("Unknown");
    }

    auto sync_period = rsGxsChannels->getSyncPeriod(group.mMeta.mGroupId) ;

    if(sync_period > 0 && group.mMeta.mLastPost > 0 && group.mMeta.mLastPost + rsGxsChannels->getSyncPeriod(group.mMeta.mGroupId) < time(NULL) && IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags))
        sync_string += " (Warning: will not allow posts to sync)";

    ui->infoSyncTimeLabel->setText(sync_string);

  QString formatDescription = QString::fromUtf8(group.mDescription.c_str());

  unsigned int formatFlag = RSHTML_FORMATTEXT_EMBED_LINKS;

  // embed smileys ?
  if (Settings->valueFromGroup(QString("ChannelPostsWidget"), QString::fromUtf8("Emoteicons_ChannelDecription"), true).toBool()) {
      formatFlag |= RSHTML_FORMATTEXT_EMBED_SMILEYS;
  }

  formatDescription = RsHtml().formatText(NULL, formatDescription, formatFlag);

  ui->infoDescription->setText(formatDescription);

  ui->infoAdministrator->setId(group.mMeta.mAuthorId) ;

  if(!group.mMeta.mAuthorId.isNull())
  {
      RetroShareLink link = RetroShareLink::createMessage(group.mMeta.mAuthorId, "");
      ui->infoAdministrator->setText(link.toHtml());
  }
  else
      ui->infoAdministrator->setText("[No contact author]");

  ui->infoCreated->setText(DateTime::formatLongDateTime(group.mMeta.mPublishTs));

Thanks @defnax ,I did not get the idea of checking the qt interface :)

Sukhamjot-Singh commented 2 years ago

Yes @csoler we can merge this. I will open a new P for further work.

csoler commented 2 years ago

@Ronttencandy: can you have a look at this PR? I would like to merge it. Thx.

rottencandy commented 2 years ago

Hi, sorry I haven't been able to actively look at contributions recently. Taking a look right now.

Sukhamjot-Singh commented 2 years ago

@rottencandy Thanks for the review, I will address these issues in an hour.

csoler commented 2 years ago

Once you fixed these issues, do not forget to reset the "Draft" flag so that the PR can be merged.

Sukhamjot-Singh commented 2 years ago

@rottencandy I have passed the attrs into the Layout and fixed the issue in the latest commit. Please review. Also, can you help me with the review of Post API issue -> It receives request very late and sometimes sends empty summaries.

Sukhamjot-Singh commented 2 years ago

I commented out the Post section in the latest commit due to instability. This PR is stable to merge.

rottencandy commented 2 years ago

@Sukhamjot-Singh which section is that, and which endpoint is it calling? I can see a bunch of sections where blocks are commented out. Also I think we should avoid merging commented code if possible.

Sukhamjot-Singh commented 2 years ago

Rest of the code looks okay. If you like we can merge it and continue in the next PR.

Yes, I think now it is ready to be merged. @csoler